-
Notifications
You must be signed in to change notification settings - Fork 1
/
prepare-to-upgrade-debian.yaml
74 lines (66 loc) · 2.69 KB
/
prepare-to-upgrade-debian.yaml
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
---
# Ansible playbook to prepare to upgrade Debian.
# This doesn't actually do the upgrade because I want to do that
# manually to manually update config files, etc.
- name: Prepare to upgrade Debian
hosts: all
become: true
vars:
old_release: bullseye
new_release: bookworm
puppet_version: 8
tasks:
- name: Prepare to upgrade Debian
when:
- ansible_facts['distribution'] == 'Debian'
- ansible_facts['distribution_release'] == old_release
block:
- name: Remove Puppet packages
ansible.builtin.package:
name:
- puppet-agent
- puppet-release
state: absent
- name: Remove Puppet package source files
ansible.builtin.file:
path: "/etc/apt/sources.list.d/{{ item }}.list"
state: absent
loop:
- pc_repo
- puppet-tools
# systemd-resolved is a separate package in bookworm and not installed
# when upgrading.
# https://www.debian.org/releases/bookworm/amd64/release-notes/ch-information.en.html#systemd-resolved
- name: Install systemd-resolved from bullseye-backports
ansible.builtin.apt:
name: systemd-resolved
default_release: bullseye-backports
- name: Update /etc/nsswitch.conf so that local resolution of domain name works
ansible.builtin.lineinfile:
path: /etc/nsswitch.conf
regexp: "^hosts:"
line: "hosts: resolve [!UNAVAIL=return] files myhostname dns"
- name: Find sources files
ansible.builtin.find:
paths: /etc/apt
recurse: true
patterns: "*.list"
register: sources
- name: Replace release codename in sources files
ansible.builtin.replace:
regexp: "{{ old_release }}"
replace: "{{ new_release }}"
path: "{{ item.path }}"
loop: "{{ sources.files }}"
- name: Update package cache
ansible.builtin.apt:
update_cache: true
autoclean: true
- name: Done
ansible.builtin.debug:
msg:
- "Now, the manual upgrade process: sudo apt upgrade --without-new-pkgs && sudo apt full-upgrade"
- "Reference: https://www.debian.org/releases/{{ new_release }}/amd64/release-notes/ch-upgrading.en.html"
- "Reinstall Puppet:"
- "wget https://apt.puppet.com/puppet{{ puppet_version }}-release-{{ new_release }}.deb && sudo apt install ./puppet{{ puppet_version }}-release-{{ new_release }}.deb" # noqa yaml[line-length]
- "sudo apt update && sudo apt install puppet-agent"