From an Ansible playbook via AWX I want to start a docker container, which performs data analysis. Since the data analysis is rather complex there are a lot of parameters, that I need to give to the container. To do so I defined a survey in AWX and use the extra-vars in the API calls.
Since I have a lot of parameters (11 survey questions, 2 of them as multiple choice multiselect) its rather tedious to convert every single one into a boolean/string and have an environment variable for it. Here is an example how this would look like:
- name: "Run Container"
community.docker.docker_container:
image: "{{ docker_image }}"
env:
Var1: "{{ Var1_from_survey | string }}"
Var2: "{{ Var2_from_survey | string }}"
VarN: "{{ VarN_from_survey | string }}"
My idea was to get all extra vars from Ansible via something like "{{ hostvars[inventory_hostname] }}"
and then save them as one environment variable in the container, where I can use something like this
to split them apart.
But it seems that there is no way in Ansible to get all extra-vars in a compacted way.
There is no way with "{{ hostvars[inventory_hostname] }}"
to know which vars are from the survey and which are from Ansible itself.
Do you know what is the best way to transfer a lot of extra-vars from the survey (or API) to a docker container?