![Page 1: Automatización de sistemas con Ansible - OpenSouthCode 16](https://reader033.vdocuments.pub/reader033/viewer/2022042908/58f1a6691a28ab180b8b457d/html5/thumbnails/1.jpg)
Automatización de sistemas con
![Page 2: Automatización de sistemas con Ansible - OpenSouthCode 16](https://reader033.vdocuments.pub/reader033/viewer/2022042908/58f1a6691a28ab180b8b457d/html5/thumbnails/2.jpg)
WhoisFrancisco López
Sysadmin
![Page 3: Automatización de sistemas con Ansible - OpenSouthCode 16](https://reader033.vdocuments.pub/reader033/viewer/2022042908/58f1a6691a28ab180b8b457d/html5/thumbnails/3.jpg)
Sysadmin: the hard way
![Page 4: Automatización de sistemas con Ansible - OpenSouthCode 16](https://reader033.vdocuments.pub/reader033/viewer/2022042908/58f1a6691a28ab180b8b457d/html5/thumbnails/4.jpg)
The hard way▪ Máquinas con
configuración similar▪ Servidores “artesanos”
![Page 5: Automatización de sistemas con Ansible - OpenSouthCode 16](https://reader033.vdocuments.pub/reader033/viewer/2022042908/58f1a6691a28ab180b8b457d/html5/thumbnails/5.jpg)
Simple IT Automation
![Page 6: Automatización de sistemas con Ansible - OpenSouthCode 16](https://reader033.vdocuments.pub/reader033/viewer/2022042908/58f1a6691a28ab180b8b457d/html5/thumbnails/6.jpg)
Ansible▪ Aprovisionamiento▪ Gestión de la configuración▪ Orquestación▪ Despliegue de aplicaciones
![Page 7: Automatización de sistemas con Ansible - OpenSouthCode 16](https://reader033.vdocuments.pub/reader033/viewer/2022042908/58f1a6691a28ab180b8b457d/html5/thumbnails/7.jpg)
Caracteristicas▪ Simple pero potente
Configuración en YAML. Plantillas en jinja2.▪ Sin agentes
Usa SSH.▪ Segura
...eehm, bueno, todo lo seguro que sea SSH.
![Page 8: Automatización de sistemas con Ansible - OpenSouthCode 16](https://reader033.vdocuments.pub/reader033/viewer/2022042908/58f1a6691a28ab180b8b457d/html5/thumbnails/8.jpg)
Caracteristicas▪ Muy bien documentada
▪ Respaldada por Red Hat
![Page 9: Automatización de sistemas con Ansible - OpenSouthCode 16](https://reader033.vdocuments.pub/reader033/viewer/2022042908/58f1a6691a28ab180b8b457d/html5/thumbnails/9.jpg)
¡Es software libre!▪ Core licenciado como GPLv3
▪ Modulos libres
▪ Roles libres
![Page 10: Automatización de sistemas con Ansible - OpenSouthCode 16](https://reader033.vdocuments.pub/reader033/viewer/2022042908/58f1a6691a28ab180b8b457d/html5/thumbnails/10.jpg)
Ansible 101Conceptos básicos
![Page 11: Automatización de sistemas con Ansible - OpenSouthCode 16](https://reader033.vdocuments.pub/reader033/viewer/2022042908/58f1a6691a28ab180b8b457d/html5/thumbnails/11.jpg)
Inventory192.168.1.10opensouthcode.org
[webservers]web1.osc.orgweb2.osc.org
[databases:children]databases-mastersdatabases-slaves
[databases-masters]master[1:3].osc.org
[databases-slaves]slaves[1:3].osc.org
Listado de máquinas
![Page 12: Automatización de sistemas con Ansible - OpenSouthCode 16](https://reader033.vdocuments.pub/reader033/viewer/2022042908/58f1a6691a28ab180b8b457d/html5/thumbnails/12.jpg)
- name: Instalar vim apt: pkg=vim state=present update_cache=yes
Task Acción a realizarCompuesta de módulo y parámetros
apt update && apt install vim
![Page 13: Automatización de sistemas con Ansible - OpenSouthCode 16](https://reader033.vdocuments.pub/reader033/viewer/2022042908/58f1a6691a28ab180b8b457d/html5/thumbnails/13.jpg)
Módulos Amazon EC2Amazon ECSAmazon S3CommandMongoDBRedisMySQLPostgresIISWindows
NagiosZabbixRabbitMQAzureDigital OceanDockerGoogle CloudVMWareRackspaceLinux
Apache2DjangoJBOSSJiraGitGithubSubversionF5CiscoHAProxy
![Page 14: Automatización de sistemas con Ansible - OpenSouthCode 16](https://reader033.vdocuments.pub/reader033/viewer/2022042908/58f1a6691a28ab180b8b457d/html5/thumbnails/14.jpg)
PlayInventario + tareas- name: Play simple de ejemplo hosts: webservers tasks: - name: Instalar vim apt: pkg=vim state=present update_cache=yes
- name: Instalar tcpdump apt: pkg=tcpdump state=present
![Page 15: Automatización de sistemas con Ansible - OpenSouthCode 16](https://reader033.vdocuments.pub/reader033/viewer/2022042908/58f1a6691a28ab180b8b457d/html5/thumbnails/15.jpg)
Playbook Sucesión de playsBase de ejecución de Ansible
![Page 16: Automatización de sistemas con Ansible - OpenSouthCode 16](https://reader033.vdocuments.pub/reader033/viewer/2022042908/58f1a6691a28ab180b8b457d/html5/thumbnails/16.jpg)
Config management
![Page 17: Automatización de sistemas con Ansible - OpenSouthCode 16](https://reader033.vdocuments.pub/reader033/viewer/2022042908/58f1a6691a28ab180b8b457d/html5/thumbnails/17.jpg)
Variables
app_path: “/home/app”
monitoring: server-name: nagios server: 11.22.33.44
Se pueden definir “en cualquier sitio”
![Page 18: Automatización de sistemas con Ansible - OpenSouthCode 16](https://reader033.vdocuments.pub/reader033/viewer/2022042908/58f1a6691a28ab180b8b457d/html5/thumbnails/18.jpg)
inventario
host_vars
group_vars
main.yml
web.osc.org.yml
---app_path: “/home/app”servername: “web.osc.org”monitoring: server-name: “nagios” server: 11.22.33.44
![Page 19: Automatización de sistemas con Ansible - OpenSouthCode 16](https://reader033.vdocuments.pub/reader033/viewer/2022042908/58f1a6691a28ab180b8b457d/html5/thumbnails/19.jpg)
Variables
- name: Clonar repositorio git:repo="[email protected]:app.git" clone=yes dest={{ app_path }}
Se referencian usando jinja2
![Page 20: Automatización de sistemas con Ansible - OpenSouthCode 16](https://reader033.vdocuments.pub/reader033/viewer/2022042908/58f1a6691a28ab180b8b457d/html5/thumbnails/20.jpg)
TemplatesAplicar variables a ficheros de configuración
<VirtualHost _default_:{{ http_port }}> ServerName {{ servername }} ...
![Page 21: Automatización de sistemas con Ansible - OpenSouthCode 16](https://reader033.vdocuments.pub/reader033/viewer/2022042908/58f1a6691a28ab180b8b457d/html5/thumbnails/21.jpg)
TemplatesAplicar variables a ficheros de configuración
- name: Subir config apache template: src=00-app.conf.j2 dest=/path/00-app.conf owner=root group=root mode=0644
![Page 22: Automatización de sistemas con Ansible - OpenSouthCode 16](https://reader033.vdocuments.pub/reader033/viewer/2022042908/58f1a6691a28ab180b8b457d/html5/thumbnails/22.jpg)
inventario
host_varsgroup_vars
main.yml
templates00-app.conf.j2
![Page 23: Automatización de sistemas con Ansible - OpenSouthCode 16](https://reader033.vdocuments.pub/reader033/viewer/2022042908/58f1a6691a28ab180b8b457d/html5/thumbnails/23.jpg)
Inclusión y roles
![Page 24: Automatización de sistemas con Ansible - OpenSouthCode 16](https://reader033.vdocuments.pub/reader033/viewer/2022042908/58f1a6691a28ab180b8b457d/html5/thumbnails/24.jpg)
InclusiónEn un playbook se pueden incluir otros ficheros con tasks--- - hosts: webservers tasks:
- include: dependencies.yml - include: deployment.yml - include: apache.yml
![Page 25: Automatización de sistemas con Ansible - OpenSouthCode 16](https://reader033.vdocuments.pub/reader033/viewer/2022042908/58f1a6691a28ab180b8b457d/html5/thumbnails/25.jpg)
RolesEncapsulación de configuraciones--- - hosts: webservers
roles: - base - django - apache2
![Page 26: Automatización de sistemas con Ansible - OpenSouthCode 16](https://reader033.vdocuments.pub/reader033/viewer/2022042908/58f1a6691a28ab180b8b457d/html5/thumbnails/26.jpg)
inventario
host_varsgroup_vars
main.yml
templatesroles
![Page 27: Automatización de sistemas con Ansible - OpenSouthCode 16](https://reader033.vdocuments.pub/reader033/viewer/2022042908/58f1a6691a28ab180b8b457d/html5/thumbnails/27.jpg)
apache2files
meta
roles
handlers
tasks
varstemplates
![Page 28: Automatización de sistemas con Ansible - OpenSouthCode 16](https://reader033.vdocuments.pub/reader033/viewer/2022042908/58f1a6691a28ab180b8b457d/html5/thumbnails/28.jpg)
¿Resultados?
![Page 29: Automatización de sistemas con Ansible - OpenSouthCode 16](https://reader033.vdocuments.pub/reader033/viewer/2022042908/58f1a6691a28ab180b8b457d/html5/thumbnails/29.jpg)
![Page 30: Automatización de sistemas con Ansible - OpenSouthCode 16](https://reader033.vdocuments.pub/reader033/viewer/2022042908/58f1a6691a28ab180b8b457d/html5/thumbnails/30.jpg)
¡Gracias!¿Preguntas?@[email protected]