The goal is to run this play against all hosts but each role should only run as follows:
- lab01-4 for webservers
- lab01-5 for databases
- lab01-6 for others
We have several hosts in different groups:
[webservers]
rhel-01
[databases]
rhel-02
[others]
rhel-03
We have several roles in one play with tags:
- hosts: all
become: yes
roles:
- { role: 'lab01-4', tags: 'webservers', hosts: 'webservers' }
- { role: 'lab01-5', tags: 'databases', hosts: 'databases' }
- { role: 'lab01-6', tags: 'others', hosts: 'others' }
I see that there is no keyword hosts in role (https://docs.ansible.com/ansible/latest/reference_appendices/playbooks_keywords.html#role). Ansible ignores keyword hosts and starts play without errors for all hosts.
Any suggestions?