Ansible: deploy on multiple hosts in the same time

前端 未结 7 1549
暖寄归人
暖寄归人 2020-12-08 06:19

Is it possible to run ansible playbook, which looks like this (it is an example from this site: http://docs.ansible.com/playbooks_roles.html):

- name: this i         


        
7条回答
  •  伪装坚强ぢ
    2020-12-08 06:57

    In my case I needed the configuration stage to be blocking as a whole, but execute each role in parallel. I've tackled this issue using the following code:

    echo webserver loadbalancer database | tr ' ' '\n' \
    | xargs -I % -P 3 bash -c 'ansible-playbook $1.yml' -- %
    

    the -P 3 argument in xargs makes sure that all the commands are ran in parallel, each command executes the respective playbook and the command as a whole blocks until all parts are finished.

提交回复
热议问题