updated README os-updates roles; optimized variables for same role

This commit is contained in:
Claudio Maradonna 2022-11-21 17:29:55 +01:00
parent 997dfa1a53
commit 83ead6aefa
Signed by untrusted user who does not match committer: claudiomaradonna
GPG key ID: 0CBA58694C5680D9
3 changed files with 15 additions and 21 deletions

View file

@ -1,38 +1,35 @@
Role Name
os-updates
=========
A brief description of the role goes here.
This role update the target system packages
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
.
Role Variables
--------------
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
**os_update_auto** (string): If 'reboot' the system will reboot after update, if 'shutdown' will shutdown, else will ignore the parameter
**os_update_auto_delay** (integer): Delay for auto reboot or shutdown
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
`ansible-playbook -i inventory/hive.yml os-update.yml --extra-vars="target=odroid"`
License
-------
BSD
GPLv3
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
- [Claudio Maradonna](https://social.unitoo.it/claudio)

View file

@ -1,8 +1,5 @@
---
# defaults file for os-updates
os_update_auto_reboot: false
os_update_reboot_delay: 60
os_update_auto_shutdown: false
os_update_shutdown_delay: 60
os_update_auto: ''
os_update_auto_delay: 60

View file

@ -12,14 +12,14 @@
- name: Reboot when packages were updated
reboot:
post_reboot_delay: "{{ os_update_reboot_delay }}"
post_reboot_delay: "{{ os_update_auto_delay }}"
when:
- apt_update_status.changed
- "os_update_auto_reboot is true"
- "os_update_auto == 'reboot'"
- name: Shutdown when packages were updated
community.general.shutdown:
delay: "{{ os_update_shutdown_delay }}"
delay: "{{ os_update_auto_delay }}"
when:
- apt_update_status.changed
- "os_update_auto_shutdown is true"
- "os_update_auto == 'shutdown'"