packer-plugin-ansible icon indicating copy to clipboard operation
packer-plugin-ansible copied to clipboard

Ansible command as output should be directly runnable in the shell

Open hc-github-team-packer opened this issue 3 years ago • 0 comments

This issue was originally opened by @pjnagel in https://github.com/hashicorp/packer/issues/5412 and has been migrated to this repository. The original issue description is below.


When the Ansible provisioner executes ansible, it prints a line like the following:

Executing Ansible: ansible-playbook --extra-vars packer_build_name=virtualbox-ovf packer_builder_type=virtualbox-ovf -i /tmp/packer-provisioner-ansible432653744 /home/r2d2/setup/lautus_ansible/tau.yml --private-key /tmp/ansible-key857554005 --limit tau-desktop-image.lautus.net

The above command-line is not suitable for pasting into a shell and re-running, due to the embedded spaces not being shell escaped, or quoted. The actual command that was executed is (note the quotes):

ansible-playbook --extra-vars "packer_build_name=virtualbox-ovf packer_builder_type=virtualbox-ovf" -i /tmp/packer-provisioner-ansible432653744 /home/r2d2/setup/lautus_ansible/tau.yml --private-key /tmp/ansible-key857554005 --limit tau-desktop-image.lautus.net

This makes it difficult to debug failing builds. One strategy for debugging builds is to arrange for the build to pause, and then manually re-running the ansible command.

I am not sure whether this issue is specific to ansible builds, or whether this bug affects printing out of shell command-lines in general.

Packer version 1.1.0 Ubuntu 16.04.3 LTS

hc-github-team-packer avatar Dec 13 '21 00:12 hc-github-team-packer