Code Snippet

Just another Code Snippet site

[Ansible] CLI : limit to specific list of hosts

With host definition as :

SERVER-APP-1 ansible_ssh_host=192.168.0.1 ansible_ssh_user=root ansible_ssh_pass=password
SERVER-DB-1 ansible_ssh_host=192.168.0.2 ansible_ssh_user=root ansible_ssh_pass=password
SERVER-APP-2 ansible_ssh_host=192.168.0.3 ansible_ssh_user=root ansible_ssh_pass=password
SERVER-DB-2 ansible_ssh_host=192.168.0.4 ansible_ssh_user=root ansible_ssh_pass=password

[app-servers]
SERVER-APP-1
SERVER-APP-2

[db-servers]
SERVER-DB-1
SERVER-DB-2

[app1-servers]
SERVER-DB-1
SERVER-APP-1

[app2-servers]
SERVER-DB-2
SERVER-APP-2

#Group of Groups
[all-servers:children]
db-servers
app-servers

ansible-playbook main.yml -v -i hosts --limit db-servers

ansible-playbook main.yml -v -i hosts --limit app1-servers

ansible-playbook main.yml -v -i hosts --limit all-servers

...


One thought on “[Ansible] CLI : limit to specific list of hosts

Leave a Reply to Olivier Cancel reply

Your email address will not be published. Required fields are marked *