mirror of
https://git.local.zernis.ch/simon/homeserver.zernis.ch.git
synced 2025-12-15 21:29:40 +01:00
added update_system role
This commit is contained in:
30
roles/update_system/tasks/main.yml
Normal file
30
roles/update_system/tasks/main.yml
Normal file
@@ -0,0 +1,30 @@
|
||||
---
|
||||
- name: Update apt cache and packages
|
||||
ansible.builtin.apt:
|
||||
update_cache: true
|
||||
name: "*"
|
||||
state: latest
|
||||
register: updates_applied
|
||||
|
||||
- debug: var=updates_applied
|
||||
|
||||
- name: reboot the system
|
||||
ansible.builtin.reboot:
|
||||
reboot_timeout: 3600
|
||||
when: updates_applied.changed == true
|
||||
|
||||
- name: Autoremove no longer needed packages
|
||||
ansible.builtin.apt:
|
||||
autoremove: true
|
||||
|
||||
- name: Create custom fact directorie
|
||||
ansible.builtin.file:
|
||||
state: directory
|
||||
recurse: true
|
||||
path: /etc/ansible/facts.d
|
||||
|
||||
- name: set last_update local fact
|
||||
ansible.builtin.template:
|
||||
src: last_update.j2
|
||||
dest: /etc/ansible/facts.d/last_update.fact
|
||||
when: updates_applied.changed == true
|
||||
3
roles/update_system/templates/last_update.j2
Normal file
3
roles/update_system/templates/last_update.j2
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"date": "{{ ansible_date_time.date }}"
|
||||
}
|
||||
Reference in New Issue
Block a user