On 15.05.2019 11:38, COUSSI Matthieu wrote:
Hi everyone,
I have a variable where i want to loop on this in a .yml task file :
My variable :
lst_apps:
- {name: APP01, version: 1234, bdd_sid: BDDSID,
bdd_host:
SERVEURBDD, bdd_port: 1525}
Content of my main.xml :
- name: Test display variable
debug:
msg: "{{ lst_apps }}"
tags: test
- name: Installation des differentes applications
include: 2-install.yml
with_items:
- "{{ lst_apps }}"
loop_control:
loop_var: tmp_deploy_app
tags: install,test
Content of my yml task file where the loop is executed :
- name: Test display variable in task file
debug:
msg: "{{ item.bdd_sid }}"
with_items: "{{ tmp_deploy_app }}"
tmp_deploy_app doesn't contain a list, it is a dict.
You can check that with putting this first in your 2-install.yml file
- debug: var=tmp_deploy_app
So if you are going to loop you need to use with_dict.
But for you example above you only need this
- name: Test display variable in task file
debug:
msg: "{{ tmp_deploy_app.bdd_sid }}"
--
Kai Stian Olstad
--
You received this message because you are subscribed to the Google Groups "Ansible
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/72832cf369fb69be58409a9d970c67ae%40olstad.com.
For more options, visit https://groups.google.com/d/optout.