Skip to content

Commit fcd2174

Browse files
authored
Merge pull request #974 from konstruktoid/injectvars
switch to the Ansible fact namespace
2 parents 4594efc + 488263c commit fcd2174

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+240
-228
lines changed

TESTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Before running any test:
1212
```console
1313
almalinux/10-kitten-x86_64_v2
1414
bento/almalinux-9
15+
bento/debian-13
1516
bento/ubuntu-22.04
1617
bento/ubuntu-24.04
1718
debian/bookworm64

handlers/main.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
name: auditd
66
enabled: true
77
when:
8-
- ansible_virtualization_type not in ["container", "docker", "podman"]
8+
- ansible_facts.virtualization_type not in ["container", "docker", "podman"]
99

1010
- name: Generate auditd rules
1111
become: true
@@ -21,14 +21,14 @@
2121
name: systemd-sysctl
2222
state: restarted
2323
when:
24-
- ansible_virtualization_type not in ["container", "docker", "podman"]
24+
- ansible_facts.virtualization_type not in ["container", "docker", "podman"]
2525

2626
- name: Reload systemd
2727
become: true
2828
ansible.builtin.systemd_service:
2929
daemon_reload: true
3030
when:
31-
- ansible_virtualization_type not in ["container", "docker", "podman"]
31+
- ansible_facts.virtualization_type not in ["container", "docker", "podman"]
3232

3333
- name: Run rkhunter propupd
3434
become: true
@@ -48,7 +48,7 @@
4848
failed_when:
4949
- rkhunter_update.rc == 1
5050
when:
51-
- ansible_virtualization_type not in ["container", "docker", "podman"]
51+
- ansible_facts.virtualization_type not in ["container", "docker", "podman"]
5252

5353
- name: Enable aidecheck
5454
become: true
@@ -57,7 +57,7 @@
5757
enabled: true
5858
state: started
5959
when:
60-
- ansible_virtualization_type not in ["container", "docker", "podman"]
60+
- ansible_facts.virtualization_type not in ["container", "docker", "podman"]
6161

6262
- name: Disable aidecheck
6363
become: true
@@ -66,7 +66,7 @@
6666
state: stopped
6767
enabled: false
6868
when:
69-
- ansible_virtualization_type not in ["container", "docker", "podman"]
69+
- ansible_facts.virtualization_type not in ["container", "docker", "podman"]
7070

7171
- name: Mask aidecheck
7272
become: true
@@ -76,7 +76,7 @@
7676
state: stopped
7777
enabled: false
7878
when:
79-
- ansible_virtualization_type not in ["container", "docker", "podman"]
79+
- ansible_facts.virtualization_type not in ["container", "docker", "podman"]
8080

8181
- name: Restart ssh service
8282
become: true
@@ -88,7 +88,7 @@
8888
- ssh_service is not success
8989
- not 'Could not find the requested service' in ssh_service.msg
9090
when:
91-
- ansible_virtualization_type not in ["container", "docker", "podman"]
91+
- ansible_facts.virtualization_type not in ["container", "docker", "podman"]
9292

9393
- name: Restart sshd service
9494
become: true
@@ -100,15 +100,15 @@
100100
- sshd_service is not success
101101
- not 'Could not find the requested service' in sshd_service.msg
102102
when:
103-
- ansible_virtualization_type not in ["container", "docker", "podman"]
103+
- ansible_facts.virtualization_type not in ["container", "docker", "podman"]
104104

105105
- name: Restart Postfix
106106
become: true
107107
ansible.builtin.service:
108108
name: postfix
109109
state: restarted
110110
when:
111-
- ansible_virtualization_type not in ["container", "docker", "podman"]
111+
- ansible_facts.virtualization_type not in ["container", "docker", "podman"]
112112

113113
- name: Run apt-get autoremove
114114
become: true
@@ -129,14 +129,14 @@
129129
enabled: false
130130
state: stopped
131131
when:
132-
- ansible_virtualization_type not in ["container", "docker", "podman"]
132+
- ansible_facts.virtualization_type not in ["container", "docker", "podman"]
133133

134134
- name: Run dnf autoremove
135135
become: true
136136
ansible.builtin.dnf:
137137
autoremove: true
138138
when:
139-
- ansible_os_family == "RedHat"
139+
- ansible_facts.os_family == "RedHat"
140140
tags:
141141
- dnf
142142
- packages
@@ -153,7 +153,7 @@
153153
register: update_debian_cracklib
154154
changed_when: update_debian_cracklib.rc == 0
155155
when:
156-
- ansible_os_family == "Debian"
156+
- ansible_facts.os_family == "Debian"
157157

158158
- name: Update RedHat cracklib
159159
environment:
@@ -164,7 +164,7 @@
164164
register: update_redhat_cracklib
165165
changed_when: update_redhat_cracklib.rc == 0
166166
when:
167-
- ansible_os_family == "RedHat"
167+
- ansible_facts.os_family == "RedHat"
168168

169169
- name: Update GRUB
170170
become: true
@@ -173,7 +173,7 @@
173173
register: update_grub
174174
changed_when: update_grub.rc == 0
175175
when:
176-
- ansible_virtualization_type not in ["container", "docker", "podman"]
176+
- ansible_facts.virtualization_type not in ["container", "docker", "podman"]
177177

178178
- name: Update GRUB2
179179
become: true
@@ -182,7 +182,7 @@
182182
register: update_grub2
183183
changed_when: update_grub2.rc == 0
184184
when:
185-
- ansible_virtualization_type not in ["container", "docker", "podman"]
185+
- ansible_facts.virtualization_type not in ["container", "docker", "podman"]
186186

187187
- name: Validate rsyslogd
188188
become: true

molecule/debian/molecule.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ provisioner:
2020
inventory:
2121
host_vars:
2222
bookworm:
23-
ansible_python_interpreter: /usr/bin/python3
23+
ansible_facts.python_interpreter: /usr/bin/python3
2424
manage_kernel: true
2525
sshd_admin_net:
2626
- 0.0.0.0/0
@@ -30,7 +30,7 @@ provisioner:
3030
manage_suid_sgid_permissions: false
3131
system_upgrade: false
3232
testing:
33-
ansible_python_interpreter: /usr/bin/python3
33+
ansible_facts.python_interpreter: /usr/bin/python3
3434
kernel_lockdown: confidentiality
3535
manage_auditd: false
3636
manage_suid_sgid_permissions: false
@@ -41,7 +41,7 @@ provisioner:
4141
- sudo
4242
sshd_update_moduli: true
4343
trixie:
44-
ansible_python_interpreter: /usr/bin/python3
44+
ansible_facts.python_interpreter: /usr/bin/python3
4545
manage_kernel: true
4646
sshd_admin_net:
4747
- 0.0.0.0/0

molecule/default/converge.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
hosts: all
44
any_errors_fatal: true
55
tasks:
6+
- name: Install OpenSSL on AlmaLinux
7+
become: true
8+
ansible.builtin.dnf:
9+
name: openssl
10+
state: present
11+
when:
12+
- ansible_facts.distribution == 'AlmaLinux'
13+
614
- name: Include Ansible role
715
ansible.builtin.import_role:
816
name: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}"

molecule/default/molecule.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ provisioner:
3636
custom_origins:
3737
- "origin=Docker,archive=trixie"
3838
allow_virtual_system_calls: false
39-
ansible_python_interpreter: /usr/bin/python3
39+
ansible_facts.python_interpreter: /usr/bin/python3
4040
disable_wireless: false
4141
kernel_lockdown: confidentiality
4242
rkhunter_web_cmd: wget

0 commit comments

Comments
 (0)