Skip to content

Ansible basics

Config

ansible-config dump

First tests

ansible -i inventory/cloud/hosts.yml all --list-hosts

ansible -i inventory/cloud/hosts.yml all -m ping

Get facts

ansible -i inventory/cloud/hosts.yml all -m setup

ansible -i inventory/cloud/hosts.yml {hostname} -m setup

Run playbooks

Verbose mode

ansible-playbook -i inventory/cloud/hosts.yml playbook/cloud.yml -vvv
For specified host(s)
ansible-playbook -i inventory/cloud/hosts.yml playbook/cloud.yml --limit {host}
With special tags
ansible-playbook -i inventory/cloud/hosts.yml playbook/cloud.yml --tags nginx,cron_job
Skip tags
ansible-playbook -i inventory/cloud/hosts.yml playbook/cloud.yml --skip-tags nginx

Inventories

ansible-doc -t inventory -l