Nuestro primer comando :)
¥ ansible: Comando!
¥ all: Parte del inventario a usar.!
¥ -m command: Módulo
¥ -a "ls /tmp": Atributos del módulo
$ ansible all -m command -a "ls /tmp”!
Slide 21
Slide 21 text
Más comandos
$ ansible all -m copy -a "src=/tmp/foo dest=/tmp/foo"!
$ ansible webservers -m yum -a "name=php5 state=present"!
$ ansible all -m command -a ”pwd” –f 10 !
$ ansible all -m command -a ”rm –rf /” –i custom_inventory!
Slide 22
Slide 22 text
PLAYBOOKS
Slide 23
Slide 23 text
Introducción a Playbooks
¥ Automatización de tareas complejas.
¥ Ficheros en formato YAML.
¥ Definición de:
¥ Tareas
¥ Pasos
¥ Variables
“Los módulos son las herramientas
y los playbooks los planos”
Slide 24
Slide 24 text
YAML Ain’t Another Markup
Language
---!
- hosts: webservers!
..vars:!
....http_port: 80!
....max_clients: 200!
....remote_user: root!
..tasks:!
....- name: ensure apache is at the latest version!
......yum: pkg=httpd state=latest!
....- name: write the apache config file!
......template: src=/srv/httpd.j2 dest=/etc/httpd.conf!
....- name: ensure apache is running!
......service: name=httpd state=started!
Slide 25
Slide 25 text
---!
- hosts: webservers!
vars:!
http_port: 80!
max_clients: 200!
remote_user: root!
tasks:!
- name: ensure apache is at the latest version!
yum: pkg=httpd state=latest!
- name: write the apache config file!
template: src=/srv/httpd.j2 dest=/etc/httpd.conf!
- name: ensure apache is running!
service: name=httpd state=started!
!
!
$ ansible-playbook my-playbook.yml!
!
!
Slide 26
Slide 26 text
No content
Slide 27
Slide 27 text
Módulos
¥ +200 incluidos por defecto
¥ Aceptan parámetros clave-valor:
¥ key1=value1, key2=value2, key3=value3!
¥ Ídempotentes
¥ No se ejecutan si no hace falta.
¥ Documentación:
$ ansible-doc !
http://docs.ansible.com/modules.html !
o
¿Qué son los roles?
¥ Organización de playbooks.
¥ “Convention over configuration”
¥ Carga automática de:
¥ Tasks
¥ Vars
¥ Handlers
¥ Dependencias
¥ Reutilizables