Ansible CLI cheatsheet
This page shows one or more examples of each Ansible command line utility with some common flags added and a link to the full documentation for the command. This page offers a quick reminder of some common use cases only - it may be out of date or incomplete or both. For canonical documentation, follow the links to the CLI pages.
ansible-playbook -i /path/to/my_inventory_file -u my_connection_user -k -f 3 -T 30 -t my_tag -M /path/to/my_modules -b -K my_playbook.yml
my_playbook.ymlfrom the current working directory and:
-u- connects over SSH as
-k- asks for password which is then provided to SSH authentication.
-f- allocates 3 forks.
-T- sets a 30-second timeout.
-t- runs only tasks marked with the tag
-M- loads local modules from
-b- executes with elevated privileges (uses become).
-K- prompts the user for the become password.
See ansible-playbook for detailed documentation.
Install a single collection:
ansible-galaxy collection install mynamespace.mycollection
mynamespace.mycollection from the configured Galaxy server (galaxy.ansible.com by default).
Install a list of collections:
ansible-galaxy collection install -r requirements.yml
Downloads the list of collections specified in the
List all installed collections:
ansible-galaxy collection list
Install a role named example.role:
ansible-galaxy role install example.role
- extracting example.role to /home/user/.ansible/roles/example.role
- example.role was installed successfully
List all installed roles:
ansible-galaxy role list
See ansible-galaxy for detailed documentation.