Run shell command on group ansible
Run a shell command on all hosts in the webservers group
ansible webservers -m shell -a 'uptime && free -h' -i inventory.ini
more ansible
all 56 commands →
Gather facts for a host
ansible <host> -m setup -i inventory.ini | jq '.ansible_facts | {os: .ansible_distribution, mem: .ansible_memtotal_mb}'
Check mode (dry run)
ansible-playbook site.yml --check --diff -i inventory.ini
Run with extra variables
ansible-playbook deploy.yml -e 'env=prod version=2.1.0' -i inventory.ini
Limit to specific hosts
ansible-playbook site.yml --limit 'web-01,web-02' -i inventory.ini
Run specific tags
ansible-playbook site.yml --tags 'config,restart' -i inventory.ini