Hello,
In the Ansible Roles documentation it’s written;
“While it’s probably not something you should do often, you can also conditionally apply roles like so:”
---
- hosts: webservers
roles:
- { role: some_role, when: "ansible_os_family == 'RedHat'" }
It seems conditional roles is the only way to have a unique playbook executing differentes installations concidering targeted servers types.
for instance, for kubernetes install:
- hosts:all
roles : - { role: install_master, when: "server_type == “master” }
- { role: install_worker, when: "server_type == “worker” }
Then, executing this playbook, i install both the masters and the workers, instead to have one playbook for each with one hosts group for each.
So conditionnal roles seems pretty important and going to be used very often.
What i have missed? Is there another way to to this?