See:
Python based tool for updating/managing systems over SSH connections.
It leaves no scripts on the target machine so no need to managed installer versions.
The control machine must be Linux based with python 2.6
Target machines must have python 2.4 and, if accessing using SSH, an SSH service running.
Windows targets can also be catered for using a remote Power Shell session.
Key Concepts
YAML: A data markup language, like json.
INI: A simple syntax for configuration files
Inventory: INI file that defines groups of machines within an environment. Default loaded from /etc/ansible/hosts (override with -i on the command line.
Module: 'Re-usable units of magic' that encapsulates a distinct action. Normally invoked from a Playbook
Playbook: A YAML file that tells Ansible what to execute. Playbooks can include other playbooks.
Role: A YAML file that is essentially a self contained, re-usable playbook that encapsulates a piece of functionality e.g. a WebServer or Database. Each role is defined in a set of directories (see Directory Layout) below.
Directory layout (from best practices)
# Inventory INI files definitions of groups of hosts production # inventory file for production servers stage # inventory file for stage environment group_vars/ # Define variables related to a specific group group1 # here we assign variables to particular groups group2 # "" host_vars/ # Define variables related to a specific host hostname1 # if systems need specific variables, put them here hostname2 # "" library/ # if any custom modules, put them here (optional) filter_plugins/ # if any custom filter plugins, put them here (optional) # Playbook YAML files declare what Ansible should do site.yml # master playbook webservers.yml # playbook for webserver tier dbservers.yml # playbook for dbserver tier roles/ common/ # this hierarchy represents a "role" tasks/ # main.yml # <-- tasks file can include smaller files if warranted handlers/ # main.yml # <-- handlers file templates/ # <-- files for use with the template resource ntp.conf.j2 # <------- templates end in .j2 files/ # bar.txt # <-- files for use with the copy resource foo.sh # <-- script files for use with the script resource vars/ # main.yml # <-- variables associated with this role defaults/ # main.yml # <-- default lower priority variables for this role meta/ # main.yml # <-- role dependencies webtier/ # same kind of structure as "common" was above, done for the webtier role monitoring/ # "" fooapp/ # ""
# Note: A clean Centos install needs the eth0 network adapter enabled (or enable it during install).
# Edit /etc/sysconfig/network-scripts/ifcfg-$IFNAME. Change the ONBOOT line's value to yes
# Add yum repositories for epel (Extra Packages for Enterprise Linux) to allow python-pip to be installed
$ cd /tmp
$ wget http://mirror-fpt-telecom.fpt.net/fedora/epel/6/i386/epel-release-6-8.noarch.rpm
$ rpm -ivh epel-release-6-8.noarch.rpm
# pip is a python specific package install tool, as yum and apt are for Linux
$ yum install python-pip
# Install development tools to compile paramiko
$ yum groupinstall 'Development Tools'
$ yum install python-devel
$ pip install paramiko PyYAML jinja2 httplib2
# Install support tools for ansible install
$ yum install git
$ git clone git://github.com/ansible/ansible.git
$ cd ./ansible
$ source ./hacking/env-setup