Bootstrap FreeKB - Ansible - Invoking a role more than once using allow_duplicates
Ansible - Invoking a role more than once using allow_duplicates

Updated:   |  Ansible articles

By default, a role will only be invoked once. In this example, even though the foo role was declared twice, the foo role will only be invoked once.

---
- hosts: all
  roles:
    - foo
    - foo

 

One option is to use allow_duplicates: true in the roles/foo/meta/main.yml file, like this.

---
allow_duplicates: true

 

The other option is to pass unique variables into the role, like this.

---
- hosts: all
  roles:
    - role: foo
      vars:
        bar: Hello

    - role: foo
      vars:
        bar: World

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter aedde9 in the box below so that we can be sure you are a human.