Ansible Cheatsheet
misc notes, tips and tricks as well as reminders for ansible.
Run a command
ansible kafka -i hosts -m service -a "name=kafka state=started enabled=yes"
kafka
: group name to run this on
-i hosts
: path to inventory file
-m service
: use the service module
-a ...
: module args
print facts for the above group
ansible kafka -i hosts -m setup
Hosts groups
Ansible allows you to filter out or use wildcards in it's hosts:
playbook section
run on all hosts except for nat
group
- hosts: 'all:!nat'
run on all groups with nginx-
in the group name
- hosts: ~nginx-*