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 10:32] – [swarm 3 nodos docker] 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 130: | Línia 131: | ||
| </ | </ | ||
| - | === 3 nodos (diferentes linux) | + | == packer |
| - | para su uso en ansible | + | 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> | <code yaml; Vagrantgile> | ||
| - | $sshinit | + | $mi_script=<< |
| mkdir -m 0700 /root/.ssh | mkdir -m 0700 /root/.ssh | ||
| cp / | cp / | ||
| Línia 139: | Línia 157: | ||
| chmod 600 / | chmod 600 / | ||
| SCRIPT | SCRIPT | ||
| + | |||
| Vagrant.configure(2) do |config| | Vagrant.configure(2) do |config| | ||
| - | config.vm.define "debian1" do |config| | + | config.vm.define "centos7" do |config| |
| - | config.vm.box = "debian/stretch64" | + | config.vm.box = "centos/7" |
| - | config.vm.hostname = "debian1" | + | config.vm.hostname = "centos7" |
| - | config.vm.provision " | + | config.vm.network " |
| + | config.vm.provision " | ||
| + | # config.vm.synced_folder " | ||
| end | end | ||
| - | + | ||
| - | config.vm.define "debian2" do |config| | + | config.vm.define "jessie64" do |config| |
| - | config.vm.box = " | + | config.vm.box = " |
| - | config.vm.hostname = "debian2" | + | config.vm.hostname = "debianjessie64" |
| - | config.vm.provision " | + | config.vm.network " |
| + | config.vm.provision " | ||
| + | # config.vm.synced_folder " | ||
| end | end | ||
| - | config.vm.define "centos1" do |config| | + | config.vm.define "jessie66" do |config| |
| - | config.vm.box = "centos/7" | + | config.vm.box = "debian/jessie64" |
| - | config.vm.hostname = "centos1" | + | config.vm.hostname = "debianjessie66" |
| - | config.vm.provision " | + | config.vm.network " |
| + | config.vm.provision " | ||
| + | # config.vm.synced_folder " | ||
| end | end | ||
| - | config.vm.define "ubuntu1" do |config| | + | config.vm.define "trusty64" do |config| |
| - | config.vm.box = " | + | config.vm.box = " |
| - | config.vm.hostname = "ubuntu1" | + | config.vm.hostname = "ubuntutrusty64" |
| - | config.vm.provision " | + | config.vm.network " |
| + | config.vm.provision " | ||
| + | # config.vm.synced_folder " | ||
| end | end | ||
| end | end | ||
| </ | </ | ||
| - | == packer | + | < |
| - | Para construir imágenes exportables/ | + | [debian] |
| - | * [[https:// | + | 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 |
| - | * [[http:// | + | |
| - | == ansible | + | [centos] |
| - | hay que usar sus módulos para sacarle provecho | + | centos1 ansible_host=127.0.0.1 ansible_ssh_port=2200 ansible_ssh_user=root |
| - | === instalación | + | |
| - | * '' | + | |
| - | * '' | + | |
| - | * [[https:// | + | |
| - | === inventory | + | [ubuntu] |
| - | * relación de máquinas, se pueden agrupar y agrupar los grupos | + | ubuntu1 ansible_host=127.0.0.1 ansible_ssh_port=2202 ansible_ssh_user=root |
| - | * un equipo puede forma parte de más de un grupo | + | |
| - | * [[https:// | + | |
| + | [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 | == otros | ||
| * [[http:// | * [[http:// | ||
| * [[https:// | * [[https:// | ||
| + | * %%~%% | ||
| + | * desde root: '' | ||
| + | * '' | ||