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 }}"
When i execute the task, the content of variable is correctly display but
the loop in the task file does not work :
[root@ANSIBLESRV projet]# ansible-playbook -l TEST_SRV
/projet/playbooks/DEPLOY_test.yml --extra-vars @extra-vars/structure.yml
--tags "test"
[WARNING]: While constructing a mapping from /projet/roles/TEST_ROLE/tasks/
main.yml, line 12, column 3, found a duplicate dict key
(tags). Using last defined value only.
PLAY [MCSLAB]
*************************************************************************************************************************
TASK [Gathering Facts]
****************************************************************************************************************
ok: [TEST_SRV]
TASK [TEST_ROLE : Test display variable]
********************************************************************************************
ok: [TEST_SRV] => {
"msg": [
{
"bdd_host": "SERVEURBDD",
"bdd_port": 1525,
"bdd_sid": "BDDSID",
"name": "APP01",
"version": "1234"
}
]
}
TASK [TEST_ROLE : Installation des differentes applications]
************************************************************************
included: /projet/roles/TEST_ROLE/tasks/2-install.yml for TEST_SRV
PLAY RECAP
****************************************************************************************************************************
TEST_SRV : ok=3 changed=0 unreachable=0 failed=
0
Ansible version :
[root@ANSIBLESRV projet]# ansible --version
ansible 2.7.10
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules', u
'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.5 (default, Nov 6 2016, 00:28:07) [GCC 4.8.5
20150623 (Red Hat 4.8.5-11)]
Thanks for your help,
Matt
--
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/daee4f58-f6dd-4bb8-8095-0065a60ed024%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.