Matrix Docker Ansible eploy
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 

39 satır
1.0 KiB

  1. #!/usr/bin/env bash
  2. # SPDX-FileCopyrightText: 2022 - 2024 MDAD project contributors
  3. # SPDX-FileCopyrightText: 2024 Slavi Pantaleev
  4. #
  5. # SPDX-License-Identifier: AGPL-3.0-or-later
  6. #
  7. # Run the playbook on multiple hosts with different credentials with this script
  8. # It defaults to ansible tags "setup-all,start". You can pass alternative tags
  9. # to this script as arguments, e.g.
  10. #
  11. # ./bin/ansible-all-hosts.sh self-check
  12. #
  13. # set playbook root path
  14. root=$(dirname "$(readlink -f "$0")")/..
  15. # set default tags or get from first argument if any
  16. tags="${1:-setup-all,start}"
  17. # init password array
  18. declare -A pws
  19. # capture passwords for all hosts
  20. for host in "$root"/inventory/*.yml; do
  21. read -rp "sudo password for $(basename "$host"): " -s pw
  22. pws[$host]="$pw"
  23. echo
  24. done
  25. # run ansible on all captured passwords/hosts
  26. for host in "${!pws[@]}"; do
  27. ansible-playbook "$root"/setup.yml \
  28. --inventory-file "$host" \
  29. --extra-vars "ansible_become_pass=${pws[$host]}" \
  30. --tags="$tags"
  31. done