ansible-galaxy init roles/myrole
ansible-playbook -C -D -i <inventory> [-u <ssh-user>] [-t tag1,tag2] [--list-hosts] [-l host1,host2] play.yml
-C check_mode
-D show file diffs
ansible -i <inventory> <host/hostgroup> -a <command>
EXAMPLE: ansible -i inventory/beta tag_Role_api_socket -a "date"
ansible -m setup -i <inventory> <host>
e.g
ansible -m setup -i development.ini vm1
Output:
"ansible_selinux": {
"config_mode": "enforcing",
"mode": "enforcing",
"policyvers": 28,
"status": "enabled",
"type": "targeted"
},
"ansible_service_mgr": "systemd",
...
ansible -m ping -i <inventory> <host>
e.g
ansible -m ping -i development.ini vm1
Output:
192.XXX.XXX.XXX | SUCCESS => {
"changed": false,
"ping": "pong"
}
for f in $(grep -rl '$ANSIBLE_VAULT;1.1'); do echo $f:; ansible-vault view $f | grep <pattern>; done
ansible-playbook -i inventory/ec2.py meta.yml --list-hosts -l "tag_Name_a:&tag_Role_b:&tag_Environment_c"
Reference links:
Official:
- [Ansible - Docs] (http://docs.ansible.com/ansible/index.html)
- [Ansible - Module] Index (http://docs.ansible.com/ansible/modules_by_category.html)
- [Ansible - Module] All (http://docs.ansible.com/ansible/list_of_all_modules.html)
Others:
- [ansible-files-layout] (https://leucos.github.io/ansible-files-layout)