Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reboot handler improvements #457

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelogs/fragments/global_handler_lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
minor_changes:
- "global_handlers: Reboot handler improvements, restart_on_requirement=false, ansible-lint (oravirt#457)"
2 changes: 1 addition & 1 deletion roles/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ ol7_repo_file: public-yum-ol7.repo

## Dependencies

None.
- global_handlers

## License

Expand Down
3 changes: 2 additions & 1 deletion roles/common/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ galaxy_info:

galaxy_tags: []

dependencies: []
dependencies:
- role: global_handlers
1 change: 1 addition & 0 deletions roles/common/tasks/RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@
- install_os_packages
tags:
- commonpackages
notify: Reboot concerning package updates
1 change: 1 addition & 0 deletions roles/common/tasks/Suse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
- install_os_packages
tags:
- commonpackages
notify: Reboot concerning package updates
2 changes: 1 addition & 1 deletion roles/global_handlers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ or just displays a reboot advice (false)
#### Default value

```YAML
restart_on_requirement: true
restart_on_requirement: false
```


Expand Down
2 changes: 1 addition & 1 deletion roles/global_handlers/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# or just displays a reboot advice (false)
# @end
# @var restart_on_requirement:type: bool
restart_on_requirement: true
restart_on_requirement: false
16 changes: 9 additions & 7 deletions roles/global_handlers/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
---
- name: Reboot concerning package updates
ansible.builtin.command:
"{%- if ansible_facts.os_family == 'RedHat' -%}
yum needs-restarting -r
{%- elif ansible_facts.os_family == 'Suse' -%}
zypper needs-rebooting
{%- endif -%}"
ansible.builtin.command: >-
{% if ansible_facts.os_family == 'RedHat' -%}
yum needs-restarting -r
{% elif ansible_facts.os_family == 'Suse' -%}
zypper needs-rebooting
{% endif -%}

failed_when: false
register: _global_handlers_needs_restarting
changed_when: _global_handlers_needs_restarting.rc > 0
Expand All @@ -17,8 +18,9 @@
when: restart_on_requirement
listen: restart server
ansible.builtin.reboot:

- name: Reboot recommendation
when: not restart_on_requirement
listen: restart server
ansible.builtin.debug:
msg: Please REBOOT {{ ansible_hostname }} for modifications to take effect.
msg: "Please REBOOT {{ ansible_hostname }} for modifications to take effect."
1 change: 1 addition & 0 deletions roles/orahost/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,7 @@ transparent_hugepage_disable:

## Dependencies

- global_handlers
- orahost_meta

## License
Expand Down
4 changes: 0 additions & 4 deletions roles/orahost/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
name: network
state: restarted

- name: restart server
ansible.builtin.command: reboot
# noqa no-changed-when

- name: swapon
ansible.builtin.command: swapon -a
# noqa no-changed-when
1 change: 1 addition & 0 deletions roles/orahost/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ galaxy_info:
galaxy_tags: []

dependencies:
- role: global_handlers
- role: orahost_meta
2 changes: 2 additions & 0 deletions roles/orahost/tasks/RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- install_os_packages
- ansible_distribution_major_version is version('7', '<=')
tags: os_packages, oscheck
notify: Reboot concerning package updates

- name: Install packages required by Oracle for ASMlib on OL/RHEL
ansible.builtin.yum:
Expand All @@ -22,6 +23,7 @@
- device_persistence == 'asmlib'
- asm_diskgroups is defined
tags: os_packages, oscheck
notify: Reboot concerning package updates

- name: Disable Firewall
when:
Expand Down
3 changes: 3 additions & 0 deletions roles/orahost/tasks/Suse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- install_os_packages
- ansible_os_family == 'Suse'
tags: os_packages, oscheck
notify: Reboot concerning package updates

- name: Install default packages required by Oracle on SLES (version dependant)
community.general.zypper:
Expand All @@ -23,6 +24,7 @@
- ansible_os_family == 'Suse'
- item.condition | default(false)
tags: os_packages, oscheck
notify: Reboot concerning package updates

- name: Install packages required by Oracle for ASMlib on SLES
community.general.zypper:
Expand All @@ -33,6 +35,7 @@
- device_persistence == 'asmlib'
- asm_diskgroups is defined
tags: os_packages, oscheck, asm1
notify: Reboot concerning package updates

- name: Disable Transparent Hugepages (runtime)
ansible.builtin.shell: |
Expand Down
Loading