[default]localhost x=1---- set_fact: x: '{{ x + 1 }}'---- debug: var: x---- hosts: all gather_facts: no tasks: - include: roles/a/tasks/main.yml vars: x: 10 - include: roles/b/tasks/main.yml - include: roles/b/tasks/main.yml vars: x: 20---- hosts: all gather_facts: no roles: - role: a x: 10 - role: b - role: b x: 20$ ansible-playbook -i hosts tasks.yml
PLAY ***************************************************************************
TASK [include] *****************************************************************included: /home/yaegashi/tmp/test/roles/a/tasks/main.yml for localhost
TASK [set_fact] ****************************************************************ok: [localhost]
TASK [include] *****************************************************************included: /home/yaegashi/tmp/test/roles/b/tasks/main.yml for localhost
TASK [debug] *******************************************************************ok: [localhost] => { "x": "11"}
TASK [include] *****************************************************************included: /home/yaegashi/tmp/test/roles/b/tasks/main.yml for localhost
TASK [debug] *******************************************************************ok: [localhost] => { "x": 20}
PLAY RECAP *********************************************************************localhost : ok=6 changed=0 unreachable=0 failed=0 $ ansible-playbook -i hosts roles.yml
PLAY ***************************************************************************
TASK [a : set_fact] ************************************************************ok: [localhost]
TASK [b : debug] ***************************************************************ok: [localhost] => { "x": "11"}
TASK [b : debug] ***************************************************************ok: [localhost] => { "x": "11"}
PLAY RECAP *********************************************************************localhost : ok=3 changed=0 unreachable=0 failed=0