Ansible Cheatsheet
by sij /
Display ansible settings
It can be verified which ansible.cfg file is used.
ansible --version
ansible 2.10.5
config file = /home/ansible/devops/ansible/stpf/setup/ansible.cfg
configured module search path = ['/home/ansible/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/ansible/.local/lib/python3.8/site-packages/ansible
executable location = /home/ansible/.local/bin/ansible
python version = 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0]
Display matching hosts
Nothing will be executed.
ansible all --list-hosts
hosts (1):
devops.codesie.local
Select a host group
ansible -l newStpfServer all --list-hosts
hosts (1):
devops.codesie.local
Check playbook syntax
ansible-playbook --syntax-check execute-setup.yaml
playbook: execute-setup.yaml
Show all facts
Ansible gathers facts of the target nodes. We can have a look at them by using the setup
module.
ansible all -m setup