I have to deploy an application wich compose of many files to install.
I created a dictionnary whith version and file who need to be install.
Here is the dictionnary
dict_app:
version: RC1
- sql
- bin
version: RC2
- sql
- bin
Run an
- debug: var=dict_app
and you'll see that you don't get what you think.
You have two version so the second one will overwrite the fist one.
And the version is a dict and a list and that will not work as you think.
Just make the variable like this:
dict_app:
RC1:
- sql
- bin
RC2:
- sql
- bin
Here is the YAML ansible code. I try to use json_query to find file of a
version.
- name: Test variable
debug:
msg: "{{ item }}"
with_items: '{{ dict_app | json_query("[?version==`RC1`]") }}'
name: Valorisation de la variable pour les livrables
set_fact:
install_livrable: “{{dict_app|json_query(‘[?version==' + deploy_app.version + '].[livrables]’)}}”
name: Affichage des livrables à installer pour la versiion en cours
debug:
msg: “{{ item }}”
with_items: ‘{{ install_livrable}}’