La fourchette 04/08/15

Simon C.

@kos_si

Ansible

Simon C.

 

Architecte WEB

Travaille chez Theodo

Adepte de LEAN, SCRUM

et du devops

Qui suis je ?

Outil d'automatisation
de tâches

script shell ?

python

SSH

Simplicité

YAML

valeur: clé
liste:
  - un element de la liste
  - un second element
liste2: [1, 2, 3]
dictionnaire:
  dictionaire2: {'element': 2, 'valeurNull': ~}

Extensible

Sans agent

coté serveur

Idempotent

Comment ça marche ?

=

Listes de taches sur des groupes de domaine

Playbook

- name: Banana provisioning
  hosts: all
  sudo: true
  tasks: 
     - name: install cowsay package
       apt: pkg=cowsay state=present
     - name: remove cowsay package
       apt: pkg=cowsay state=absent

Exemple

     - name: install cowsay package
       apt: pkg=cowsay state=present

documentation

module

arguments

Une tâche

375 modules

a10_server a10_service_group a10_virtual_server accelerate acl add_host airbrake_deployment alternatives apache2_module apt apt_key apt_repository apt_rpm assemble assert async_status at authorized_key azure bigip_facts bigip_monitor_http bigip_monitor_tcp bigip_node bigip_pool bigip_pool_member bigpanda boundary_meter bzr campfire capabilities cloudformation command composer copy cpanm cron datadog_event debconf debug digital_ocean digital_ocean_domain digital_ocean_sshkey django_manage dnsimple dnsmadeeasy docker docker_image easy_install ec2 ec2_ami ec2_ami_search ec2_asg ec2_eip ec2_elb ec2_elb_lb ec2_facts ec2_group ec2_key ec2_lc ec2_metric_alarm ec2_scaling_policy ec2_snapshot ec2_tag ec2_vol ec2_vpc ejabberd_user elasticache facter fail fetch file filesystem fireball firewalld flowdock gc_storage gce gce_lb gce_net gce_pd gem get_url getent git github_hooks glance_image group group_by grove hg hipchat homebrew homebrew_cask homebrew_tap hostname htpasswd include_vars ini_file irc jabber jboss jira kernel_blacklist keystone_user layman librato_annotation lineinfile linode lldp locale_gen logentries lvg lvol macports mail modprobe mongodb_user monit mount mqtt mysql_db mysql_replication mysql_user mysql_variables nagios netscaler newrelic_deployment nexmo nova_compute nova_keypair npm ohai open_iscsi openbsd_pkg openvswitch_bridge openvswitch_port opkg osx_say ovirt pacman pagerduty pause ping pingdom pip pkgin pkgng pkgutil portage portinstall postgresql_db postgresql_privs postgresql_user quantum_floating_ip quantum_floating_ip_associate quantum_network quantum_router quantum_router_gateway quantum_router_interface quantum_subnet rabbitmq_parameter rabbitmq_plugin rabbitmq_policy rabbitmq_user rabbitmq_vhost raw rax rax_cbs rax_cbs_attachments rax_cdb rax_cdb_database rax_cdb_user rax_clb rax_clb_nodes rax_dns rax_dns_record rax_facts rax_files rax_files_objects rax_identity rax_keypair rax_meta rax_network rax_queue rax_scaling_group rax_scaling_policy rds rds_param_group rds_subnet_group redhat_subscription redis replace rhn_channel rhn_register riak rollbar_deployment route53 rpm_key s3 script seboolean selinux service set_fact setup shell slack slurp sns stackdriver stat subversion supervisorctl svr4pkg swdepot synchronize sysctl template twilio typetalk ufw unarchive uri urpmi user virt vsphere_guest wait_for win_feature win_get_url win_group win_msi win_ping win_service win_stat win_user xattr yum zabbix_maintenance zfs zypper zypper_repository

hosts/prod :

[webservers]
sharepear.io

playbook.yml :

- hosts: webservers
  vars:
    packages: [cowsay, cowthink, sl, figlet]
  tasks: 
     - name: install packages
       apt: pkg={{ item }} state=present
       with_items: packages
ansible-playbook -i hosts/prod playbook.yml

commande :

Les rôles

  • des tâches
  • des variables
  • des templates
  • ...

Variables par défaut

Tâches

Tâches spécifique

Templates

Informations

Tests

playbook.yml :

- hosts: webservers
  vars_files:
    - vars/apt.yml
  roles:
    - { role: kosssi.apt, tags: apt }

vars/apt.yml :

apt_install:
  - cowsay
  - cowthink
  - sl
  - figlet
ansible-playbook -i hosts/prod playbook.yml

commande :

Utiliser requirements.txt

requirements.txt :

documentation                   exemple

kosssi.ssh,v1.0.0
kosssi.apt,v1.0.0
kosssi.php,v1.0.0
kosssi.composer,v1.0.3
kosssi.apache,v1.0.0
Ansibles.mysql,v1.0.2

ansible-galaxy install -r requirements.txt --force

Utiliser ansible.cfg

documentation        par défaut        exemple

[defaults]

# some basic default values...

hostfile = /etc/ansible/hosts
library_path = /usr/share/my_modules/
roles_path = /etc/ansible/roles

sudo_user = root
remote_user = root
ask_sudo_pass = True
ask_pass = True

log_path = /var/log/ansible.log

Demo

Documentation

documentation                      contribuer

Question ?

Simon C. @kos_si

Merci !!!

Présentation d'Ansible à la fourchette

By kosssi

Présentation d'Ansible à la fourchette

  • 1,360
Loading comments...

More from kosssi