I have below playbook in one git repository: mymasterplaybook.yml
name: Do some test
include_role:
name: mytestrole
tasks_from: test-server-names
when: “‘testing-group-name’ in group_names”`
Now I invoke above playbook with a existing role named “mytestrole” and task in it as “test-server-names” and group name is testing-group-name.It works fine.
Now what i want tasks_from , name of role and group name as dynamic : so my mymasterplaybook.yml will look like as below
name: Do some test
include_role:
name: {{dynamic role name}
tasks_from: {{dynamic task name from role}}
when: “{{dynamic group name}’ in group_names”`
so that any role can be plugged into that !
So whenever some one writes roles , they write 2 things
Role
some configuration file which contains “dynamic role name”, “dynamic task name from role”, “dynamic group name” as configurable items so that it can be plugged in master playbook named mymasterplaybook.yml as shown above.
and this configuration file will work as an interface between role and master playbook (named mymasterplaybook.yml) for entire execution.
Hi Ansible Gurus,
I have below playbook in one git repository: mymasterplaybook.yml
- name: Do some test
include_role:
name: mytestrole
tasks_from: test-server-names
when: "'testing-group-name' in group_names"`
Now I invoke above playbook with a existing role named "mytestrole" and task in it as "test-server-names" and group
name is testing-group-name.It works fine.
Now what i want tasks_from , name of role and group name as dynamic : so my mymasterplaybook.yml will look like as below
- name: Do some test
include_role:
name: {{dynamic role name}
tasks_from: {{dynamic task name from role}}
when: "{{dynamic group name}' in group_names"`
so that any role can be plugged into that !
So whenever some one writes roles , they write 2 things
1. Role
2. some configuration file which contains "dynamic role name", "dynamic task name from role", "dynamic group name" as
configurable items so that it can be plugged in master playbook named mymasterplaybook.yml as shown above.
and this configuration file will work as an interface between role and master playbook (named mymasterplaybook.yml) for
entire execution.
Rahul
Yes, and what's your question(s) ?
The when condition wouldn't work that way as the value is virtually wrapped into a Jinja template, so try:
My question how i can take these 3 dynamic values as a configuration file which comes with each role.
Example: I want to invoke mymasterplaybook.yml for 10 roles , so i invoke this playbook
as >ansible-playbook -i inventory.yml mymasterplaybook.yml → This invocation could be completed if mymasterplaybook.yml takes those 3 params which are dynamic from some configuration file a below
In short , I want this configuration file as an interface between mymasterplaybook.yml and individual roles , also mymasterplaybook.yml need to recognize this file to fill its dynamic params .