Always reboot if reboot is run
This commit is contained in:
parent
f0cd39728a
commit
ce7e6ffc5e
23
provision.sh
23
provision.sh
|
@ -4,16 +4,16 @@ set -e
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
printf '%s\n' "Usage:"
|
printf '%s\n' "Usage:"
|
||||||
printf '$ %s\n' "$0 [-h|--help]"
|
printf '$ %s\n' "$0 [--help]"
|
||||||
printf '$ %s\n' "$0 [--dry] os"
|
printf '$ %s\n' "$0 [--dry] os"
|
||||||
printf '$ %s\n' "$0 [--dry] base"
|
printf '$ %s\n' "$0 [--dry] base"
|
||||||
printf '$ %s\n' "$0 [--dry] firewall"
|
printf '$ %s\n' "$0 [--dry] firewall"
|
||||||
printf '$ %s\n' "$0 [--dry] ssh"
|
printf '$ %s\n' "$0 [--dry] ssh"
|
||||||
printf '$ %s\n' "$0 [--dry] docker"
|
printf '$ %s\n' "$0 [--dry] docker"
|
||||||
printf '$ %s\n' "$0 [--dry] docker_config"
|
printf '$ %s\n' "$0 [--dry] docker_config"
|
||||||
printf '$ %s\n' "$0 [--dry] users [-i|--init]"
|
printf '$ %s\n' "$0 [--dry] users [--init]"
|
||||||
printf '$ %s\n' "$0 [--dry] reboot [-f|--force]"
|
printf '$ %s\n' "$0 [--dry] reboot"
|
||||||
printf '$ %s\n' "$0 [--dry] services [-d|--down] [SINGLE_SERVICE]"
|
printf '$ %s\n' "$0 [--dry] services [--down] [SINGLE_SERVICE]"
|
||||||
}
|
}
|
||||||
|
|
||||||
install_modules() {
|
install_modules() {
|
||||||
|
@ -45,25 +45,18 @@ case $TAG in
|
||||||
users)
|
users)
|
||||||
install_modules
|
install_modules
|
||||||
|
|
||||||
if [ "$1" = "-i" ] || [ "$1" = "--init" ]; then
|
if [ "$1" = "--init" ]; then
|
||||||
$EXEC "$BASE_CMD --user root --tags '$TAG'"
|
$EXEC "$BASE_CMD --user root --tags '$TAG'"
|
||||||
else
|
else
|
||||||
$EXEC "$BASE_CMD --tags '$TAG'"
|
$EXEC "$BASE_CMD --tags '$TAG'"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
reboot)
|
reboot)
|
||||||
install_modules
|
install_modules; $EXEC "$BASE_CMD --tags '$TAG' --extra-vars 'do_reboot=true'" ;;
|
||||||
|
|
||||||
if [ "$1" = "-f" ] || [ "$1" = "--force" ]; then
|
|
||||||
$EXEC "$BASE_CMD --tags '$TAG' --extra-vars 'force_reboot=true'"
|
|
||||||
else
|
|
||||||
$EXEC "$BASE_CMD --tags '$TAG' --extra-vars 'reboot=true'"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
services)
|
services)
|
||||||
install_modules
|
install_modules
|
||||||
|
|
||||||
if [ "$1" = "-d" ] || [ "$1" = "--down" ]; then
|
if [ "$1" = "--down" ]; then
|
||||||
DOWN=1
|
DOWN=1
|
||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
|
@ -78,7 +71,7 @@ case $TAG in
|
||||||
|
|
||||||
$EXEC "$BASE_CMD --tags '$TAG' $(test -z "$VARS" || echo "--extra-vars '$VARS'")"
|
$EXEC "$BASE_CMD --tags '$TAG' $(test -z "$VARS" || echo "--extra-vars '$VARS'")"
|
||||||
;;
|
;;
|
||||||
-h|--help)
|
--help)
|
||||||
usage ;;
|
usage ;;
|
||||||
*)
|
*)
|
||||||
usage >&2; exit 1 ;;
|
usage >&2; exit 1 ;;
|
||||||
|
|
|
@ -14,19 +14,14 @@
|
||||||
vars:
|
vars:
|
||||||
stop: true
|
stop: true
|
||||||
when: needs_reboot.stat.exists or
|
when: needs_reboot.stat.exists or
|
||||||
(force_reboot is defined and force_reboot)
|
(do_reboot is defined and do_reboot)
|
||||||
|
|
||||||
- name: Reboot host
|
- name: Reboot host
|
||||||
ansible.builtin.reboot:
|
ansible.builtin.reboot:
|
||||||
when: needs_reboot.stat.exists or
|
when: needs_reboot.stat.exists or
|
||||||
(force_reboot is defined and force_reboot)
|
(do_reboot is defined and do_reboot)
|
||||||
register: rebooted
|
register: rebooted
|
||||||
|
|
||||||
- name: End play if reboot is not needed
|
|
||||||
ansible.builtin.meta: end_play
|
|
||||||
when: reboot is defined and reboot and
|
|
||||||
(rebooted.rebooted is undefined or not rebooted.rebooted)
|
|
||||||
|
|
||||||
- name: Re-gather facts
|
- name: Re-gather facts
|
||||||
ansible.builtin.setup:
|
ansible.builtin.setup:
|
||||||
filter:
|
filter:
|
||||||
|
|
Reference in a new issue