Diferències
Ací es mostren les diferències entre la revisió seleccionada i la versió actual de la pàgina.
Ambdós costats versió prèvia Revisió prèvia Següent revisió | Revisió prèvia | ||
info:cursos:pue:devops:sesion5 [01/03/2019 08:38] – [apache+mysql] mate | info:cursos:pue:devops:sesion5 [04/03/2019 06:07] (actual) – [Sesión 5: Vagrant, Ansible] mate | ||
---|---|---|---|
Línia 1: | Línia 1: | ||
- | = Sesión 5 | + | = Sesión 5: vagrant, ansible |
== Vagrant | == Vagrant | ||
* '' | * '' | ||
Línia 7: | Línia 7: | ||
* ubicación imágenes vagrant: **$HOME/ | * ubicación imágenes vagrant: **$HOME/ | ||
* '' | * '' | ||
+ | * '' | ||
== ejemplos | == ejemplos | ||
Línia 79: | Línia 80: | ||
end | end | ||
</ | </ | ||
+ | |||
+ | === swarm 3 nodos docker | ||
+ | hay que buscar una imagen que permita compartir de manera sincronizada una carpeta entre los 3 nodos para compartir la información de unirse al swarm (o NFS) | ||
+ | <code yaml; Vagrantfile> | ||
+ | $docker = << | ||
+ | apt-get -y update | ||
+ | apt-get -y install curl apt-transport-https | ||
+ | curl -s https:// | ||
+ | usermod -aG docker vagrant | ||
+ | SCRIPT | ||
+ | |||
+ | $swarminit = << | ||
+ | docker swarm init --advertise-addr 10.0.7.11 | ||
+ | docker swarm join-token manager | grep swarm | tail -1 > / | ||
+ | SCRIPT | ||
+ | |||
+ | $swarmjoin = << | ||
+ | bash / | ||
+ | SCRIPT | ||
+ | |||
+ | Vagrant.configure(2) do |config| | ||
+ | config.vm.define " | ||
+ | config.vm.box = " | ||
+ | config.vm.hostname = " | ||
+ | config.vm.network " | ||
+ | config.vm.provision " | ||
+ | config.vm.provision " | ||
+ | # config.vm.synced_folder " | ||
+ | end | ||
+ | |||
+ | config.vm.define " | ||
+ | config.vm.box = " | ||
+ | config.vm.hostname = " | ||
+ | config.vm.network " | ||
+ | config.vm.provision " | ||
+ | config.vm.provision " | ||
+ | # config.vm.synced_folder " | ||
+ | end | ||
+ | |||
+ | config.vm.define " | ||
+ | config.vm.box = " | ||
+ | config.vm.hostname = " | ||
+ | config.vm.network " | ||
+ | config.vm.provision " | ||
+ | config.vm.provision " | ||
+ | # config.vm.synced_folder " | ||
+ | end | ||
+ | |||
+ | end | ||
+ | </ | ||
+ | |||
+ | == packer | ||
+ | Para construir imágenes exportables/ | ||
+ | * [[https:// | ||
+ | * '' | ||
+ | * [[http:// | ||
+ | |||
+ | == ansible | ||
+ | hay que usar sus módulos para sacarle provecho | ||
+ | === instalación | ||
+ | * '' | ||
+ | * '' | ||
+ | * [[https:// | ||
+ | |||
+ | === inventory | ||
+ | * relación de máquinas, se pueden agrupar y agrupar los grupos | ||
+ | * un equipo puede forma parte de más de un grupo | ||
+ | * [[https:// | ||
+ | |||
+ | === 4 nodos (diferentes linux para ansible) | ||
+ | <code yaml; Vagrantgile> | ||
+ | $mi_script=<< | ||
+ | mkdir -m 0700 /root/.ssh | ||
+ | cp / | ||
+ | cat / | ||
+ | chmod 600 / | ||
+ | SCRIPT | ||
+ | |||
+ | Vagrant.configure(2) do |config| | ||
+ | config.vm.define " | ||
+ | config.vm.box = " | ||
+ | config.vm.hostname = " | ||
+ | config.vm.network " | ||
+ | config.vm.provision " | ||
+ | # config.vm.synced_folder " | ||
+ | end | ||
+ | |||
+ | config.vm.define " | ||
+ | config.vm.box = " | ||
+ | config.vm.hostname = " | ||
+ | config.vm.network " | ||
+ | config.vm.provision " | ||
+ | # config.vm.synced_folder " | ||
+ | end | ||
+ | |||
+ | config.vm.define " | ||
+ | config.vm.box = " | ||
+ | config.vm.hostname = " | ||
+ | config.vm.network " | ||
+ | config.vm.provision " | ||
+ | # config.vm.synced_folder " | ||
+ | end | ||
+ | |||
+ | config.vm.define " | ||
+ | config.vm.box = " | ||
+ | config.vm.hostname = " | ||
+ | config.vm.network " | ||
+ | config.vm.provision " | ||
+ | # config.vm.synced_folder " | ||
+ | end | ||
+ | |||
+ | end | ||
+ | </ | ||
+ | < | ||
+ | [debian] | ||
+ | debian1 ansible_host=127.0.0.1 ansible_ssh_port=2201 ansible_ssh_user=root | ||
+ | debian2 ansible_host=127.0.0.1 ansible_ssh_port=2203 ansible_ssh_user=root | ||
+ | |||
+ | [centos] | ||
+ | centos1 ansible_host=127.0.0.1 ansible_ssh_port=2200 ansible_ssh_user=root | ||
+ | |||
+ | [ubuntu] | ||
+ | ubuntu1 ansible_host=127.0.0.1 ansible_ssh_port=2202 ansible_ssh_user=root | ||
+ | |||
+ | [laboratorio: | ||
+ | debian | ||
+ | centos | ||
+ | ubuntu | ||
+ | </ | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | * instala correctamente | ||
+ | * '' | ||
+ | |||
+ | código de colores: | ||
+ | * rojo: error | ||
+ | * naranja: cambios | ||
+ | * verde: no se ha tocado nada o correcto | ||
+ | |||
+ | === ansible-playbook | ||
+ | <code yaml; apache.yaml> | ||
+ | - hosts: all | ||
+ | tasks: | ||
+ | - name: Install apache httpd but avoid starting it immediately (state=present is optional) | ||
+ | apt: | ||
+ | name: apache2 | ||
+ | state: present | ||
+ | </ | ||
+ | |||
+ | y ejecutamos con : '' | ||
+ | |||
+ | * '' | ||
+ | * [[https:// | ||
+ | |||
+ | ejecución solo en ciertas máquinas: | ||
+ | <code yaml; system-updates.yaml> | ||
+ | - hosts: all | ||
+ | tasks: | ||
+ | - name: actualizar debians | ||
+ | apt: upgrade=yes update_cache=yes | ||
+ | when: ansible_facts[' | ||
+ | become: true | ||
+ | # | ||
+ | - name: Upgrade Centos-Family | ||
+ | yum: name=' | ||
+ | when: ansible_os_family == ' | ||
+ | </ | ||
+ | [[https:// | ||
+ | == otros | ||
+ | * [[http:// | ||
+ | * [[https:// | ||
+ | * %%~%% | ||
+ | * desde root: '' | ||
+ | * '' |