informatica:linux:docker:ansible
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
informatica:linux:docker:ansible [2017/07/04 14:28] – jose | informatica:linux:docker:ansible [2019/09/09 13:54] (current) – jose | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | < | ||
+ | proyecto | ||
+ | ├── inventories | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | │ | ||
+ | ├── main.yml | ||
+ | └── roles | ||
+ | └── create_user | ||
+ | ├── README.md | ||
+ | ├── defaults | ||
+ | │ | ||
+ | ├── files | ||
+ | ├── handlers | ||
+ | │ | ||
+ | ├── meta | ||
+ | │ | ||
+ | ├── tasks | ||
+ | │ | ||
+ | ├── templates | ||
+ | ├── tests | ||
+ | │ | ||
+ | │ | ||
+ | └── vars | ||
+ | └── main.yml | ||
+ | </ | ||
+ | Cada role lo creamos con: | ||
+ | ansible-galaxy init < | ||
+ | |||
+ | |||
+ | |||
+ | |||
https:// | https:// | ||
Line 37: | Line 78: | ||
| | ||
+ | ====== PLAYBOOKS ====== | ||
+ | Para ejecutar un playbook creamos el fichero yml y ejecutamos con -s si queremos sudo: | ||
+ | ansible-playbook <-s> playbook.yml | ||
+ | |||
+ | |||
+ | nginx.yml | ||
+ | |||
+ | < | ||
+ | --- | ||
+ | - hosts: prueba | ||
+ | tasks: | ||
+ | - name: Install Nginx | ||
+ | apt: pkg=nginx state=installed update_cache=true | ||
+ | |||
+ | </ | ||
+ | |||
+ | Ejemplo: | ||
+ | < | ||
+ | root@5b83b804b705: | ||
+ | |||
+ | PLAY [prueba] ****************************************************************** | ||
+ | |||
+ | TASK [setup] ******************************************************************* | ||
+ | ok: [172.17.0.3] | ||
+ | ok: [172.17.0.4] | ||
+ | |||
+ | TASK [Install Nginx] *********************************************************** | ||
+ | changed: [172.17.0.4] | ||
+ | changed: [172.17.0.3] | ||
+ | |||
+ | PLAY RECAP ********************************************************************* | ||
+ | 172.17.0.3 | ||
+ | 172.17.0.4 | ||
+ | |||
+ | </ | ||
+ | |||
+ | ====== Tarea dependiente ====== | ||
+ | Solo ejecuta la segunda tarea cuando ejecuta la primera. En este caso solo arranca nginx si lo instala: | ||
+ | < | ||
+ | - hosts: prueba | ||
+ | tasks: | ||
+ | - name: Install Nginx | ||
+ | apt: pkg=nginx state=installed update_cache=true | ||
+ | | ||
+ | - Start Nginx | ||
+ | |||
+ | handlers: | ||
+ | - name: Start Nginx | ||
+ | | ||
+ | </ | ||
+ | |||
+ | ====== Login con usuario ====== | ||
+ | Deshabilitamos la consulta del fingerprint | ||
+ | # uncomment this to disable SSH key host checking | ||
+ | host_key_checking = False | ||
+ | |||
+ |
informatica/linux/docker/ansible.1499178488.txt.gz · Last modified: 2017/07/04 14:28 by jose