Skip to content

Commit 63cc6d1

Browse files
committed
chore: Run var.custom_shell_commands in a separate shell provisioner
This ensures that the ec2-user is seen as member of the docker group when executing commands.
1 parent 40cfba7 commit 63cc6d1

File tree

6 files changed

+44
-12
lines changed

6 files changed

+44
-12
lines changed

images/linux-al2023/github_agent.linux.pkr.hcl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,20 @@ build {
143143
]
144144
provisioner "shell" {
145145
environment_vars = []
146-
inline = concat([
146+
inline = [
147147
"sudo dnf upgrade-minimal -y",
148148
"sudo dnf install -y amazon-cloudwatch-agent jq git docker",
149149
"sudo dnf install -y --allowerasing curl",
150150
"sudo systemctl enable docker.service",
151151
"sudo systemctl enable containerd.service",
152152
"sudo service docker start",
153153
"sudo usermod -a -G docker ec2-user",
154-
], var.custom_shell_commands)
154+
]
155+
}
156+
157+
provisioner "shell" {
158+
environment_vars = []
159+
inline = var.custom_shell_commands
155160
}
156161

157162
provisioner "file" {

images/ubuntu-focal/github_agent.ubuntu.pkr.hcl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ build {
144144
environment_vars = [
145145
"DEBIAN_FRONTEND=noninteractive"
146146
]
147-
inline = concat([
147+
inline = [
148148
"sudo cloud-init status --wait",
149149
"sudo apt-get -y update",
150150
"sudo apt-get -y install ca-certificates curl gnupg lsb-release",
@@ -161,7 +161,12 @@ build {
161161
"sudo curl -f https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip -o awscliv2.zip",
162162
"unzip awscliv2.zip",
163163
"sudo ./aws/install",
164-
], var.custom_shell_commands)
164+
]
165+
}
166+
167+
provisioner "shell" {
168+
environment_vars = []
169+
inline = var.custom_shell_commands
165170
}
166171

167172
provisioner "file" {

images/ubuntu-jammy-arm64/github_agent.ubuntu.pkr.hcl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ build {
144144
environment_vars = [
145145
"DEBIAN_FRONTEND=noninteractive"
146146
]
147-
inline = concat([
147+
inline = [
148148
"sudo cloud-init status --wait",
149149
"sudo apt-get update",
150150
"sudo apt-get -y install ca-certificates curl gnupg lsb-release",
@@ -161,7 +161,12 @@ build {
161161
"sudo curl -f https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip -o awscliv2.zip",
162162
"unzip awscliv2.zip",
163163
"sudo ./aws/install",
164-
], var.custom_shell_commands)
164+
]
165+
}
166+
167+
provisioner "shell" {
168+
environment_vars = []
169+
inline = var.custom_shell_commands
165170
}
166171

167172
provisioner "file" {

images/ubuntu-jammy/github_agent.ubuntu.pkr.hcl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ build {
144144
environment_vars = [
145145
"DEBIAN_FRONTEND=noninteractive"
146146
]
147-
inline = concat([
147+
inline = [
148148
"sudo cloud-init status --wait",
149149
"sudo apt-get -y update",
150150
"sudo apt-get -y install ca-certificates curl gnupg lsb-release",
@@ -161,7 +161,12 @@ build {
161161
"sudo curl -f https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip -o awscliv2.zip",
162162
"unzip awscliv2.zip",
163163
"sudo ./aws/install",
164-
], var.custom_shell_commands)
164+
]
165+
}
166+
167+
provisioner "shell" {
168+
environment_vars = []
169+
inline = var.custom_shell_commands
165170
}
166171

167172
provisioner "file" {

images/windows-core-2019/github_agent.windows.pkr.hcl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,18 @@ build {
108108
}
109109

110110
provisioner "powershell" {
111-
inline = concat([
111+
inline = [
112112
templatefile("./windows-provisioner.ps1", {
113113
action_runner_url = "https://github.com/actions/runner/releases/download/v${local.runner_version}/actions-runner-win-x64-${local.runner_version}.zip"
114114
})
115-
], var.custom_shell_commands)
115+
]
116116
}
117+
118+
provisioner "powershell" {
119+
environment_vars = []
120+
inline = var.custom_shell_commands
121+
}
122+
117123
post-processor "manifest" {
118124
output = "manifest.json"
119125
strip_path = true

images/windows-core-2022/github_agent.windows.pkr.hcl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,18 @@ build {
122122
}
123123

124124
provisioner "powershell" {
125-
inline = concat([
125+
inline = [
126126
templatefile("./windows-provisioner.ps1", {
127127
action_runner_url = "https://github.com/actions/runner/releases/download/v${local.runner_version}/actions-runner-win-x64-${local.runner_version}.zip"
128128
})
129-
], var.custom_shell_commands)
129+
]
130130
}
131+
132+
provisioner "powershell" {
133+
environment_vars = []
134+
inline = var.custom_shell_commands
135+
}
136+
131137
post-processor "manifest" {
132138
output = "manifest.json"
133139
strip_path = true

0 commit comments

Comments
 (0)