== Installing ansible == {{{#!highlight sh numbers=off # Official PPA for Ubuntu sudo apt-add-repository -y ppa:ansible/ansible sudo apt-get update sudo apt-get install -y ansible }}} == Playbooks meant to only be run locally == {{{#!highlight yaml - hosts: local connection: local become: yes become_user: root tasks: - name: Install Nginx apt: name: nginx state: installed update_cache: true }}} or specify hosts: all: {{{#!highlight yaml - hosts: all become: yes become_user: root tasks: - name: Install Nginx apt: name: nginx state: installed update_cache: true }}} and then invoke ansible with: {{{#!highlight sh numbers=off ansible-playbook -i 'localhost,' -c local Playbook.ansible.yml }}} == Disable SSH host key checking == Export `ANSIBLE_HOST_KEY_CHECKING` before running ansible: {{{#!highlight sh numbers=off ANSIBLE_HOST_KEY_CHECKING=False ansible -i inventory.yml all -m ping }}} or into ansible.cfg put: {{{ [defaults] host_key_checking = False }}} == Async/parallelizing tasks == See http://toroid.org/ansible-parallel-dispatch and https://docs.ansible.com/ansible/latest/user_guide/playbooks_async.html, and https://blog.crisp.se/2018/01/27/maxwenzin/how-to-run-ansible-tasks-in-parallel, needs more research. == Tips & tricks == {{{#!highlight sh # Start at a specific named task, e.g. the one called "install packages" ansible-playbook playbook.yml --start-at="install packages" }}} == Good articles == * [[https://serversforhackers.com/c/an-ansible2-tutorial|An Ansible2 Tutorial]] * [[https://linuxctl.com/2017/01/ansible---interacting-with-external-rest-api/|Ansible - Interacting with external REST APIs]] == Filters == * [[https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html|Filters in Ansible's documentation]] * [[http://jinja.pocoo.org/docs/latest/templates/#builtin-filters|Jinja2's built-in filters]]