lst_apps:
- {name: APP01, version: 1234, bdd_sid: BDDSID, bdd_host: SERVEURBDD, bdd_port: 1525}
- 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- name: Test display variable in task file
debug:
msg: "{{ item.bdd_sid }}"
with_items: "{{ tmp_deploy_app }}"[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[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)]- name: Installation des differentes applications
include: 2-install.yml
with_items:
- "{{ mcs_lst_apps }}"
loop_control:
loop_var: tmp_deploy_app
tags: install,test- debug: var=tmp_deploy_appTASK [MCS_ROLE : Installation des differentes applications] ********************************************************************************************
included: /projet/roles/MCS_ROLE/tasks/2-install.yml for SERVER