Add playbook and accompanying role for doing maintenance
This commit is contained in:
parent
de97436706
commit
b295690ad5
3 changed files with 33 additions and 0 deletions
7
playbooks/maintenance.yaml
Normal file
7
playbooks/maintenance.yaml
Normal file
|
@ -0,0 +1,7 @@
|
|||
- name: Make Sure System Package Are Up-To-Date
|
||||
hosts: all
|
||||
roles:
|
||||
- apt_update_and_upgrade
|
||||
|
||||
- name: Run deploy Playbook
|
||||
ansible.builtin.import_playbook: deploy.yaml
|
11
playbooks/roles/apt_update_and_upgrade/README.md
Normal file
11
playbooks/roles/apt_update_and_upgrade/README.md
Normal file
|
@ -0,0 +1,11 @@
|
|||
# Role `apt_update_and_upgrade`
|
||||
|
||||
This role does an `apt-get update`, `apt-get dist-upgrade` and a potential reboot (if packages got upgraded) on the specified hosts.
|
||||
|
||||
## `hosts`
|
||||
|
||||
The `hosts` for this role need to be the VMs, which should be updated and upgraded.
|
||||
|
||||
## Required Variables
|
||||
|
||||
This role doesn't have any required variables.
|
15
playbooks/roles/apt_update_and_upgrade/tasks/main.yaml
Normal file
15
playbooks/roles/apt_update_and_upgrade/tasks/main.yaml
Normal file
|
@ -0,0 +1,15 @@
|
|||
- name: update, upgrade and potentially reboot
|
||||
become: true
|
||||
block:
|
||||
- name: apt-get update
|
||||
ansible.builtin.apt:
|
||||
update-cache: true
|
||||
|
||||
- name: apt-get dist-upgrade
|
||||
ansible.builtin.apt:
|
||||
upgrade: dist
|
||||
register: apt_update_and_upgrade__upgrade_result
|
||||
|
||||
- name: reboot, after package upgrade
|
||||
ansible.builtin.reboot:
|
||||
when: apt_update_and_upgrade__upgrade_result.changed
|
Loading…
Reference in a new issue