É possível executar funções que são definidas no site.yml de forma assíncrona no Ansible sem abrir mil terminais?

2

No momento, várias funções foram definidas no site.yml:

- include: role1.yml
- include: role2.yml
- include: role3.yml
- include: role4.yml
- include: role5.yml

e estes são executados de forma síncrona, emitindo:

ansible-playbook -i testing site.yml -u root --vault-password-file ~/.vault_pass.txt

Pergunta

Como executar as funções definidas no site.yml de uma só vez?

Discussão

Funciona para executar todas as funções de forma assíncrona, abrindo vários terminais e executando:

ansible-playbook -i testing playbook1.yml -u root --vault-password-file ~/.vault_pass.txt
ansible-playbook -i testing playbook2.yml -u root --vault-password-file ~/.vault_pass.txt
ansible-playbook -i testing playbook3.yml -u root --vault-password-file ~/.vault_pass.txt
ansible-playbook -i testing playbook4.yml -u root --vault-password-file ~/.vault_pass.txt
ansible-playbook -i testing playbook5.yml -u root --vault-password-file ~/.vault_pass.txt
    
por 030 21.09.2016 / 09:04

1 resposta

1

Dê uma olhada nas estratégias de livros didáticos :

In 2.0 we added a new way to control play execution, strategy, by default plays will still run as they used to, with what we call the linear strategy. All hosts will run each task before any host starts the next task, using the number of forks (default 5) to parallelize.

Vale a pena tentar definir a estratégia para free :

A second strategy ships with ansible free, which allows each host to run until the end of the play as fast as it can.

- hosts: all
  strategy: free

Verifique também a configuração forks em ansible.cfg :

This is the default number of parallel processes to spawn when communicating with remote hosts. Since Ansible 1.3, the fork number is automatically limited to the number of possible hosts, so this is really a limit of how much network and CPU load you think you can handle. Many users may set this to 50, some set it to 500 or more. If you have a large number of hosts, higher values will make actions across all of those hosts complete faster. The default is very very conservative:

forks=5
    
por 22.09.2016 / 15:05

Tags