Skip to content

Commit 9a3a85a

Browse files
ThiloSolbrigThilo SolbrigRendanic
authored
global_handlers: Introduce a global handlers role (#455)
--------- Co-authored-by: Thilo Solbrig <thilo.solbrig@aspicon.de> Co-authored-by: Thorsten Bruhns <Rendanic@users.noreply.github.com>
1 parent be1b810 commit 9a3a85a

File tree

6 files changed

+120
-0
lines changed

6 files changed

+120
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
minor_changes:
3+
- "global_handlers: Introduce a global handlers role (oravirt#455)"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
logging:
3+
level: warning
4+
template: readme
5+
force_overwrite: true

roles/global_handlers/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# global_handlers
2+
3+
Collection of handlers includeable by other roles.
4+
5+
Make them available to your role by including it into the
6+
dependency list in meta/main.yml of your role, for instance.
7+
8+
## Table of content
9+
10+
- [Requirements](#requirements)
11+
- [Default Variables](#default-variables)
12+
- [restart_on_requirement](#restart_on_requirement)
13+
- [Dependencies](#dependencies)
14+
- [License](#license)
15+
- [Author](#author)
16+
17+
---
18+
19+
## Requirements
20+
21+
- Minimum Ansible version: `2.14.0`
22+
23+
## Default Variables
24+
25+
### restart_on_requirement
26+
27+
Controls if reboot handler actually reboots the host (true)
28+
or just displays a reboot advice (false)
29+
30+
**_Type:_** bool<br />
31+
32+
#### Default value
33+
34+
```YAML
35+
restart_on_requirement: true
36+
```
37+
38+
39+
40+
## Dependencies
41+
42+
None.
43+
44+
## License
45+
46+
license (MIT)
47+
48+
## Author
49+
50+
[Thilo Solbrig]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
# @var restart_on_requirement:description: >
3+
# Controls if reboot handler actually reboots the host (true)
4+
# or just displays a reboot advice (false)
5+
# @end
6+
# @var restart_on_requirement:type: bool
7+
restart_on_requirement: true
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
- name: Reboot concerning package updates
3+
ansible.builtin.command:
4+
"{%- if ansible_facts.os_family == 'RedHat' -%}
5+
yum needs-restarting -r
6+
{%- elif ansible_facts.os_family == 'Suse' -%}
7+
zypper needs-rebooting
8+
{%- endif -%}"
9+
failed_when: false
10+
register: _global_handlers_needs_restarting
11+
changed_when: _global_handlers_needs_restarting.rc > 0
12+
notify: restart server
13+
14+
- name: "restart server block (on behalf of 'restart server')"
15+
block:
16+
- name: Reboot
17+
when: restart_on_requirement
18+
listen: restart server
19+
ansible.builtin.reboot:
20+
- name: Reboot recommendation
21+
when: not restart_on_requirement
22+
listen: restart server
23+
ansible.builtin.debug:
24+
msg: Please REBOOT {{ ansible_hostname }} for modifications to take effect.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
# @meta description: >
3+
# Collection of handlers includeable by other roles.
4+
#
5+
# Make them available to your role by including it into the
6+
# dependency list in meta/main.yml of your role, for instance.
7+
# @end
8+
# @meta author: [Thilo Solbrig]
9+
galaxy_info:
10+
role_name: global_handlers
11+
author: Thilo Solbrig
12+
description: Collection of handlers includeable by other roles (e.g., via meta dependencies)
13+
company: ASPICON GmbH
14+
license: license (MIT)
15+
16+
min_ansible_version: 2.14.0
17+
18+
platforms:
19+
- name: EL
20+
versions:
21+
- "6"
22+
- "7"
23+
- "8"
24+
- "9"
25+
- name: SLES
26+
versions:
27+
- "15"
28+
29+
galaxy_tags: []
30+
31+
dependencies: []

0 commit comments

Comments
 (0)