Difference between revisions of "Executando múltiplos comandos no Ansible"

From Basef
Jump to: navigation, search
 
(One intermediate revision by the same user not shown)
Line 2: Line 2:
 
<source lang="yaml">
 
<source lang="yaml">
 
- name: "Executando múltiplos comandos com Ansible"
 
- name: "Executando múltiplos comandos com Ansible"
    sudo: yes
+
  sudo: yes
    command: "{{ item }}"
+
  command: "{{ item }}"
    with_items:
+
  with_items:
    - gpg --keyserver keys.gnupg.net --recv-keys 5C927F7C
+
  - gpg --keyserver keys.gnupg.net --recv-keys 5C927F7C
    - gpg -a --export 5C927F7C | apt-key add -
+
  - gpg -a --export 5C927F7C | apt-key add -
 
</source>
 
</source>
  
Line 15: Line 15:
 
gpg -a --export 5C927F7C | apt-key add -
 
gpg -a --export 5C927F7C | apt-key add -
 
</source>
 
</source>
 +
[[Categoria:Ansible]]

Latest revision as of 19:15, 25 April 2015

Para executar múltiplos comandos no Ansible, basta usar o trecho de código a seguir no playbook:

- name: "Executando múltiplos comandos com Ansible"
  sudo: yes
  command: "{{ item }}"
  with_items:
  - gpg --keyserver keys.gnupg.net --recv-keys 5C927F7C
  - gpg -a --export 5C927F7C | apt-key add -

O código acima está executando dois comandos do shell:

gpg --keyserver keys.gnupg.net --recv-keys 5C927F7C
gpg -a --export 5C927F7C | apt-key add -