ansible all -i inventory -u root -m ping -vvv
# inventory, user root, module ping, very verbose
# copies file to server, exec file (with python), report result
ansible all -m apt -a "pkg=dead-parrot state=present"
# idempotent, run multiple times
# success reported along with {"changed": false} (or true)
All Ansible modules are idempotent, so they don’t make changes on a second application when not necessary
- hosts: all
user: root
tasks:
- name: install nginx
apt: pkg=nginx state=latest
- name: The home page is configured
copy: src=... dest=/var/share/nginx/www/index.html
A set of Ansible instructions is called a “playbook”, where this contains a hostname, username and tasks in YAML format