We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This issue was originally opened by @npearson72 as hashicorp/packer#10485. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.
Using multi-line arguments in extra_arguments does not work.
extra_arguments
I have the following Ansible provisioner block:
When the --extra-vars arguments are arranged as a single line, all works as expected:
--extra-vars
... { "type": "ansible", "playbook_file": "ansible/playbook.yml", "extra_arguments": [ "--extra-vars", "ssh_user={{user `ssh_user`}} ssh_port={{user `ssh_port`}} pg_data_dir={{user `pg_data_dir`}}", "--tags", "{{ user `tags`}}" ] } ...
When I arrange the --extra-vars as multi-line (valid json syntax), Ansible rejects the command and the script fails to run:
... "provisioners": [ { "type": "ansible", "playbook_file": "ansible/playbook.yml", "extra_arguments": [ "--extra-vars", "ssh_user={{user `ssh_user`}}", "ssh_port={{user `ssh_port`}}", "pg_data_dir={{user `pg_data_dir`}}", "--tags", "{{ user `tags`}}" ] } ] ...
Interestingly... the terminal output shows the same input command in both forms. However the second is rejected.
==> digitalocean: Executing Ansible: ansible-playbook -e packer_build_name="digitalocean" -e packer_builder_type=digitalocean --ssh-extra-args '-o IdentitiesOnly=yes' --extra-vars ssh_user=deployer ssh_port=1111 pg_data_dir=/mnt/pg_data --tags database -e ansible_ssh_private_key_file=/var/folders/jk/_4zr0chs4h13kpkzrfr_gkm40000gn/T/ansible-key233643224 -i /var/folders/jk/_4zr0chs4h13kpkzrfr_gkm40000gn/T/packer-provisioner-ansible381681239 /Users/me/Dev/project/devops/infrastructure/packer/ansible/playbook.yml
==> digitalocean: Executing Ansible: ansible-playbook -e packer_build_name="digitalocean" -e packer_builder_type=digitalocean --ssh-extra-args '-o IdentitiesOnly=yes' --extra-vars ssh_user=deployer ssh_port=1111 pg_data_dir=/mnt/pg_data --tags database -e ansible_ssh_private_key_file=/var/folders/jk/_4zr0chs4h13kpkzrfr_gkm40000gn/T/ansible-key108274220 -i /var/folders/jk/_4zr0chs4h13kpkzrfr_gkm40000gn/T/packer-provisioner-ansible576775579 /Users/me/Dev/project/devops/infrastructure/packer/ansible/playbook.yml
They appear identical, but second throws a non-zero exit with Ansible complaining that the arguments were not correct.
1.6.6
https://gist.github.com/npearson72/a363b559a72f703905a643d4d4ae0450
MacOS 11.1
ansible 2.10.3
https://gist.github.com/npearson72/b998db9cac3af5a7b1b72692f30b1e3d
The text was updated successfully, but these errors were encountered:
No branches or pull requests
This issue was originally opened by @npearson72 as hashicorp/packer#10485. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.
Overview of the Issue
Using multi-line arguments in
extra_arguments
does not work.Reproduction Steps
I have the following Ansible provisioner block:
When the
--extra-vars
arguments are arranged as a single line, all works as expected:When I arrange the
--extra-vars
as multi-line (valid json syntax), Ansible rejects the command and the script fails to run:Interestingly... the terminal output shows the same input command in both forms. However the second is rejected.
First output (with single line arguments):
Second output (with multi-line arguments):
They appear identical, but second throws a non-zero exit with Ansible complaining that the arguments were not correct.
Packer version
1.6.6
Simplified Packer Buildfile
https://gist.github.com/npearson72/a363b559a72f703905a643d4d4ae0450
Operating system and Environment details
MacOS 11.1
ansible 2.10.3
Log Fragments and crash.log files
https://gist.github.com/npearson72/b998db9cac3af5a7b1b72692f30b1e3d
The text was updated successfully, but these errors were encountered: