--- # tasks file for reboot - name: include assert.yml import_tasks: assert.yml run_once: yes delegate_to: localhost - name: install requirements ansible.builtin.package: name: "{{ reboot_requirements }}" state: present - name: configure redhat block: - name: check for needs-restarting executable (rhel) ansible.builtin.stat: path: /usr/bin/needs-restarting register: reboot_rhel_needs_restarting_executable - name: see if a reboot is required (rhel) ansible.builtin.command: needs-restarting -r check_mode: no register: reboot_rhel_needsrestarting changed_when: - reboot_rhel_needsrestarting.rc == 1 failed_when: - reboot_rhel_needsrestarting.rc not in [ 0, 1 ] when: - reboot_rhel_needs_restarting_executable.stat.exists when: - ansible_connection != "docker" - ansible_os_family == "RedHat" - name: configure debian block: - name: check for needrestart executable (debian) ansible.builtin.stat: path: /usr/sbin/needrestart register: reboot_debian_needsrestart_executable - name: see if a reboot is required (debian) ansible.builtin.command: needrestart -b check_mode: no register: reboot_debian_needrestarting changed_when: - "'NEEDRESTART-KSTA: 3' in reboot_debian_needrestarting.stdout_lines" when: - reboot_debian_needsrestart_executable.stat.exists when: - ansible_connection != "docker" - ansible_os_family == "Debian" - name: include reboot ansible.builtin.include_tasks: reboot.yml when: - ansible_connection != "docker" - (reboot_always | bool) or (reboot_rhel_needsrestarting.changed | default(no)) or (reboot_debian_needrestarting.changed | default(no))