Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run the playbook on multiple hosts with different credentials #1980

Merged
merged 6 commits into from Jul 26, 2022

Conversation

mcnesium
Copy link
Contributor

This is a bash script to run the playbook on multiple hosts with different credentials.

It first iterates over any inventory/<my host>.yml to get all the sudo passwords, and then runs the playbook on each host afterwards. The PR includes an example host file and documentation. The host file comes with yaml syntax, so that the for loop in the bash script can use the asterisk wildcard syntax: inventory/*.yml.

I am aware that running playbooks on multiple hosts can be done using default ansible methods. Though, this playbook ought to be usable as a standalone configuration imho.

Feel free to rephrase, extend, alter or reject anything of this contribution. Just wanted to share the work I did for my own use case.

mcnesium and others added 3 commits July 26, 2022 14:22
Co-authored-by: Slavi Pantaleev <slavi@devture.com>
Co-authored-by: Slavi Pantaleev <slavi@devture.com>
@spantaleev spantaleev merged commit 72309ed into spantaleev:master Jul 26, 2022
@spantaleev
Copy link
Owner

Thanks! 👍

@mcnesium mcnesium deleted the ansible-all-hosts branch July 26, 2022 13:41
@etkecc
Copy link
Contributor

etkecc commented Jul 26, 2022

IIRC, you can encrypt password with ansible-vault and save it to the vars.yml of your host. In such way you can run ansible with all hosts at once

@mcnesium
Copy link
Contributor Author

@etkecc that is true. We talked about this problem it in the chat last week and there were many suggestions on how to deal with multiple home servers. Most of them were presented with a similar uncertainty regarding whether this playbook is actually meant to be used this way. Using a vault being one of them, most suggestions required further knowledge about how Ansible works, which probably exceeds the scope of the documentation of this playbook. The easiest suggestion was to use multiple host files. That in turn required to run the ansible-playbook … command multiple times with lots of time to wait in between, which was annoying and lead me to writing this script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants