added reboot functionality to update role

This commit is contained in:
2022-11-19 14:23:04 +01:00
parent 903d690f3b
commit 30e688614b
3 changed files with 24 additions and 4 deletions

View File

@@ -1,2 +1,3 @@
--- ---
update_autoremove: yes update_autoremove: yes
update_reboot_allowed: yes

View File

@@ -8,6 +8,25 @@
- name: "Autoremove and cleanup" - name: "Autoremove and cleanup"
apt: apt:
autoremove: yes autoremove: yes
clean: yes autoclean: yes
when: when:
- "update_autoremove" - "update_autoremove"
- name: "Check if reboot file exists"
stat:
path: "/var/run/reboot-required"
register: p
- name: "Output required reboot"
debug:
msg:
- "Reboot required: {{ p.stat.exists }}"
- "Reboot allowed: {{ update_reboot_allowed }}"
- name: "Reboot Host"
reboot:
msg: "Reboot initiated by Ansible"
post_reboot_delay: 10
when:
- "p.stat.exists"
- "update_reboot_allowed"

View File

@@ -1,5 +1,5 @@
--- ---
- hosts: localhost - hosts: all
remote_user: root remote_user: root
roles: roles:
- Ansible-Role-Update - Ansible-Role-Update