Browse Source

New post: Ansible Playbook: Reboot Servers

restyle-spring-2019
Annika Backstrom 9 months ago
parent
commit
51af5e690c
1 changed files with 24 additions and 0 deletions
  1. 24
    0
      content/ansible-playbook-reboot-servers.md

+ 24
- 0
content/ansible-playbook-reboot-servers.md View File

@@ -0,0 +1,24 @@
1
+Title: Ansible Playbook: Reboot Servers
2
+Slug: ansible-playbook-reboot-servers
3
+Summary: An Ansible playbook to reboot servers that require a reboot.
4
+Date: 2018-10-08 10:50
5
+Category: Technology
6
+Tags: ansible, Linux
7
+
8
+Here's a short Ansible playbook that reboots servers that need a reboot.
9
+
10
+```
11
+---
12
+- hosts: all
13
+  tasks:
14
+    - name: check if reboot is required
15
+      stat: path=/var/run/reboot-required
16
+      register: reboot_file
17
+    - name: reboot host
18
+      reboot:
19
+      when: reboot_file.stat.exists == true
20
+```
21
+
22
+My hosts are configured to auto-install security updates. Many times, when I log
23
+into a host, I'll get a notification that a reboot is required. This playbook
24
+lets me broadcast a conditional reboot to all my hosts.

Loading…
Cancel
Save