[webservers]
web1.example.com
web2.example.com
[databases]
db1.example.com
db2.example.com
- name: Ensure Apache is installed
hosts: webservers
tasks:
- name: Install Apache
apt:
name: apache2
state: present
ansible-playbook -i inventory playbook.ym