Ansible in a nutshell and Ansible terms defined

Ansible is a Python script that sshes to your servers (requiring no daemon listening on the servers) and configures them according to "idempotence". Idempotency basically means you describe what state you want, Ansible figures out how to get to that state, versus you specifying what is run and how it is run. Thus you can "run" Ansible plays over and over and it does the "right thing" instead of repeating your commands. Ansible is really useful for repeatedly setting up servers which need to be set up the same way, a better approach than "ad hoc" configuring them over ssh in a shell with no record of your changes. 

Ansible uses a lot of special terminology specific to Ansible. Learn the following Ansible terms and then reading the normal Ansible docs will make sense:

  • inventories - list of your servers
  • playbooks - collection of plays, or simply a collection of roles for a 1-play playbook
  • plays - a collection of roles
  • roles - generally, one service (like postgres or nginx) 
  • tasks - a command that Ansible runs via its modules, like a task for installing a package via apt-get
  • handlers - like tasks that get called when other tasks request them via notifications. Typically used to restart apache.
  • host vars - variables that apply to one collection of hosts
  • modules - provided by Ansible to do things like configure MySQL (mysql module), install via apt-get (apt module), copy over files (file module), add users (user module).

You normally run a playbook, as you can't just run tasks individually. You can execute a module command with arguments directly though.

Ansible will "push" to vs pull (though Ansible can pull too) from servers. Servers don't need anything special installed on them, just ssh access.

Read on for some Ansible tips and tricks I picked up when first learning it.