Hello all, I have a packer build which is building an AWS AMI.
First thing is to set HTTP and HTTPS proxy unfortunately it seems that the shell provisioner does not exit the script ?
I am not quite sure if the issue is that the script itself sets proxy for the running shell or something else. I have added an echo command to see if it gets stuck or proceeds and just does not exit. The script itself works if I try debuging packer and SSHing into the machine and running it from there.
What I tried so far:
- using inline to bash or sudo bash execute the script - permissions error
- using start_retry_timeout - did nothing
- tried exit 0 to force it to quit - did nothing
Whole script downloads a custom proxy binary, sets proxy as itself at specific port and should exit and go to ansible as provisioner which then downloads and installs additional software.
build {
sources = ["source.amazon-ebs.custom_ami"]
provisioner "shell" {
environment_vars = [
"AWS_SECRET_ACCESS_KEY=${var.aws_secret_key}",
"AWS_SESSION_TOKEN=${var.aws_token}",
"AWS_ACCESS_KEY_ID=${var.aws_access_key}",
"REGION=${var.aws_region}"
]
script = "../scripts/outbound_proxy.sh"
execute_command = "{{.Vars}} bash -x '{{.Path}}'"
start_retry_timeout = "1m"
}
provisioner "ansible" {
ansible_env_vars = ["ANSIBLE_CONFIG=../ansible/ansible.cfg"]
playbook_file = "../ansible/siem_packer.yml"
user = "ubuntu"
extra_arguments = [ "--scp-extra-args='-O'" ]
ansible_ssh_extra_args = [
"-oHostKeyAlgorithms=+ssh-rsa -oPubkeyAcceptedKeyTypes=+ssh-rsa"
]
inventory_directory = "../ansible/inventory/aws"
}
}