| 44 | Ansible (http://docs.ansible.com) is a free, open-source, intuitive IT automation tool that is well-suited to the tasks in this tutorial. Ansible commands can be run from the command line or put in a YAML file called a ''playbook''. We will be creating an Ansible playbook to run the parameterized HTTP query described earlier. |
| 45 | |
| 46 | Two basic concepts in Ansible are ''inventories'' and ''modules''. An inventory is a list of hosts to be managed by Ansible, organized into groups. When you run Ansible commands, either from the command-line or in a playbook, you specify the host group that the command should operate on. In this way Ansible commands can operate on many hosts in parallel. Take a look at the Ansible inventory in your '''ansible-hosts''' file. This is basically the equivalent of the '''ssh-config''' except its specialized for Ansible. |
| 47 | |
| 48 | A command consists of a module and some arguments for the module. A module provides a declarative abstraction on top of standard shell commands. So for example, in the shell on an Ubuntu machine you might install package “foo” like this: |
| 49 | |
| 50 | {{{ |
| 51 | $ sudo apt-get update |
| 52 | $ sudo apt-get install foo |
| 53 | }}} |
| 54 | |
| 55 | An equivalent Ansible command in a playbook would look like: |
| 56 | |
| 57 | {{{ |
| 58 | apt: name=foo state=latest update_cache=yes |
| 59 | }}} |
| 60 | |
| 61 | The command uses the '''apt''' module, and tells Ansible: “Make sure the latest version of package foo is installed”. There are many other modules which are well-documented at http://docs.ansible.com. |
| 62 | |