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 () {
|
usage () {
|
||||||
echo "Usage: $0"
|
echo "Usage: $0"
|
||||||
echo "Usage: $0 boot"
|
echo "Usage: $0 reboot [-f|--force]"
|
||||||
echo "Usage: $0 services [SINGLE_SERVICE]"
|
echo "Usage: $0 services [SINGLE_SERVICE]"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,8 +16,12 @@ if [ -z "$1" ]; then
|
||||||
$BASE_CMD
|
$BASE_CMD
|
||||||
else
|
else
|
||||||
case $1 in
|
case $1 in
|
||||||
boot)
|
reboot)
|
||||||
$BASE_CMD --tags boot
|
if [ "$2" = "-f" ] || [ "$2" = "--force" ]; then
|
||||||
|
$BASE_CMD --tags reboot --extra-vars "force_reboot=true"
|
||||||
|
else
|
||||||
|
$BASE_CMD --tags reboot
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
services)
|
services)
|
||||||
if [ -z "$2" ]; then
|
if [ -z "$2" ]; then
|
||||||
|
|
|
@ -40,5 +40,5 @@
|
||||||
- name: Set up Docker services
|
- name: Set up Docker services
|
||||||
import_tasks: services.yml
|
import_tasks: services.yml
|
||||||
tags:
|
tags:
|
||||||
- boot
|
- reboot
|
||||||
- services
|
- services
|
||||||
|
|
|
@ -12,7 +12,12 @@
|
||||||
- name: Configure SSH
|
- name: Configure SSH
|
||||||
import_tasks: ssh.yml
|
import_tasks: ssh.yml
|
||||||
|
|
||||||
|
- name: Reboot if needed
|
||||||
|
import_tasks: reboot.yml
|
||||||
|
tags:
|
||||||
|
- reboot
|
||||||
|
|
||||||
- name: Configure disks
|
- name: Configure disks
|
||||||
import_tasks: disks.yml
|
import_tasks: disks.yml
|
||||||
tags:
|
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