Reputation: 178
I wrote my playbook this way:
- name: install kubernetes
hosts: [kuber]
roles:
- A
- B
- C
- B
which means I wanted to run B role
twice, but based on result, the second B
hasn't even run.
What should I do to run a role multiple times?
Upvotes: 2
Views: 2652
Reputation: 6158
Use include_role
:
- name: install kubernetes
hosts: [kuber]
tasks:
- include_role:
name: A
- include_role:
name: B
- include_role:
name: C
- include_role:
name: B
Upvotes: 0
Reputation: 44615
To make roles run more than once, there are two options:
- Pass different parameters in each role definition.
- Add
allow_duplicates: true
to themeta/main.yml
file for the role.
So an easy workaround in your case could be as follow:
- name: install kubernetes
hosts: [kuber]
roles:
- role: A
- role: B
vars:
fake_param: firstinclude
- role: C
- role: B
vars:
fake_param: secondinclude
Upvotes: 3