Ansible Generic Commands
To list hosts in inventory:
ansible-inventory --list -y
To ping all hosts:
ansible all -m ping -u glwhite
To scan a playbook for tasks without making changes:
ansible-playbook myplaybook.yml --list-tasks
To get a list of hosts affected by a playbook:
ansible-playbook myplaybook.yml --list-hosts --ask-vault-pass
To run a playbook:
ansible-playbook playbook.yml --ask-vault-pass
Adding the “--ask-become-pass
" argument, tells Ansible to ask for the user password for the account it uses.
Adding the “--ask-vault-pass
" argument, tells Ansible to ask for the vault password that it can use to decrypt the vars file that contains the become sudo password.
Ad-hoc command t list NFS shares:
ansible testservers -m shell -a 'df -h -T|grep -i nfs' -i ansible_hosts
No Comments