bs_nix/ansible/check-reboot.yml

24 lines
553 B
YAML
Raw Normal View History

2021-03-12 10:03:10 +00:00
- hosts: '{{ target }}'
2021-01-25 08:17:08 +00:00
gather_facts: true
become: true
2021-01-29 22:04:26 +00:00
remote_user: root
2021-01-25 08:17:08 +00:00
strategy: free
tasks:
- name: dnf install needs-restarting
dnf:
name: "yum-utils"
state: latest
when: ansible_facts['os_family'] == 'RedHat' and ansible_facts ['distribution_major_version'] >= '8'
- name: check reboot
command: "/usr/bin/needs-restarting -r"
register: reboot_required
ignore_errors: True
changed_when: False
failed_when: reboot_required.rc == 1
- debug:
var: reboot_required.rc
verbosity: 2