Skip to content

Commit

Permalink
moved handler to a task and exclude containers from CI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chuegel committed Nov 19, 2023
1 parent 406df29 commit 5ffd3e1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
6 changes: 0 additions & 6 deletions roles/update/handlers/main.yml

This file was deleted.

29 changes: 17 additions & 12 deletions roles/update/tasks/system.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,26 @@
- name: Check if a reboot is required
ansible.builtin.stat:
path: /var/run/reboot-required
get_md5: false
register: reboot_required
changed_when: reboot_required.stat.exists
when: ansible_os_family == "Debian"
notify: "reboot host"
register: reboot_required_debian
changed_when: false
when:
- ansible_os_family == "Debian"
- ansible_virtualization_type not in ['container', 'docker', 'lxc', 'podman'] # exclude for containers to prevent test failures in CI.

- name: Check if a reboot is required
ansible.builtin.command: needs-restarting -r
register: reboot_required
ignore_errors: true
register: reboot_required_rhel
failed_when: false
changed_when: reboot_required.rc != 0
when: ansible_os_family == "RedHat"
notify: "reboot host"
changed_when: false
when:
- ansible_os_family == "RedHat"
- ansible_virtualization_type not in ['container', 'docker', 'lxc', 'podman'] # exclude for containers to prevent test failures in CI.

- name: Make sure handlers are flushed immediately
ansible.builtin.meta: flush_handlers
- name: Rebooting host
ansible.builtin.reboot:
msg: "Reboot initiated by Ansible due to required system updates"
reboot_timeout: 1800 # 30 minutes
test_command: uptime
when: (reboot_required_debian.stat.exists is defined and reboot_required_debian.stat.exists) or
(reboot_required_rhel.rc is defined and reboot_required_rhel.rc != 0)
...

0 comments on commit 5ffd3e1

Please sign in to comment.