Skip to content

Commit 6b87bba

Browse files
authored
Fix repository management issues and simplify configuration (#347)
* prevent Ceph repository from being removed, fixes #342 * translate *_repository_line role variables to their respective *_repository deb822 counterparts * refactor: remove legacy repository configurations
1 parent 15e2027 commit 6b87bba

File tree

5 files changed

+108
-111
lines changed

5 files changed

+108
-111
lines changed

README.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -379,13 +379,12 @@ serially during a maintenance period.) It will also enable the IPMI watchdog.
379379
```
380380
[variable]: [default] #[description/purpose]
381381
pve_group: proxmox # host group that contains the Proxmox hosts to be clustered together
382-
# Proxmox repository configuration for PVE 9 and above
382+
# Proxmox repository configuration
383383
pve_repository:
384-
uris: # List of URIs for the Proxmox repository
385-
suites: # List of suites for the Proxmox repository
386-
components: # List of components for the Proxmox repository
387-
# Proxmox repository configuration for PVE 8 and below
388-
pve_repository_line: "deb http://download.proxmox.com/debian/pve bookworm pve-no-subscription" # apt-repository configuration - change to enterprise if needed (although TODO further configuration may be needed)
384+
uris: http://download.proxmox.com/debian/pve
385+
suites: "{{ ansible_distribution_release }}"
386+
components: pve-no-subscription # change to enterprise if needed (although TODO further configuration may be needed)
387+
# pve_repository_line: "" # apt-repository configuration, backward compatibility, prefer to use pve_repository instead
389388
pve_remove_subscription_warning: true # patches the subscription warning messages in proxmox if you are using the community edition
390389
pve_extra_packages: [] # Any extra packages you may want to install, e.g. ngrep
391390
pve_run_system_upgrades: false # Let role perform system upgrades
@@ -412,13 +411,12 @@ pve_zfs_enabled: no # Specifies whether or not to install and configure ZFS pack
412411
# pve_zfs_zed_email: "" # Should be set to an email to receive ZFS notifications
413412
pve_zfs_create_volumes: [] # List of ZFS Volumes to create (to use as PVE Storages). See section on Storage Management.
414413
pve_ceph_enabled: false # Specifies wheter or not to install and configure Ceph packages. See below for an example configuration.
415-
# Proxmox Ceph repository configuration for PVE 9 and above
414+
# Proxmox Ceph Repository
416415
pve_ceph_repository:
417-
uris: # List of URIs for the Ceph repository
418-
suites: # List of suites for the Ceph repository
419-
components: # List of components for the Ceph repository
420-
# Proxmox Ceph repository configuration for PVE 8 and below
421-
pve_ceph_repository_line: "deb http://download.proxmox.com/debian/ceph-pacific bookworm main" # apt-repository configuration. Will be automatically set for 6.x and 7.x (Further information: https://pve.proxmox.com/wiki/Package_Repositories)
416+
uris: http://download.proxmox.com/debian/ceph-{{ pve_ceph_default_version }}
417+
suites: "{{ ansible_distribution_release }}"
418+
components: "{{ pve_ceph_debian_component }}"
419+
#pve_ceph_repository_line: "" # apt-repository configuration, backward compatibility, prefer to use pve_ceph_repository instead
422420
pve_ceph_network: "{{ (ansible_default_ipv4.network +'/'+ ansible_default_ipv4.netmask) | ansible.utils.ipaddr('net') }}" # Ceph public network
423421
# pve_ceph_cluster_network: "" # Optional, if the ceph cluster network is different from the public network (see https://pve.proxmox.com/pve-docs/chapter-pveceph.html#pve_ceph_install_wizard)
424422
pve_ceph_nodes: "{{ pve_group }}" # Host group containing all Ceph nodes

defaults/main.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
22
# defaults file for ansible-role-proxmox
33
pve_group: proxmox
4+
# Proxmox PVE Repository
45
pve_repository:
56
uris: http://download.proxmox.com/debian/pve
67
suites: "{{ ansible_distribution_release }}"
78
components: pve-no-subscription
8-
# Repo configuration for Proxmox VE < 9
9-
pve_repository_line: "deb http://download.proxmox.com/debian/pve {{ ansible_distribution_release }} pve-no-subscription"
9+
# pve_repository_line: ""
1010
pve_remove_subscription_warning: true
1111
pve_extra_packages: []
1212
pve_check_for_kernel_update: true
@@ -33,15 +33,12 @@ pve_zfs_enabled: no
3333
# pve_zfs_zed_email: "email address for zfs events"
3434
pve_zfs_create_volumes: []
3535
pve_ceph_enabled: false
36+
# Proxmox Ceph Repository
3637
pve_ceph_repository:
3738
uris: http://download.proxmox.com/debian/ceph-{{ pve_ceph_default_version }}
3839
suites: "{{ ansible_distribution_release }}"
3940
components: "{{ pve_ceph_debian_component }}"
40-
# Ceph Repo configuration for Proxmox VE < 9
41-
pve_ceph_repository_line: >-
42-
deb http://download.proxmox.com/debian/ceph-{{ pve_ceph_default_version }}
43-
{{ ansible_distribution_release }}
44-
{{ pve_ceph_debian_component }}
41+
# pve_ceph_repository_line: ""
4542
pve_ceph_network: >-
4643
{{ (ansible_default_ipv4.network + '/' + ansible_default_ipv4.netmask) |
4744
ansible.utils.ipaddr('net') }}

tasks/main.yml

Lines changed: 16 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -131,59 +131,8 @@
131131
name: os-prober
132132
state: absent
133133

134-
- ansible.builtin.import_tasks: remove_enterprise_repos.yml
135-
when:
136-
- "'pve-no-subscription' in pve_repository_line"
137-
138-
- name: Manage apt repositories
139-
block:
140-
- name: Add Proxmox repository
141-
ansible.builtin.apt_repository:
142-
repo: "{{ pve_repository_line }}"
143-
filename: proxmox
144-
state: present
145-
register: _pve_repo
146-
147-
- name: Add Proxmox Ceph repository
148-
ansible.builtin.apt_repository:
149-
repo: '{{ pve_ceph_repository_line }}'
150-
filename: ceph
151-
state: present
152-
register: _pve_ceph_repo
153-
when: "pve_ceph_enabled | bool"
154-
when: "ansible_distribution_major_version | int <= 12"
155-
156-
- name: Manage deb822 repositories
157-
block:
158-
- name: Add Proxmox repository
159-
ansible.builtin.deb822_repository:
160-
name: proxmox
161-
types: deb
162-
uris: "{{ pve_repository.uris }}"
163-
suites: "{{ pve_repository.suites }}"
164-
components: "{{ pve_repository.components }}"
165-
signed_by: /etc/apt/trusted.gpg.d/proxmox-release-{{ ansible_distribution_release }}.gpg
166-
state: present
167-
register: _pve_repo
168-
169-
- name: Add Proxmox Ceph repository
170-
ansible.builtin.deb822_repository:
171-
name: ceph
172-
types: deb
173-
uris: "{{ pve_ceph_repository.uris }}"
174-
suites: "{{ pve_ceph_repository.suites }}"
175-
components: "{{ pve_ceph_repository.components }}"
176-
signed_by: /etc/apt/trusted.gpg.d/proxmox-release-{{ ansible_distribution_release }}.gpg
177-
state: present
178-
register: _pve_ceph_repo
179-
when: "pve_ceph_enabled | bool"
180-
181-
- name: Update repositories cache
182-
ansible.builtin.apt:
183-
update_cache: yes
184-
when: _pve_repo is changed or _pve_ceph_repo is changed
185-
186-
when: "ansible_distribution_major_version | int > 12"
134+
- name: Setup Proxmox repositories
135+
ansible.builtin.import_tasks: repositories.yml
187136

188137
- name: Run apt-get dist-upgrade on repository changes
189138
ansible.builtin.apt:
@@ -232,20 +181,20 @@
232181
register: _proxmox_install
233182
until: _proxmox_install is succeeded
234183

235-
- block:
236-
- ansible.builtin.import_tasks: remove_enterprise_repos.yml
237-
238-
- name: Remove subscription check wrapper function in web UI
239-
ansible.builtin.lineinfile:
240-
path: /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js
241-
line: " orig_cmd(); return;"
242-
insertafter: "^\\s+checked_command: function\\s?\\(orig_cmd\\) {$"
243-
firstmatch: yes
244-
backup: yes
245-
when:
246-
- "pve_remove_subscription_warning | bool"
184+
# Once Proxmox is installed, enterprise repositories are automatically added
185+
# This task ensure to update repositories with desired configuration
186+
- name: Ensure Proxmox repositories configuration
187+
ansible.builtin.import_tasks: repositories.yml
188+
189+
- name: Remove subscription check wrapper function in web UI
190+
ansible.builtin.lineinfile:
191+
path: /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js
192+
line: " orig_cmd(); return;"
193+
insertafter: "^\\s+checked_command: function\\s?\\(orig_cmd\\) {$"
194+
firstmatch: yes
195+
backup: yes
247196
when:
248-
- "'pve-no-subscription' in pve_repository_line"
197+
- "pve_remove_subscription_warning | bool"
249198

250199
- ansible.builtin.import_tasks: pcie_passthrough.yml
251200
when: "pve_pcie_passthrough_enabled | bool"
@@ -288,7 +237,7 @@
288237
state: "{{ item.state | default('present') }}"
289238
comment: "{{ item.comment | default(omit) }}"
290239
with_items: "{{ pve_groups }}"
291-
when: "not pve_cluster_enabled | bool or (pve_cluster_enabled | bool and inventory_hostname == _init_node)"
240+
when: "not pve_cluster_enabled or (pve_cluster_enabled | bool and inventory_hostname == _init_node)"
292241

293242
- name: Configure Proxmox user accounts
294243
proxmox_user:

tasks/remove_enterprise_repos.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

tasks/repositories.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
- name: Convert pve_repository_line to pve_repository format
3+
ansible.builtin.set_fact:
4+
pve_repository:
5+
uris: "{{ (pve_repository_line | trim | split(' '))[1] }}"
6+
suites: "{{ (pve_repository_line | trim | split(' '))[2] }}"
7+
components: "{{ (pve_repository_line | trim | split(' '))[3:] }}"
8+
when:
9+
- pve_repository_line is defined
10+
11+
- name: Convert pve_ceph_repository_line to pve_ceph_repository format
12+
ansible.builtin.set_fact:
13+
pve_ceph_repository:
14+
uris: "{{ (pve_ceph_repository_line | trim | split(' '))[1] }}"
15+
suites: "{{ (pve_ceph_repository_line | trim | split(' '))[2] }}"
16+
components: "{{ (pve_ceph_repository_line | trim | split(' '))[3:] }}"
17+
when:
18+
- pve_ceph_repository_line is defined
19+
- pve_ceph_enabled | bool
20+
21+
- name: Add PVE repository (deb822)
22+
ansible.builtin.deb822_repository:
23+
name: proxmox
24+
types: deb
25+
uris: "{{ pve_repository.uris }}"
26+
suites: "{{ pve_repository.suites }}"
27+
components: "{{ pve_repository.components }}"
28+
signed_by: "/etc/apt/trusted.gpg.d/proxmox-release-{{ ansible_distribution_release }}.gpg"
29+
state: present
30+
enabled: true
31+
register: _pve_repo
32+
33+
- name: Ensure Ceph repository (PVE 8 and below) is compatible with new filename (PVE 9)
34+
ansible.builtin.command:
35+
mv "{{ _pve_ceph_repo_file_old }}" "{{ _pve_ceph_repo_file }}"
36+
args:
37+
creates: "{{ _pve_ceph_repo_file }}"
38+
removes: "{{ _pve_ceph_repo_file_old }}"
39+
vars:
40+
_pve_ceph_repo_file: /etc/apt/sources.list.d/ceph.sources
41+
_pve_ceph_repo_file_old: /etc/apt/sources.list.d/ceph.list
42+
when:
43+
- pve_ceph_enabled | bool
44+
45+
- name: Add Ceph repository (deb822)
46+
ansible.builtin.deb822_repository:
47+
name: ceph
48+
types: deb
49+
uris: "{{ pve_ceph_repository.uris }}"
50+
suites: "{{ pve_ceph_repository.suites }}"
51+
components: "{{ pve_ceph_repository.components }}"
52+
signed_by: "/etc/apt/trusted.gpg.d/proxmox-release-{{ ansible_distribution_release }}.gpg"
53+
state: present
54+
enabled: true
55+
register: _pve_ceph_repo
56+
when:
57+
- pve_ceph_enabled | bool
58+
59+
- name: Update repositories
60+
ansible.builtin.apt:
61+
update_cache: true
62+
when: _pve_repo is changed or _pve_ceph_repo is changed
63+
64+
- name: Ensure PVE enterprise repository is absent (deb822)
65+
ansible.builtin.deb822_repository:
66+
name: pve-enterprise
67+
enabled: false
68+
state: absent
69+
when:
70+
- pve_repository.components != "pve-enterprise"
71+
72+
- name: Ensure PVE enterprise repository is absent (legacy)
73+
ansible.builtin.apt_repository:
74+
repo: "deb {{ pve_repository.uris }} {{ pve_repository.suites }} pve-enterprise"
75+
state: absent
76+
filename: pve-enterprise
77+
when:
78+
- pve_repository.components != "pve-enterprise"

0 commit comments

Comments
 (0)