3
Introduction: What is Ansible ?
● Simple IT automation platform
● Written in Python
● Playbooks written in YAML files
● Uses an agentless, SSH-based model
● Require no server or client daemons
● Modules included
● Easy to manage
● Push mechanism
07/19/16 The Future of Gluster.org - John Mark Walk
er
Inventory
● Inventory files are simple text files which describe your target machines
● Catagorize by IP Addresses, DNS Names & group names
● Configured in /etc/ansible/hosts
Example:
[www]
168.197.1.15
168.197.1.16
168.197.1.17
[db]
192.168.1.[18:25]
07/19/16 The Future of Gluster.org - John Mark Walk
er
Facts
● When Ansible host connects to the target server(s), It queries the server(s) for
all kinds of details about the server(s): CPU architecture, operating system, IP
addresses, memory info, disk info, and more
● Viewing All Facts Associated with a Server,
$ ansible server1 -m setup
07/19/16 The Future of Gluster.org - John Mark Walk
er
Module
● Modules (also referred to as “task plugins” or “library plugins”) are the ones that do the actual work
in ansible, they are what gets executed in each playbook task.
● These modules can control system resources, like services, packages, or handle executing system
commands.
● You can also run a single module using the ‘ansible’ command with ad-hoc method.
● Documentation for each module can be accessed from the command line with the ansible-doc tool:
# ansible-doc -l
# ansible-doc ping
Example:
# ansible webservers -m service -a "name=httpd state=started"
# ansible webservers -m ping
# ansible webservers -m command -a "/sbin/reboot -t now"
07/19/16 The Future of Gluster.org - John Mark Walk
er
Playbooks
● Playbooks can be used to manage configurations of and deployments to remote machines.
● Playbooks are designed to be easy and are developed in a basic text language
● Playbooks are expressed in YAML format
YAML Syntax:
---
# Employee records
- martin:
name: Martin
job: Developer
skills:
- python
- perl
- pascal
07/19/16 The Future of Gluster.org - John Mark Walk
er
Introduction to Ad-hoc commands
● An ad-hoc command is something that you might want to type in to do something
really quick
● Don't want to save for later
● Don't want to write a full playbook
Example:
# ansible webservers -m service -a "name=httpd state=started"
# ansible webservers -m ping
# ansible webservers -m command -a "/sbin/reboot -t now"