I have a role with some variables than I using several times with different parameters like below:
roles:
- role: my_role
vars:
role_uuid: uuud_1
first_param: first
- role: my_role
vars:
role_uuid: uuid_2
second_param: second
Problem is that when my role is executed:
- The first role instance, uuid_1, has a parameter second_param which is set to second
- The second role instance, uuid_2, has a parameter first_param that is set to first.
To resume, both instance have the parameters first_param and second_param set.
It seems that the parameters of the instances of the role my_role are merged then only the part that differ is really different (here role_uuid).
Is there are way to avoid this merge ?
This is expected with roles defined in the
roles
section.Use
include_role
orimport_role
module intasks
(orpre_tasks
) to avoid the problem:An option would be to dynamically include vars in my_role
$ cat vars/id_1
$ cat vars/id_2
Then run the play
$ cat play.yml
$ ansible-playbook play.yml | grep msg