6. Ansible Commmands

6.1. Ansible Binaries

  • ansible
  • ansible-playbook
  • ansible-doc
  • ansible-galaxy (later)
  • ansible-vault (later)
  • ansible-console
  • ansible-inventory

6.2. Ansible Documentation

Get the documentation of a module.

# show all modules
ansible-doc -l

# show documentation of the easy_install module
ansible-doc easy_install

6.3. Ad-Hoc Commands

  • run some commands or modules on a host
  • used for quick tasks without writing a playbook
# simple command
ansible -a "/bin/echo hello" all

# "ping" all hosts
ansible -m ping all

Hint

all stands for all hosts in the inventory file.

Hint

Ad-Hoc commands can be useful to get informations (e.g is a package installed, is a user available)

6.4. Ansible Playbook

Run a playbook

# run the playbook play.yml
ansible-playbook play.yml