Muestra las diferencias entre dos versiones de la página.
| Ambos lados, revisión anterior Revisión previa Próxima revisión | Revisión previa | ||
|
wiki2:ansible [2018/12/27 14:53] alfred [Tips and tricks] |
wiki2:ansible [2020/05/09 09:25] (actual) |
||
|---|---|---|---|
| Línea 58: | Línea 58: | ||
| * ''-m <module>'' exec that module. | * ''-m <module>'' exec that module. | ||
| * ''-a '<arguments>' '' arguments for the module | * ''-a '<arguments>' '' arguments for the module | ||
| - | |||
| - | === shell === | ||
| - | <code> | ||
| - | ansible all -b -m shell -a 'apt-get install nginx' | ||
| - | </code> | ||
| === apt === | === apt === | ||
| Línea 86: | Línea 81: | ||
| - htop | - htop | ||
| - tmux | - tmux | ||
| + | </code> | ||
| + | |||
| + | === copy === | ||
| + | |||
| + | <code> | ||
| + | - copy: | ||
| + | src: "{{ item }}" | ||
| + | dest: /etc/fooapp/ | ||
| + | owner: root | ||
| + | mode: 600 | ||
| + | with_fileglob: | ||
| + | - /playbooks/files/fooapp/* | ||
| + | </code> | ||
| + | |||
| + | <code> | ||
| + | - name: Your copy task | ||
| + | copy: src={{ item.src }} dest={{ item.dest }} | ||
| + | with_items: | ||
| + | - { src: 'containerizers', dest: '/etc/mesos/containerizers' } | ||
| + | - { src: 'another_file', dest: '/etc/somewhere' } | ||
| + | - { src: 'dynamic', dest: '{{ var_path }}' } | ||
| + | </code> | ||
| + | |||
| + | <code> | ||
| + | - name: Copy multiple files to multiple directories | ||
| + | copy: src={{ item.0 }} dest={{ item.1 }} | ||
| + | with_together: | ||
| + | - [ 'file1', 'file2', 'file3' ] | ||
| + | - [ '/dir1/', '/dir2/', '/dir3/' ] | ||
| + | </code> | ||
| + | |||
| + | === shell === | ||
| + | <code> | ||
| + | ansible all -b -m shell -a 'apt-get install nginx' | ||
| </code> | </code> | ||
| ==== Playbooks ==== | ==== Playbooks ==== | ||
| Línea 394: | Línea 423: | ||
| </code> | </code> | ||
| ===== Playbooks examples ===== | ===== Playbooks examples ===== | ||
| + | |||
| + | * https://github.com/ansible/ansible-examples | ||
| <code> | <code> | ||
| Línea 502: | Línea 533: | ||
| name: postgresql | name: postgresql | ||
| state: started | state: started | ||
| + | </code> | ||
| + | |||
| + | A right one: | ||
| + | <code> | ||
| + | --- | ||
| + | - hosts: puma | ||
| + | gather_facts: no | ||
| + | become: yes | ||
| + | name: Deploy PUMA | ||
| + | tasks: | ||
| + | - name: Send Docker images | ||
| + | debug: msg="hola" | ||
| + | |||
| + | - name: Load Docker images | ||
| + | debug: msg="{{ lookup('env','HOME') }} is an environment variable" | ||
| + | |||
| + | - name: Start PUMA | ||
| + | debug: msg="{{ lookup('env','HOME') }} is an environment variable" | ||
| + | | ||
| + | # copy: | ||
| + | # src: "{{ item }}" | ||
| + | # dest: ~ | ||
| + | # owner: root | ||
| + | # mode: 600 | ||
| + | # with_fileglob: | ||
| + | # - ../dist/* | ||
| </code> | </code> | ||