38 lines
981 B
YAML
38 lines
981 B
YAML
- name: lookup debian version
|
|
shell: cat /etc/debian_version
|
|
register: debian_version
|
|
|
|
- name: outputs debian version
|
|
debug:
|
|
var: debian_version.stdout_lines
|
|
|
|
- name: update apt cache
|
|
apt:
|
|
update_cache: yes
|
|
|
|
- name: show updateable packages
|
|
shell: apt-get -s dist-upgrade | grep Inst
|
|
register: apt_upgrade_result
|
|
changed_when: false
|
|
failed_when: apt_upgrade_result.rc > 1
|
|
|
|
- name: outputs updatable packages
|
|
debug:
|
|
var: apt_upgrade_result.stdout_lines
|
|
when: apt_upgrade_result.stdout_lines | length > 0
|
|
|
|
- name: mark server as "restart required" if necessary
|
|
shell: "needrestart -b | grep -E 'NEEDRESTART-SESS|NEEDRESTART-SVC|NEEDRESTART-KSTA: 3'"
|
|
register: restart_needed
|
|
ignore_errors: yes
|
|
changed_when: false
|
|
failed_when: restart_needed.rc > 1
|
|
tags:
|
|
- needrestart
|
|
- restart
|
|
|
|
- name: output "restart required"
|
|
debug:
|
|
var: restart_needed.stdout_lines
|
|
when: restart_needed.stdout_lines | length > 0
|
|
tags: needrestart
|