Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Not able to pass multiple extra-ansible-args to ansible-bender command #251

Open
rohitashvadialpad opened this issue Apr 18, 2021 · 1 comment

Comments

@rohitashvadialpad
Copy link

rohitashvadialpad commented Apr 18, 2021

Issue 1:

Use case #1:

When I'm trying to pass multiple variable in extra-ansible-args with ansible-bender command like below:

cmd="ansible-bender --debug build -l $target_image_tags --extra-ansible-args="--extra-vars="fun1=foo fun2=zoo"" abc.yml”

After running above command, `fun2=zoo' is taken as a playbook_path instead of abc.yml. ==> I'm not sure whether this is an issue or I'm using ansible-bender command wrongly.

Use case #2:

When I'm passing only one variable in extra-ansible-args like below, there is no issue occurred.

cmd="ansible-bender --debug build -l $target_image_tags --extra-ansible-args="--extra-vars="fun1=foo"" abc.yml”

After running above command, abc.yml is getting picked as a playbook_path. Which is the correct expectation.


Issue 2:

Also, I'm not able to pass file in extra-ansible-args. I'm trying like below:
cmd="ansible-bender --debug build -l $target_image_tags --extra-ansible-args="--extra-vars=@bcd.yml" abc.yml”

After running above command, it's giving errors. I'm not sure whether this feature is supported or not? I'm following https://docs.ansible.com/ansible/latest/cli/ansible-playbook.html#cmdoption-ansible-playbook-e link for reference.

@TomasTomecek
Copy link
Collaborator

Hi! I completed missed this issue -- sorry about that.

Regarding the first one: I can see you're using double-quotes to wrap the whole command and separate arguments as well. This seems to work for me:

$ ansible-bender build --extra-ansible-args="--extra-vars='A=B B=C'" ./playbook.yml

The second problem seems to have the same root cause: the quoting.

I'd suggest to define and change those variables via include_vars so you can edit an actual file instead of fighting quotes in a shell script

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants