Matrix Docker Ansible eploy
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

33 строки
881 B

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