hashicorp / hashicorp/packer-plugin-ansible
Ansible command as output should be directly runnable in the shell
- Dominant language
- Go
- Stars
- 64
- Forks
- 40
- PR merge metrics
- No merged PRs in 30d
Description
_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
Contributor guide
Research direction
Start at the Ansible provisioner path that executes ansible and prints the command, then reproduce the output with extra-vars containing spaces. Done means the displayed command can be pasted into a shell and rerun with the same arguments, while checking any existing command-output behavior that the payload identifies as potentially general.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ansible, go
- Domain
- devops
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100