Skip to content
New issue

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

Feature: More control over argument order for ansible provisioner #7241

Closed
duijf opened this issue Jan 29, 2019 · 3 comments
Closed

Feature: More control over argument order for ansible provisioner #7241

duijf opened this issue Jan 29, 2019 · 3 comments

Comments

@duijf
Copy link

duijf commented Jan 29, 2019

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.

@SwampDragons SwampDragons added enhancement provisioner/ansible-remote community-supported-plugin denotes requests for plugins that are supported by the community, not by HashiCorp engineers labels Jan 29, 2019
@SwampDragons
Copy link
Contributor

Sorry for the late response; this is a community-supported tool, which means the HashiCorp maintainers don't spend a ton of time on it. That said, it's probably a pretty straightforward task. All this requires is changing the string defined here into a []string, and following the Command call through the code to make sure that all of the calls to it handle its new format.

@nywilken nywilken removed the community-supported-plugin denotes requests for plugins that are supported by the community, not by HashiCorp engineers label Nov 18, 2020
@ghost ghost closed this as completed Apr 16, 2021
@ghost
Copy link

ghost commented Apr 16, 2021

This issue has been automatically migrated to hashicorp/packer-plugin-ansible#27 because it looks like an issue with that plugin. If you believe this is not an issue with the plugin, please reply to hashicorp/packer-plugin-ansible#27.

@ghost
Copy link

ghost commented May 17, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked as resolved and limited conversation to collaborators May 17, 2021
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants