Ansible - Invoking a role more than once using allow_duplicates
by
Jeremy Canfield |
Updated: February 18 2022
| 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