Skip to content

Commit 4239b66

Browse files
Add debian 13 deb822 compatibility (#97)
* Add debian 13 compatibility by using deb822 on Debian 13 distributions * Add debian 13 docker image for molecule * Add base url for deb repo and deb822 install --------- * python3-debian is required for DEB822 support added task to make sure its installed * Fixed ansible-lint findings Signed-off-by: Gary Bright <gary@mondoo.com> Co-authored-by: Gary Bright <gary@mondoo.com>
1 parent 0c3c9d2 commit 4239b66

3 files changed

Lines changed: 51 additions & 26 deletions

File tree

.github/workflows/ansible-ci.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ jobs:
1212
config:
1313
- image: geerlingguy/docker-ubuntu2204-ansible
1414
tag: latest
15+
- image: geerlingguy/docker-debian13-ansible
16+
tag: latest
1517
- image: geerlingguy/docker-rockylinux9-ansible
1618
tag: latest
1719
- image: rsprta/opensuse-ansible

defaults/main.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ update_windows_time: "12:00:00"
3535
mondoo_gpg_keyid: 4CE909E26AE7439C39CE7647AC69C65100E1C42B
3636

3737
# deb repo
38-
mondoo_deb_repo: "https://releases.mondoo.com/debian/ stable main"
38+
mondoo_deb_repo_base_url: "https://releases.mondoo.com/debian/"
39+
mondoo_deb_repo: "{{ mondoo_deb_repo_base_url }} stable main"
3940
mondoo_deb_gpgkey: "https://releases.mondoo.com/debian/pubkey.gpg"
4041
mondoo_deb_gpgkey_dest: "/usr/share/keyrings/mondoo-archive-keyring.gpg"
4142

tasks/pkg_debian.yml

Lines changed: 47 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,67 @@
33

44
---
55

6-
- name: Install gpg
6+
- name: Install gpg and apt-transport-https
77
ansible.builtin.apt:
8-
name: gpg
8+
name:
9+
- gpg
10+
- apt-transport-https
911
state: present
1012
update_cache: yes
1113
become: true
1214
when: not ansible_check_mode
1315

14-
- name: Add Mondoo apt repository key.
15-
ansible.builtin.get_url:
16-
url: "{{ mondoo_deb_gpgkey }}"
17-
dest: "/etc/apt/trusted.gpg.d/mondoo.asc"
18-
mode: '0644'
19-
force: true
20-
become: true
21-
when: not ansible_check_mode
16+
- name: Configure repository for Debian <= 12 and other distributions
17+
when:
18+
- not ansible_check_mode
19+
- ansible_distribution != "Debian" or (ansible_distribution == "Debian" and ansible_distribution_major_version | int <= 12)
20+
block:
21+
- name: Add Mondoo apt repository key.
22+
ansible.builtin.get_url:
23+
url: "{{ mondoo_deb_gpgkey }}"
24+
dest: "/etc/apt/trusted.gpg.d/mondoo.asc"
25+
mode: '0644'
26+
force: true
27+
become: true
2228

23-
- name: Pack Mondoo gpg key
24-
ansible.builtin.command: gpg --dearmor --batch --yes --output {{ mondoo_deb_gpgkey_dest }} /etc/apt/trusted.gpg.d/mondoo.asc
25-
changed_when: false
26-
no_log: true
27-
become: "{{ use_become }}"
29+
- name: Pack Mondoo gpg key
30+
ansible.builtin.command: gpg --dearmor --batch --yes --output {{ mondoo_deb_gpgkey_dest }} /etc/apt/trusted.gpg.d/mondoo.asc
31+
changed_when: false
32+
no_log: true
33+
become: "{{ use_become }}"
34+
35+
- name: Configure Mondoo deb repository
36+
ansible.builtin.apt_repository:
37+
repo: "deb [signed-by={{ mondoo_deb_gpgkey_dest }}] {{ mondoo_deb_repo }}"
38+
filename: "mondoo"
39+
state: "present"
40+
update_cache: yes
41+
become: "{{ use_become }}"
2842

29-
- name: Install apt-transport-https
43+
- name: Install python3-debian for DEB822 repository support (Debian 13+)
3044
ansible.builtin.apt:
31-
name: apt-transport-https
45+
name: python3-debian
3246
state: present
3347
update_cache: yes
3448
become: true
35-
when: not ansible_check_mode
49+
when:
50+
- not ansible_check_mode
51+
- ansible_distribution == "Debian"
52+
- ansible_distribution_major_version | int >= 13
3653

37-
- name: Configure Mondoo deb repository
38-
ansible.builtin.apt_repository:
39-
repo: "deb [signed-by={{ mondoo_deb_gpgkey_dest }}] {{ mondoo_deb_repo }}"
40-
filename: "mondoo"
41-
state: "present"
42-
update_cache: yes
54+
- name: Configure Mondoo deb repository (DEB822 format)
55+
ansible.builtin.deb822_repository:
56+
name: mondoo
57+
types: deb
58+
uris: "{{ mondoo_deb_repo_base_url }}"
59+
suites: stable
60+
components: main
61+
signed_by: "{{ mondoo_deb_gpgkey }}"
4362
become: "{{ use_become }}"
44-
when: not ansible_check_mode
63+
when:
64+
- not ansible_check_mode
65+
- ansible_distribution == "Debian"
66+
- ansible_distribution_major_version | int >= 13
4567

4668
- name: Ensure cnquery and cnspec are installed
4769
ansible.builtin.apt:

0 commit comments

Comments
 (0)