run a role twice in Ansible

Viewed 1232

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?

2 Answers

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
Related