Browse Source

New post: Ansible Playbook: Reboot Servers

restyle-spring-2019
Annika Backstrom 1 year 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 @@
Title: Ansible Playbook: Reboot Servers
Slug: ansible-playbook-reboot-servers
Summary: An Ansible playbook to reboot servers that require a reboot.
Date: 2018-10-08 10:50
Category: Technology
Tags: ansible, Linux

Here's a short Ansible playbook that reboots servers that need a reboot.

```
---
- hosts: all
tasks:
- name: check if reboot is required
stat: path=/var/run/reboot-required
register: reboot_file
- name: reboot host
reboot:
when: reboot_file.stat.exists == true
```

My hosts are configured to auto-install security updates. Many times, when I log
into a host, I'll get a notification that a reboot is required. This playbook
lets me broadcast a conditional reboot to all my hosts.

Loading…
Cancel
Save