Not able to pass multiple extra-ansible-args to ansible-bender command
rohitashvadialpad opened this issue · 1 comments
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.
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