Présentation Ansible Ikoula

21
Usages autour d’Ansible sur le Cloud public ou privé

Transcript of Présentation Ansible Ikoula

Page 1: Présentation Ansible Ikoula

Usages autour d’Ansible sur

le Cloud public ou privé

Page 2: Présentation Ansible Ikoula

Ikoula

Création : 1998

8 000 VM en production

Effectif : 47 employés

5 000 serveursphysiques

8 datacenters dans le monde

Page 3: Présentation Ansible Ikoula

Un peu d’histoire

Page 4: Présentation Ansible Ikoula

Le Cloud by Ikoula – privé, public,

hybride

Page 5: Présentation Ansible Ikoula

Orchestration CloudStack Pilote le stockage

Pilote les composants réseaux et sécurité

Pilote la virtualisation

Pilote la bibliothèque d’images et ISO.

Interfaces Web: Interface de gestion via

navigateur internet

Ligne de commande: Gérer votre PaaS via un shell

API: Intégrer les webservices de l’API cloudstack à votre système

Le Cloud by Ikoula– interopérabilité

et API

Page 6: Présentation Ansible Ikoula

Pourquoi Ansible ?

Outil de configuration rapide

Simple à prendre en main

Modulaire

Sans agent

Pas besoin d’un orchestrateur central

Interopérable avec Windows

Page 7: Présentation Ansible Ikoula

Pour quels besoins ?

Faciliter la configuration de nouveaux serveurs

Aider à la maintenance : patch, modification de configuration, mises à jours, gestion de droits, etc.

Gestion par groupe de serveurs

Page 8: Présentation Ansible Ikoula

Inventaire

Déclarer ses hôtes[z1frxenmutu]

fr-z1-mutu01-xen[01:02] ansible_connection=ssh ansible_ssh_port=22

fr-z1-mutu02-xen01 ansible_connection=ssh ansible_ssh_port=22

fr-z1-mutu03-xen[01:03] ansible_connection=ssh ansible_ssh_port=22

Lister les hôtes d’un groupe

user@ansadmin~$ ansible z1frxenmutu --list-hostsfr-z1-mutu01-xen01fr-z1-mutu01-xen02fr-z1-mutu02-xen01fr-z1-mutu03-xen01fr-z1-mutu03-xen02fr-z1-mutu03-xen03

Page 9: Présentation Ansible Ikoula

Ansible pour la mise en production

Exemple :

installer 4 serveurs PostgreSQL

Page 10: Présentation Ansible Ikoula

Ajout d’un repo dans Debian

user@ansadmin:~/postgres_cascading$ ansible -i hosts alls -u root -m apt_repository -a "repo='deb http://apt.postgresql.org/pub/repos/apt/ jessie-pgdg main' state=present“

PgHotStandbyUpstream | success >> {"changed": true,"repo": "deb http://apt.postgresql.org/pub/repos/apt/ jessie-pgdg main","state": "present"

}PgMaster | success >> {

"changed": true,"repo": "deb http://apt.postgresql.org/pub/repos/apt/ jessie-pgdg main","state": "present"

}PgStandbyDownstream | success >> {

"changed": true,"repo": "deb http://apt.postgresql.org/pub/repos/apt/ jessie-pgdg main","state": "present"

}PgWitness | success >> {

"changed": true,"repo": "deb http://apt.postgresql.org/pub/repos/apt/ jessie-pgdg main","state": "present"

}

Page 11: Présentation Ansible Ikoula

Ajouter la clé du repo

user@ansadmin:~/postgres_cascading$ ansible -i hosts alls -u root -m apt_key -a "url=https://www.postgresql.org/media/keys/ACCC4CF8.asc state=present“

PgMaster | success >> {"changed": true

}PgStandbyDownstream | success >> {

"changed": true}PgWitness | success >> {

"changed": true}PgHotStandbyUpstream | success >> {

"changed": true}

Page 12: Présentation Ansible Ikoula

Installer PostgreSQL

user@ansadmin:~/postgres_cascading$ ansible -i hosts alls -u root -m apt -a "name=postgresql state=latest"

PgHotStandbyUpstream | success >> {"changed": true,"stderr": "","stdout": "Reading package lists...\nBuilding dependency tree...\nReading

state information...\nThe following extra packages will be installed:\n libpq5 libxslt1.1 pgdg-keyring postgresql-9.4 postgresql-client-9.4\n postgresql-client-common postgresql-common postgresql-contrib-9.4 ssl-cert\nSuggestedpackages:\n postgresql-doc oidentd ident-server locales-all postgresql-doc-9.4\n libdbd-pg-perl openssl-blacklist\nThe following NEW packages will beinstalled:\n (…)Setting up postgresql (9.4+169.pgdg80+1) ...\r\nSetting up postgresql-contrib-9.4 (9.4.4-1.pgdg80+1) ...\r\nProcessing triggers for libc-bin (2.19-18+deb8u1) ...\r\nProcessing triggers for systemd (215-17+deb8u2) ...\r\n"}

PgMaster | success >> {"changed": true,

(…)

Page 13: Présentation Ansible Ikoula

Vérifier l’état du service

user@ansadmin:~/postgres_cascading$ ansible -i hosts alls -u root -m shell -a "systemctl status postgresql“

PgMaster | success | rc=0 >>* postgresql.service - PostgreSQL RDBMS

Loaded: loaded (/lib/systemd/system/postgresql.service; enabled)Active: active (exited) since Wed 2015-09-30 15:35:22 CEST; 2min 16s ago

Main PID: 47224 (code=exited, status=0/SUCCESS)CGroup: /system.slice/postgresql.service

PgHotStandbyUpstream | success | rc=0 >>* postgresql.service - PostgreSQL RDBMS

Loaded: loaded (/lib/systemd/system/postgresql.service; enabled)Active: active (exited) since Wed 2015-09-30 15:35:13 CEST; 2min 26s ago

Main PID: 47134 (code=exited, status=0/SUCCESS)CGroup: /system.slice/postgresql.service

(…)

Page 14: Présentation Ansible Ikoula

Ansible pour la maintenance

Cas 1 : modification d’une configuration en place

Cas 2 : déploiement d’un script de supervision

Cas 3 : application de patches

Page 15: Présentation Ansible Ikoula

Modification IP du serveur syslog

{{ hostuuid }} > variable définie dans le fichier d’inventaire

user@ansadmin:~$ ansible xenall -u root -m shell -a "xe host-param-set uuid={{ hostuuid }} logging:syslog_destination=192.168.1.250"

user@ansadmin:~$ ansible xenall -u root -m shell -a "xe host-syslog-reconfigurehost-uuid={{ hostuuid }}"

Page 16: Présentation Ansible Ikoula

Copie d’un script de supervision

mode > droits à appliquer au fichier ; owner / group > les propriétaires

user@ansadmin:~$ ansible xenall -u root -m copy -a "src=/home/administrator/cloudstack/files/monitoring_wrapper.sh dest=/home/zabbix/scripts/monitoring_wrapper.sh mode=500 owner=zabbixgroup=zabbix"

fr-z1-mutu03-xen01 | success >> {"changed": true,"checksum": "f58c96289522ab9418d420dc356ee412d1ae261e","dest": "/home/zabbix/scripts/monitoring_wrapper.sh","gid": 500,"group": "zabbix","md5sum": "1c02718baa2c4d5193a430789d51e033","mode": "0500","owner": "zabbix","size": 4951,"src": "/tmp/ansible/ansible-tmp-1440771441.05-37417552365678/source","state": "file","uid": 500

}

Page 17: Présentation Ansible Ikoula

Gestion de patchs

{{ hostuuid }} & {{ pwd }} > variables définies dans l’inventaire

user@ansadmin:~$ ansible xenall65sp1 -u root -m shell -a "hostname && xe -u root -pw {{ pwd }} patch-list hosts:contains={{ hostuuid }} params=name-label | sort" | awk '{print $NF}' | grep -v "^$”

>>fr-z3-mutu01-xen01XS65E001(…)XS65ESP1005>>nl-z2-basic-mutu01-xen01XS65E001(…)XS65ESP1005>>de-z1-adv-mutu01-xen02XS65E001(…)XS65ESP1005>>

Page 18: Présentation Ansible Ikoula

Appliquer un patch

Pour uploader et appliquer le patch « XS65ESP1008.xsupdate » sur tous les Xenserver en version 6.5 SP1

user@ansadmin:~$ ansible xenall65sp1 -u root -m copy -a "src=/home/administrator/cloudstack/patchs/XS65ESP1008.xsupdate dest=/root/XS65ESP1008.xsupdate"

user@ansadmin:~$ ansible xenall65sp1 -u root -m shell -a "xe patch-upload -s {{ my_host_alias }} -u root -pw {{ pwd }} file-name=/root/XS65ESP1008.xsupdate"

user@ansadmin:~$ ansible xenall65sp1 -u root -m shell -a "xe -s {{ my_host_alias}} -u root -pw {{ pwd }} patch-pool-apply uuid=d91b3557-f1bf-4083-bd6f-80a19d983775"

user@ansadmin:~$ ansible xenall65sp1 -u root -m shell -a "rm -f /root/XS65ESP1008.xsupdate"

Page 19: Présentation Ansible Ikoula

Ansible, outil d’admin indispensable

Avantages :

Simple d’utilisation

Riche en modules Core et Extra

Pas d’agent nécessaire

Gestion de rôles (les “playbooks”)

A venir :

le module« cloudstack » récemment arrivé dans les modules Core de Ansible 2.0

Page 20: Présentation Ansible Ikoula

Ressources

Documentation Ansiblehttp://docs.ansible.com/ansible/index.html

Ressources Ikoula https://github.com/ikoula

Scripts Ansible

https://www.ikoula-blog.com/ Tutoriaux, cas pratiques, etc.

https://fr.ikoula.wiki/ Base de connaissances