Nicolas Steinmetz - Juin 2015
“Ansible is an open-source software platform for configuring and managing computers. It combines multi-node software deployment, ad hoc task execution, and configuration management.”
aptitude install python-setuptools
easy_install pip
pip install ansible
Packagé aussi pour Fedora/RHEL/CentOS
yum install ansible
Tes serveurs tu géreras
[mailservers]
mail.example.com
[webservers]
foo.example.com
www[01:50].example.com
[dbservers]
one.example.com
db-[a:f].example.com
[myapp:children]
webservers
dbservers
Gestion unitaire, groupée et inclusion de groupes
Possibilité de déclarer des variables (ex conf ntp, dns, mail)
ansible <pattern_goes_here> -m <module_name> -a <arguments>
Moyen de définir sur quel(s) serveur(s) votre commande va s'exécuter
webservers:dbservers:&staging:!phoenix
Pour ping-er vos serveurs :
ansible all -m ping
Le minimum syndical
ansible webservers -a "/sbin/reboot"
Un oeuf mimosa pour la table 5 !
---
# This playbook deploys nginx from debian / wheezy-backports
- hosts: webservers
remote_user: nsteinmetz
sudo: yes
tasks:
- name: install nginx from wheezy-backports
apt:
name=nginx
update_cache=yes
state=latest
cache_valid_time=3600
default_release=wheezy-backports
- name: ensure nginx is running
service: name=nginx state=started enabled=yes
Structure "modulaire" des fichiers
site.yml
webservers.yml
fooservers.yml
roles/
webservers/
files/
templates/
tasks/
handlers/
vars/
defaults/
meta/
ansible-playbook -i production webservers.yml --tags default -K
avec webservers.yml :
---
- hosts: webservers
remote_user: nsteinmetz
sudo: yes
roles:
- debian
- webserver
---
- name: Install default packages
apt: name={{ item }} update_cache=yes cache_valid_time=3600 state=present
with_items:
- wget
- ca-certificates
- htop
[...]
tags: default
- name: Install pip for Python2
easy_install: name=pip
tags: default
- name: Install pip for Python3
easy_install: name=pip executable=easy_install-3.4
tags: default
ansible-playbook -i production webserbers.yml --tags default -K
SUDO password:
PLAY [webserbers] **********************************************************
GATHERING FACTS ***************************************************************
ok: [192.168.2.100]
TASK: [debian | Install default packages] *************************************
changed: [192.168.2.100] => (item=wget,ca-certificates,htop,nmap,vim,tree,screen,python-setuptools,python-dev,python3,python3-setuptools,python3-dev,sudo,curl,lynx,bash-completion,dnsutils,lsof,unzip,apt-utils,ssmtp,fail2ban,less,logwatch,ufw,monit)
TASK: [debian | Install pip for Python2] **************************************
changed: [192.168.2.100]
TASK: [debian | Install pip for Python3] **************************************
changed: [192.168.2.100]
PLAY RECAP ********************************************************************
192.168.2.100 : ok=4 changed=3 unreachable=0 failed=0
Support de Windows (en tant que client)
Support de sudo & utilisateurs distincts
Gestion de fichiers de référence et de templates dynamiques
Support de <feature> ? Sûrement via les modules
Support de SSHGate ? Peut-être ...