Просмотр исходного кода

fix: *now really* allow this script to be run from any directory

pull/1980/head
mcnesium 3 лет назад
Родитель
Сommit
57f3b46d24
Не найден GPG ключ соответствующий данной подписи Идентификатор GPG ключа: 7D6CC73E428F633F
1 измененных файлов: 4 добавлений и 4 удалений
  1. +4
    -4
      inventory/scripts/ansible-all-hosts.sh

+ 4
- 4
inventory/scripts/ansible-all-hosts.sh Просмотреть файл

@@ -7,8 +7,8 @@
# ./inventory/scripts/ansible-all-hosts.sh self-check # ./inventory/scripts/ansible-all-hosts.sh self-check
# #


# set inventory directory path
inventory=$(dirname "$(readlink -f "$0")")/../../inventory
# set playbook root path
root=$(dirname "$(readlink -f "$0")")/../..


# set default tags or get from first argument if any # set default tags or get from first argument if any
tags="${1:-setup-all,start}" tags="${1:-setup-all,start}"
@@ -17,7 +17,7 @@ tags="${1:-setup-all,start}"
declare -A pws declare -A pws


# capture passwords for all hosts # capture passwords for all hosts
for host in "$inventory"/*.yml; do
for host in "$root"/inventory/*.yml; do
read -rp "sudo password for $(basename "$host"): " -s pw read -rp "sudo password for $(basename "$host"): " -s pw
pws[$host]="$pw" pws[$host]="$pw"
echo echo
@@ -25,7 +25,7 @@ done


# run ansible on all captured passwords/hosts # run ansible on all captured passwords/hosts
for host in "${!pws[@]}"; do for host in "${!pws[@]}"; do
ansible-playbook setup.yml \
ansible-playbook "$root"/setup.yml \
--inventory-file "$host" \ --inventory-file "$host" \
--extra-vars "ansible_become_pass=${pws[$host]}" \ --extra-vars "ansible_become_pass=${pws[$host]}" \
--tags="$tags" --tags="$tags"


Загрузка…
Отмена
Сохранить