Tasks and hosts
Ansible runs tasks on hosts, and all you need is SSH. In other words, Ansible runs in one place (your laptop, or a deploy box like Rundeck or Tower, or somewhere else), opens up SSH connections to your remote hosts and then runs commands directly on them.
What is a task?
A task can be anything from creating a bucket in AWS S3, to launching an instance in Azure, installing pip on a server, updating a config file, or simply checking the time on a remote host. In this tutorial we focus on tasks to configure a remote Ubuntu host.
For example, this task installs pip on Ubuntu:
- name: ensure pip is installed
apt:
name: python-pip
state: installed
Every task uses a module. Here we use the apt
module, a wrapper for the apt package manager, letting you specify what to do in YAML syntax. There are hundreds of different modules included in Ansible.
What is a host?
The host is where the tasks get run. It can be any number of remote hosts that you have SSH access to, or localhost.
Your hosts respective IP addresses or hostnames need to be stored in an inventory file for Ansible to be aware of them. Later when you run Ansible, you will specify one or more hosts, or groups of hosts, defined in the inventory file.