24 lines
553 B
YAML
24 lines
553 B
YAML
- hosts: '{{ target }}'
|
|
gather_facts: true
|
|
become: true
|
|
remote_user: root
|
|
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
|
|
|