-
Notifications
You must be signed in to change notification settings - Fork 0
/
dist-upgrade.yml
50 lines (43 loc) · 1.2 KB
/
dist-upgrade.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
---
- hosts: radios
become: yes
gather_facts: yes
vars:
verbose: false
log_dir: "log/dist-upgrade/{{ inventory_hostname }}"
tasks:
- name: Update packages
apt:
update_cache: yes
upgrade: dist
autoremove: yes
register: output
- name: Remove dependencies that are no longer required
apt:
autoremove: yes
- name: Check changes
set_fact:
updated: true
when: not output.stdout is search("0 upgraded, 0 newly installed")
- name: Remove unattended upgrades kept back (until next run)
file:
path: /var/lib/unattended-upgrades/kept-back
state: absent
- name: Display changes
debug:
msg: "{{ output.stdout_lines }}"
when: verbose or updated is defined
- block:
- name: "Create log directory"
file:
path: "{{ log_dir }}"
state: directory
changed_when: false
- name: "Write changes to logfile"
copy:
content: "{{ output.stdout }}"
dest: "{{ log_dir }}/dist-upgrade_{{ ansible_date_time.iso8601 }}.log"
changed_when: false
when: updated is defined
delegate_to: localhost
become: false