Reboot host if needed or if forced
This commit is contained in:
parent
c85fdf12b5
commit
5decde69dc
10
deploy.sh
10
deploy.sh
|
@ -2,7 +2,7 @@
|
|||
|
||||
usage () {
|
||||
echo "Usage: $0"
|
||||
echo "Usage: $0 boot"
|
||||
echo "Usage: $0 reboot [-f|--force]"
|
||||
echo "Usage: $0 services [SINGLE_SERVICE]"
|
||||
}
|
||||
|
||||
|
@ -16,8 +16,12 @@ if [ -z "$1" ]; then
|
|||
$BASE_CMD
|
||||
else
|
||||
case $1 in
|
||||
boot)
|
||||
$BASE_CMD --tags boot
|
||||
reboot)
|
||||
if [ "$2" = "-f" ] || [ "$2" = "--force" ]; then
|
||||
$BASE_CMD --tags reboot --extra-vars "force_reboot=true"
|
||||
else
|
||||
$BASE_CMD --tags reboot
|
||||
fi
|
||||
;;
|
||||
services)
|
||||
if [ -z "$2" ]; then
|
||||
|
|
|
@ -40,5 +40,5 @@
|
|||
- name: Set up Docker services
|
||||
import_tasks: services.yml
|
||||
tags:
|
||||
- boot
|
||||
- reboot
|
||||
- services
|
||||
|
|
|
@ -12,7 +12,12 @@
|
|||
- name: Configure SSH
|
||||
import_tasks: ssh.yml
|
||||
|
||||
- name: Reboot if needed
|
||||
import_tasks: reboot.yml
|
||||
tags:
|
||||
- reboot
|
||||
|
||||
- name: Configure disks
|
||||
import_tasks: disks.yml
|
||||
tags:
|
||||
- boot
|
||||
- reboot
|
||||
|
|
12
roles/os_config/tasks/reboot.yml
Normal file
12
roles/os_config/tasks/reboot.yml
Normal file
|
@ -0,0 +1,12 @@
|
|||
# vim: ft=yaml.ansible
|
||||
---
|
||||
- name: Check if reboot is needed
|
||||
stat:
|
||||
path: /var/run/reboot-required
|
||||
register: needs_reboot
|
||||
|
||||
- name: Reboot host
|
||||
reboot:
|
||||
connect_timeout: 60
|
||||
when: needs_reboot.stat.exists or
|
||||
(force_reboot is defined and force_reboot)
|
Reference in a new issue