Skip to content

Commit 8faf447

Browse files
committed
NetworkManager package and PAM stat files fixes
- Use proper NetworkManager package for ubuntu2204 and ubuntu2404. - Resolved issue where using the same register variable outside and inside the block was causing failures. Signed-off-by: Shane Dell <[email protected]>
1 parent dfb60cf commit 8faf447

File tree

5 files changed

+54
-7
lines changed
  • linux_os/guide/system
    • accounts/accounts-pam/set_password_hashing_algorithm
      • set_password_hashing_algorithm_passwordauth/ansible
      • set_password_hashing_algorithm_systemauth/ansible
    • network/network-wireless/wireless_software/wireless_disable_interfaces/ansible
  • shared

5 files changed

+54
-7
lines changed

linux_os/guide/system/accounts/accounts-pam/set_password_hashing_algorithm/set_password_hashing_algorithm_passwordauth/ansible/shared.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
- name: '{{{ rule_title }}} - Check if {{{ pam_file }}} File is Present'
1313
ansible.builtin.stat:
1414
path: {{{ pam_file }}}
15-
register: result_pam_file_present
15+
register: result_pam_password_auth_file_present
1616

1717
- name: '{{{ rule_title }}} - Check The Proper Remediation For The System'
1818
block:
@@ -46,4 +46,4 @@
4646
- result_authselect_present.stat.exists
4747
- result_pam_hashing_options_removal is changed
4848
when:
49-
- result_pam_file_present.stat.exists
49+
- result_pam_password_auth_file_present.stat.exists

linux_os/guide/system/accounts/accounts-pam/set_password_hashing_algorithm/set_password_hashing_algorithm_systemauth/ansible/shared.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
- name: '{{{ rule_title }}} - Check if {{{ pam_file }}} File is Present'
1919
ansible.builtin.stat:
2020
path: {{{ pam_file }}}
21-
register: result_pam_file_present
21+
register: result_pam_auth_file_present
2222

2323
- name: '{{{ rule_title }}} - Check The Proper Remediation For The System'
2424
block:
@@ -52,4 +52,4 @@
5252
- result_authselect_present.stat.exists
5353
- result_pam_hashing_options_removal is changed
5454
when:
55-
- result_pam_file_present.stat.exists
55+
- result_pam_auth_file_present.stat.exists

linux_os/guide/system/network/network-wireless/wireless_software/wireless_disable_interfaces/ansible/shared.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
{{% if platform_package_overrides.NetworkManager %}}
2+
{{% set network_manager_package_name = platform_package_overrides.NetworkManager %}}
3+
{{% else %}}
4+
{{% set network_manager_package_name = "NetworkManager" %}}
5+
{{% endif %}}
6+
17
# platform = multi_platform_all
28
# reboot = false
39
# strategy = unknown
@@ -32,12 +38,12 @@
3238
name: "{{ item }}"
3339
state: present
3440
with_items:
35-
- NetworkManager
41+
- {{{ network_manager_package_name }}}
3642

3743
{{%- endif %}}
3844

3945
- name: NetworkManager Deactivate Wireless Network Interfaces
4046
ansible.builtin.command: nmcli radio wifi off
4147
when:
42-
- "'NetworkManager' in ansible_facts.packages"
48+
- "'{{{ network_manager_package_name }}}' in ansible_facts.packages"
4349
- ansible_facts.services['NetworkManager.service'].state == 'running'

shared/applicability/package.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ args:
6969
pkgname: snmp
7070
{{% endif %}}
7171
networkmanager:
72+
{{% if product in ["ubuntu2204", "ubuntu2404"] %}}
73+
pkgname: network-manager
74+
{{% else %}}
7275
pkgname: NetworkManager
76+
{{% endif %}}
7377
nftables:
7478
pkgname: nftables
7579
nss-pam-ldapd:

shared/macros/10-ansible.jinja

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1836,7 +1836,13 @@ Part of the grub2_bootloader_argument_absent template.
18361836
- name: '{{{ rule_title }}} - Check if {{{ pam_file }}} file is present'
18371837
ansible.builtin.stat:
18381838
path: "{{{ pam_file }}}"
1839+
{{%- if pam_file == "/etc/pam.d/password-auth" %}}
1840+
register: result_pam_password_auth_file_present
1841+
{{%- elif pam_file in ["/etc/pam.d/common-password", "/etc/pam.d/system-auth"] %}}
1842+
register: result_pam_auth_file_present
1843+
{{%- else %}}
18391844
register: result_pam_file_present
1845+
{{%- endif %}}
18401846

18411847
- name: '{{{ rule_title }}} - Ensure the "{{{ option }}}" option from "{{{ module }}}" is not present in {{{ pam_file }}}'
18421848
ansible.builtin.replace:
@@ -1848,7 +1854,14 @@ Part of the grub2_bootloader_argument_absent template.
18481854
{{%- endif %}}
18491855
replace: '\1\2'
18501856
register: result_pam_option_removal
1851-
when: result_pam_file_present.stat.exists
1857+
when:
1858+
{{%- if pam_file == "/etc/pam.d/password-auth" %}}
1859+
- result_pam_password_auth_file_present.stat.exists
1860+
{{%- elif pam_file in ["/etc/pam.d/common-password", "/etc/pam.d/system-auth"] %}}
1861+
- result_pam_auth_file_present.stat.exists
1862+
{{%- else %}}
1863+
- result_pam_file_present.stat.exists
1864+
{{%- endif %}}
18521865
{{%- endmacro -%}}
18531866

18541867

@@ -2016,7 +2029,13 @@ Part of the grub2_bootloader_argument_absent template.
20162029
- name: '{{{ rule_title }}} - Check if {{{ pam_file }}} file is present'
20172030
ansible.builtin.stat:
20182031
path: {{{ pam_file }}}
2032+
{{%- if pam_file == "/etc/pam.d/password-auth" %}}
2033+
register: result_pam_password_auth_file_present
2034+
{{%- elif pam_file in ["/etc/pam.d/common-password", "/etc/pam.d/system-auth"] %}}
2035+
register: result_pam_auth_file_present
2036+
{{%- else %}}
20192037
register: result_pam_file_present
2038+
{{%- endif %}}
20202039

20212040
- name: '{{{ rule_title }}} - Check the proper remediation for the system'
20222041
block:
@@ -2035,7 +2054,13 @@ Part of the grub2_bootloader_argument_absent template.
20352054
(result_pam_{{{ rule_id }}}_add is defined and result_pam_{{{ rule_id }}}_add.changed)
20362055
or (result_pam_{{{ rule_id }}}_edit is defined and result_pam_{{{ rule_id }}}_edit.changed)
20372056
when:
2057+
{{%- if pam_file == "/etc/pam.d/password-auth" %}}
2058+
- result_pam_password_auth_file_present.stat.exists
2059+
{{%- elif pam_file in ["/etc/pam.d/common-password", "/etc/pam.d/system-auth"] %}}
2060+
- result_pam_auth_file_present.stat.exists
2061+
{{%- else %}}
20382062
- result_pam_file_present.stat.exists
2063+
{{%- endif %}}
20392064
{{%- endmacro -%}}
20402065

20412066

@@ -2060,7 +2085,13 @@ Part of the grub2_bootloader_argument_absent template.
20602085
- name: '{{{ rule_title }}} - Check if {{{ pam_file }}} file is present'
20612086
ansible.builtin.stat:
20622087
path: {{{ pam_file }}}
2088+
{{%- if pam_file == "/etc/pam.d/password-auth" %}}
2089+
register: result_pam_password_auth_file_present
2090+
{{%- elif pam_file in ["/etc/pam.d/common-password", "/etc/pam.d/system-auth"] %}}
2091+
register: result_pam_auth_file_present
2092+
{{%- else %}}
20632093
register: result_pam_file_present
2094+
{{%- endif %}}
20642095

20652096
- name: '{{{ rule_title }}} - Check the proper remediation for the system'
20662097
block:
@@ -2073,7 +2104,13 @@ Part of the grub2_bootloader_argument_absent template.
20732104
- result_authselect_present.stat.exists
20742105
- result_pam_option_removal is changed
20752106
when:
2107+
{{%- if pam_file == "/etc/pam.d/password-auth" %}}
2108+
- result_pam_password_auth_file_present.stat.exists
2109+
{{%- elif pam_file in ["/etc/pam.d/common-password", "/etc/pam.d/system-auth"] %}}
2110+
- result_pam_auth_file_present.stat.exists
2111+
{{%- else %}}
20762112
- result_pam_file_present.stat.exists
2113+
{{%- endif %}}
20772114
{{%- endmacro -%}}
20782115

20792116

0 commit comments

Comments
 (0)