RedHatQE / teflo

Teflo is a standalone orchestration software that controls the flow of a set of testing scenarios, allowing users to provision machines, deploy software, execute tests against them and manage generated artifacts and report results.
https://teflo.readthedocs.io/en/latest/
GNU General Public License v3.0
14 stars 16 forks source link

Unable to pass multiple files to the extra_vars module #73

Closed DharmitD closed 3 years ago

DharmitD commented 3 years ago

When multiple files are passed as a list in the extra_vars module within ansible_options, the task fails. The file module only works for a single file.

For example, the following code snippet doesn't work:

orchestrate:
  - name: ansible/sys_setup.yml
    description: Clones layered product testsuite
    orchestrator: ansible
    hosts: "interconnect{{ INSTANCE_TAG }}"
    connection: local
    ansible_options:
      extra_vars:
        file:
          - ansible/vars/amq-interconnect_v1.10.yml
          - ansible/amq-interconnect_creds.yml

At present, the extra_vars is looped through by file 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 the file module

shay6 commented 3 years ago

Thanks, @DharmitD, we will open a ticket for this issue

shay6 commented 3 years ago

I created this ticket for this issue https://projects.engineering.redhat.com/browse/CCITCARBON-318

rujutashinde commented 3 years ago

@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

DharmitD commented 3 years ago

@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.

DharmitD commented 3 years ago

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