Closed DharmitD closed 3 years ago
Thanks, @DharmitD, we will open a ticket for this issue
I created this ticket for this issue https://projects.engineering.redhat.com/browse/CCITCARBON-318
@DharmitD you plan to use the file as extra var , so the command would look something like the following :
<ansible-playbook playbook.yml --extra-vars=@some_file --extra-vars=@some_other_file> OR <ansible-playbook playbook.yml -e "@some_file" -e "@some_other_file">
I wanted to know how you run the ansible-playbook when using multiple files as extra vars
@rujutashinde yes, I think the command should look like the one you specified: <ansible-playbook playbook.yml --extra-vars=@some_file --extra-vars=@some_other_file>
Looks like someone tried it out and that format worked: https://stackoverflow.com/questions/31800060/can-extra-vars-receive-multiple-files
If you look at the documentation here, there is an example where a list of values is passed for a single variable:
https://docs.ansible.com/ansible/2.5/user_guide/playbooks_variables.html#passing-variables-on-the-command-line
ansible-playbook arcade.yml --extra-vars '{"pacman":"mrs","ghosts":["inky","pinky","clyde","sue"]}'
Which is why I suggested having it as a list under the file
module, where multiple files could be provided as a list.
By "provision to pass a list to the file module", what I mean is that, we need extra_vars
to support calling multiple files at a time. Right now, it is only able to take a single file path, something like this:
ansible_options:
extra_vars:
file: ansible/vars/amq-interconnect_v1.10.yml
We have a use case where we need to call multiple files - basically pass more than one file as a command line argument to the playbook. So we would need to write the extra_vars
in this way:
ansible_options:
extra_vars:
file:
- ansible/vars/amq-interconnect_v1.10.yml
- ansible/amq-interconnect_creds.yml
This is currently not supported by carbon/teflo, if we write it this way, all the files are ignored and none get called. So the task would be to support calling multiple files at a time within extra_vars
When multiple files are passed as a list in the
extra_vars
module withinansible_options
, the task fails. Thefile
module only works for a single file.For example, the following code snippet doesn't work:
At present, the
extra_vars
is looped through byfile
which a unique key so it can only be set once: https://github.com/RedHatQE/teflo/blob/master/teflo/ansible_helpers.py#L178 There needs to be a provision to pass a list to thefile
module