简体   繁体   中英

Make ansible-playbook run the playbook for the given host only once

I have a build server which runs ansible playbooks, after each commit to the given playbook repository. The host data comes from a dynamic inventory. The problem I am encountering right now is that when I push several commits, the build servers runs the ansible-playbook for the same host after another and it creates a race condition on the host server. How can I make the ansible wait for the running playbook to finish and then start or simply not run when there is a playbook running on the host? (I want only one instance of ansible running in the host.)

You can check the ansible pid of the remote server before launching a playbook run. What OS/distro are you using? Hmm.. depending of what you are testing, you can spin up a container(docker or lxd) to test your environment for each commit. Take in account that if you creating/modifying network interfaces or creating device files, it won't suite your needs. I use this method to test my playbook roles in just one server having several unit tests for each role param.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM