From 4f007031dd9fa8c2748edf5b317863a8eadca8f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20A=CC=81lvaro?= Date: Thu, 3 Oct 2024 08:52:36 +0200 Subject: [PATCH] fix(ubuntu): Do not try to install brew as root --- os-images/AWS/ubuntu/scripts/install_brew.sh | 5 +++++ os-images/AWS/ubuntu/ubuntu.pkr.hcl | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/os-images/AWS/ubuntu/scripts/install_brew.sh b/os-images/AWS/ubuntu/scripts/install_brew.sh index ec437d971..e60bb1d31 100644 --- a/os-images/AWS/ubuntu/scripts/install_brew.sh +++ b/os-images/AWS/ubuntu/scripts/install_brew.sh @@ -1,5 +1,10 @@ #!/bin/bash +# Exit on failures +set -e +# Echo what runs +set -x + if [[ "$(uname -m)" != 'x86_64' ]]; then echo "brew won't be installed for $(uname -m) architecture" exit 0 diff --git a/os-images/AWS/ubuntu/ubuntu.pkr.hcl b/os-images/AWS/ubuntu/ubuntu.pkr.hcl index c7ec57dc7..98a94d18b 100644 --- a/os-images/AWS/ubuntu/ubuntu.pkr.hcl +++ b/os-images/AWS/ubuntu/ubuntu.pkr.hcl @@ -207,7 +207,7 @@ build { provisioner "shell" { inline_shebang = "/bin/bash -ex" - execute_command = "sudo -E -H bash -c '{{ .Vars }} {{ .Path }}'" + execute_command = "sudo -E -H -u ${var.ssh_username} bash -c '{{ .Vars }} {{ .Path }}'" script = "${path.root}/scripts/install_brew.sh" }