ansible.md 963 B


title: Ansible breadcrumbs:

  • title: Configuration
  • title: Automation --- {% include header.md %}

Usage

Ad Hoc

  • Run module for host: ansible all -i <host>, -m <module> [-a <module-arg>]
    • The comma after the host is required to treat it as a host list literal instead of an inventory file name.
  • Get facts (with optional filter): ansible all -i <host>, -m setup -a 'filter=ansible_os_*' (example fact filter)

Playbooks

  • Basic: ansible-playbook <playbook>
  • Specify inventory file: ansible-playbook -i <hosts> <playbook>
  • Limit which groups/hosts to use (comma-separated): ansible-playbook -l <group|host> <playbook>
  • Limit which tasks to run using tags (comma-separated): ansible-playbook -t <tag> <playbook>

Configuration

Example /etc/ansible/ansible.cfg:

[defaults]
# Change to "auto" if this path causes problems
interpreter_python = /usr/bin/python3
host_key_checking = false

{% include footer.md %}