-
Notifications
You must be signed in to change notification settings - Fork 131
/
ubuntu_upgrade.yml
91 lines (80 loc) · 2.4 KB
/
ubuntu_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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
- hosts: all
become: true
become_user: root
roles:
- { role: apt, tags: apt }
- { role: ansible, tags: ansible, mitogen: no }
tasks:
- name: "Configure temporary dpkg options"
copy:
dest: /etc/apt/apt.conf.d/local
mode: 0644
content: 'DPkg::options { "--force-confold"; }'
- name: "Replace ansible cron"
copy:
dest: "/etc/cron.d/ansible"
content: "@reboot root /bin/sleep 180 && /usr/local/sbin/ansible-distupgrade\n"
- name: "Remove mitogen"
file:
path=/opt/mitogen
state=absent
- name: "Apt-pin ansible to new version"
lineinfile:
path: /etc/apt/preferences.d/ansible.pref
regexp: '^Pin: version (.*)$'
line: 'Pin: version 2.10.7+merged+base+2.10.8+dfsg-1'
register: ansible_pin
- name: "Run apt-get update"
apt:
update_cache: yes
when: ansible_pin.changed
- name: "Run apt-get dist-upgrade once for the current release"
apt:
upgrade: dist
update_cache: yes
tags:
- prepare
- hosts: all
become: true
become_user: root
tasks:
- name: "Remove automatic update files"
file: name={{ item }} state=absent
with_items:
- /etc/apt/apt.conf.d/50unattended-upgrades
- /etc/apt/apt.conf.d/50unattended-upgrades.dpkg-dist
- name: "Perform release upgrade (bionic -> focal)"
shell: |
do-release-upgrade -f DistUpgradeViewNonInteractive
/sbin/reboot
when: ansible_distribution_release == "bionic"
ignore_errors: True
- name: "Perform release upgrade (focal -> jammy)"
shell: |
do-release-upgrade -f DistUpgradeViewNonInteractive
/sbin/reboot
ignore_errors: True
when: ansible_distribution_release == "focal"
tags:
- upgrade
- hosts: all
become: true
become_user: root
roles:
- { role: apt, tags: apt }
- { role: ansible, tags: ansible, mitogen: no }
tasks:
- name: "Remove temporary dpkg configuration"
file:
name: /etc/apt/apt.conf.d/local
state: absent
- name: "Remove spurious automatic update file"
file: name={{ item }} state=absent
with_items:
- /etc/apt/apt.conf.d/50unattended-upgrades.dpkg-dist
- name: "Remove old virtual environments"
file: name={{ item }} state=absent
with_items:
- /usr/share/ripe-atlas-venv
tags:
- cleanup