feat(Debian): add reboot handler if needed
This commit is contained in:
parent
1ee07d84ce
commit
9450ad2632
@ -1,22 +1,22 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- name: Update apt keys
|
- name: Update apt keys
|
||||||
become: yes
|
become: true
|
||||||
command: apt-key update
|
command: apt-key update
|
||||||
when: ansible_os_family == "Debian" or ansible_os_family == "OSMC"
|
when: ansible_os_family == "Debian" or ansible_os_family == "OSMC"
|
||||||
|
|
||||||
- name: Upgrade all packages to the latest version
|
- name: Upgrade all packages to the latest version
|
||||||
become: yes
|
become: true
|
||||||
apt:
|
apt:
|
||||||
upgrade: dist
|
upgrade: dist
|
||||||
update_cache: yes
|
update_cache: true
|
||||||
cache_valid_time: 3600
|
cache_valid_time: 3600
|
||||||
environment:
|
environment:
|
||||||
PATH: "{{ ansible_env.PATH }}:/sbin:/usr/sbin"
|
PATH: "{{ ansible_env.PATH }}:/sbin:/usr/sbin"
|
||||||
when: ansible_os_family == "Debian" or ansible_os_family == "OSMC"
|
when: ansible_os_family == "Debian" or ansible_os_family == "OSMC"
|
||||||
|
|
||||||
- name: Remove useless packages from the cache
|
- name: Remove useless packages from the cache
|
||||||
become: yes
|
become: true
|
||||||
become_method: sudo
|
become_method: sudo
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
command: >
|
command: >
|
||||||
@ -26,7 +26,7 @@
|
|||||||
when: ansible_os_family == "Debian" or ansible_os_family == "OSMC"
|
when: ansible_os_family == "Debian" or ansible_os_family == "OSMC"
|
||||||
|
|
||||||
- name: install packages
|
- name: install packages
|
||||||
become: yes
|
become: true
|
||||||
apt:
|
apt:
|
||||||
name: "{{ package_list | list }}"
|
name: "{{ package_list | list }}"
|
||||||
state: present
|
state: present
|
||||||
@ -42,3 +42,28 @@
|
|||||||
msg: "Restart Required!!"
|
msg: "Restart Required!!"
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
when: reboot_required_file.stat.exists == true
|
when: reboot_required_file.stat.exists == true
|
||||||
|
|
||||||
|
- name: "Reboot"
|
||||||
|
shell: 'sleep 2 && shutdown -r now'
|
||||||
|
become: true
|
||||||
|
async: 1
|
||||||
|
poll: 0
|
||||||
|
ignore_errors: true
|
||||||
|
when: reboot_required_file.stat.exists == true
|
||||||
|
|
||||||
|
# This pause is mandatory, otherwise the existing control connection gets reused!
|
||||||
|
- name: "pause "
|
||||||
|
pause:
|
||||||
|
seconds: 30
|
||||||
|
when: reboot_required_file.stat.exists == true
|
||||||
|
|
||||||
|
- name: "wait till server comes back online"
|
||||||
|
local_action: shell ansible -u {{ ansible_user_id }} -m ping {{ inventory_hostname }}
|
||||||
|
register: result
|
||||||
|
until: result.rc == 0
|
||||||
|
retries: 30
|
||||||
|
delay: 15
|
||||||
|
when: reboot_required_file.stat.exists == true
|
||||||
|
|
||||||
|
- name: Re-gather facts
|
||||||
|
action: setup
|
||||||
|
Loading…
x
Reference in New Issue
Block a user