Feature: More control over argument order for ansible provisioner
#27 aperta il 16 apr 2021
Metriche repository
- Star
- (64 stelle)
- Metriche merge PR
- (Metriche PR in attesa)
Descrizione
This issue was originally opened by @duijf as hashicorp/packer#7241. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.
This is a feature request.
Summary: I would like the "command" key for the ansible provisioner to accept lists of strings.
Background: Internally, we have a wrapper around Ansible playbook which ensures that our Ansible playbooks run in the environment they expect. It is responsible for passing the right flags to ansible-playbook for common scenario's, checking preconditions, and some setup. (FWIW, I believe we're not unique in this: I've talked to quite a few people about the way they use Ansible setup and this is quite common from what I've heard)
The wrapper has a subcommand based CLI. So there is our-ansible-wrapper foo, our-ansible-wrapper bar, etc. Because of this, I would like Packer to call our-ansible-wrapper packer-provision PLAYBOOK. This is currently not possible without an intermediate shell script.
What I've tried: This does not work:
{
"type": "ansible",
"command": "our-ansible-wrapper packer-provision",
"playbook_file": "image.yml"
}
This is because Packer tries to find a binary with a file name of the full command key. So including the space and packer-provision.
Adding packer-provision to extra_arguments also does not work.
{
"type": "ansible",
"command": "our-ansible-wrapper",
"playbook_file": "playbooks/image-base.yml",
"extra_arguments": [
"packer-provision"
]
}
This is because those extra arguments are appended to the command after other arguments generated by Packer. So packer generates something like our-ansible-wrapper /path/to/playbook -i /tmp/inventory packer-provision.
More control over the order of arguments would be nice.
Request: I would like this to work:
{
"type": "ansible",
"command": ["our-ansible-wrapper", "packer-provision"],
"playbook_file": "playbooks/image-base.yml"
}
I currently work around this by having a separate shell script where the only purpose is to pass that additional argument to our wrapper. I'd prefer not to need it.
This request might generalize to other provisioners, but I haven't tried those yet.