This script works with Ansible 2.2.
Vars for dependent roles are specified in the core role vars files:
./ roles / role1/ tasks / main.yml:
- debug: msg="{{ role_param }}"
./roles/role2/meta/main.yml:
allow_duplicates: yes dependencies: - role: role1 role_param: "{{ param1 }}" - role: role1 role_param: "{{ param2 }}"
./ roles / role 2/ tasks / main.yml:
- debug: msg=role2
./roles/role2/vary/main.yml:
param1: hello1 param2: hello2
Result:
PLAY [localhost] *************************************************************** TASK [role1 : debug] *********************************************************** ok: [localhost] => { "msg": "hello1" } TASK [role1 : debug] *********************************************************** ok: [localhost] => { "msg": "hello2" } TASK [role2 : debug] *********************************************************** ok: [localhost] => { "msg": "role2" }
source share