normally in ansible you always define a specific host for a specific playbook. But what is if I want to run a playbook for multiple hosts?
For a bit more clarity: I have following groups:
- Webservers
- Dev Clients
and following playbooks:
- install main software
- install certbot
- install nginx
- install vscode
For obvious reasons for sure the nginx playbook should have the entry: hosts: Webservers
but what is with the main software
playbook. This playbook should include both hosts.
In the end I want to have many different playbooks and groups and the only thing I wanna execute is: ansible-playbook ~/playbooks/webservers.yml
and this triggers: "main software, certbot, nginx..." via includes. But this doesn't work without editing the hosts section of every playbook that is included in the webservers.yml
.
Is it possible to tell a playbook that it should run on the hosts from the main-playbook which has included it? like: webservers.yml -> hosts -> nginx.yml -> run on all clients which are entered in webservers.yml?
Does somebody of you has an idea? Or is this just not realizable with ansible?
Regards