forked from ansible-lockdown/RHEL9-CIS
updated yamllint, company naming, linting and spacing
Signed-off-by: Mark Bolwell <mark.bollyuk@gmail.com>
This commit is contained in:
parent
1b694832bb
commit
2de8a39cdc
66 changed files with 461 additions and 675 deletions
|
|
@ -17,12 +17,13 @@
|
|||
when:
|
||||
- rhel9cis_authselect_custom_profile_name not in prelim_authselect_current_profile.stdout or
|
||||
prelim_authselect_current_profile.stdout is not defined
|
||||
ansible.builtin.shell: "/usr/bin/authselect create-profile {{ rhel9cis_authselect_custom_profile_name }} -b {{ rhel9cis_authselect_default_profile_to_copy }}"
|
||||
ansible.builtin.command: "/usr/bin/authselect create-profile {{ rhel9cis_authselect_custom_profile_name }} -b {{ rhel9cis_authselect_default_profile_to_copy }}"
|
||||
changed_when: true
|
||||
args:
|
||||
creates: "/etc/authselect/custom/{{ rhel9cis_authselect_custom_profile_name }}"
|
||||
|
||||
- name: "5.3.2.1 | AUDIT | Ensure active authselect profile includes pam modules | get profile features"
|
||||
ansible.builtin.shell: "/usr/bin/authselect list-features custom/{{ rhel9cis_authselect_custom_profile_name }}"
|
||||
ansible.builtin.command: "/usr/bin/authselect list-features custom/{{ rhel9cis_authselect_custom_profile_name }}"
|
||||
changed_when: false
|
||||
register: discovered_authselect_profile_features
|
||||
|
||||
|
|
@ -37,7 +38,8 @@
|
|||
- password
|
||||
|
||||
- name: "5.3.2.1 | PATCH | Ensure active authselect profile includes pam modules | Backup and Add pam modules"
|
||||
ansible.builtin.shell: "/usr/bin/authselect select custom/{{ rhel9cis_authselect_custom_profile_name }}{% if rhel9cis_rule_5_3_2_2 %} with-faillock{% endif %}{% if rhel9cis_rule_5_3_2_3 %} with-pwquality{% endif %}{% if rhel9cis_rule_5_3_2_4 %} with-pwhistory{% endif %}{% if rhel9cis_rule_5_3_3_4_1 %} without-nullok{% endif %} --force --backup=rhel9cis-preremediate-{{ lookup('pipe', 'date +%Y-%m-%d-%H%M') }}"
|
||||
ansible.builtin.command: "/usr/bin/authselect select custom/{{ rhel9cis_authselect_custom_profile_name }}{% if rhel9cis_rule_5_3_2_2 %} with-faillock{% endif %}{% if rhel9cis_rule_5_3_2_3 %} with-pwquality{% endif %}{% if rhel9cis_rule_5_3_2_4 %} with-pwhistory{% endif %}{% if rhel9cis_rule_5_3_3_4_1 %} without-nullok{% endif %} --force --backup=rhel9cis-preremediate-{{ lookup('pipe', 'date +%Y-%m-%d-%H%M') }}"
|
||||
changed_when: true
|
||||
|
||||
- name: "5.3.2.2 | PATCH | Ensure pam_faillock module is enabled"
|
||||
when:
|
||||
|
|
@ -64,9 +66,11 @@
|
|||
failed_when: discovered_authselect_current_faillock.rc not in [ 0, 1 ]
|
||||
register: discovered_authselect_current_faillock
|
||||
|
||||
- name: "5.3.2.2 | AUDIT | Ensure pam_faillock module is enabled | Add feature if missing"
|
||||
- name: "5.3.2.2 | AUDIT | Ensure pam_faillock module is enabled | Add feature if missing" # noqa syntax-check[specific]"
|
||||
when: discovered_authselect_current_faillock.rc != 0
|
||||
ansible.builtin.shell: "/usr/bin/authselect select custom/{{ rhel9cis_authselect_custom_profile_name }}{% if rhel9cis_rule_5_3_2_2 %} with-faillock{% endif %}{% if rhel9cis_rule_5_3_2_3 %} with-pwquality{% endif %}{% if rhel9cis_rule_5_3_2_4 %} with-pwhistory{% endif %}{% if rhel9cis_rule_5_3_3_4_1 %} without-nullok{% endif %}"
|
||||
ansible.builtin.command: "/usr/bin/authselect select custom/{{ rhel9cis_authselect_custom_profile_name }}{% if rhel9cis_rule_5_3_2_2 %} with-faillock{% endif %}{% if rhel9cis_rule_5_3_2_3 %} with-pwquality{% endif %}{% if rhel9cis_rule_5_3_2_4 %} with-pwhistory{% endif %}{% if rhel9cis_rule_5_3_3_4_1 %} without-nullok{% endif %}"
|
||||
changed_when: true
|
||||
notify: Authselect update
|
||||
|
||||
- name: "5.3.2.3 | PATCH | Ensure pam_pwquality module is enabled"
|
||||
when:
|
||||
|
|
@ -90,7 +94,8 @@
|
|||
|
||||
- name: "5.3.2.3 | AUDIT | Ensure pam_pwquality module is enabled | Add feature if missing"
|
||||
when: discovered_authselect_current_quality.rc != 0
|
||||
ansible.builtin.shell: "/usr/bin/authselect select custom/{{ rhel9cis_authselect_custom_profile_name }}{% if rhel9cis_rule_5_3_2_2 %} with-faillock{% endif %}{% if rhel9cis_rule_5_3_2_3 %} with-pwquality{% endif %}{% if rhel9cis_rule_5_3_2_4 %} with-pwhistory{% endif %}{% if rhel9cis_rule_5_3_3_4_1 %} without-nullok{% endif %}"
|
||||
ansible.builtin.command: "/usr/bin/authselect select custom/{{ rhel9cis_authselect_custom_profile_name }}{% if rhel9cis_rule_5_3_2_2 %} with-faillock{% endif %}{% if rhel9cis_rule_5_3_2_3 %} with-pwquality{% endif %}{% if rhel9cis_rule_5_3_2_4 %} with-pwhistory{% endif %}{% if rhel9cis_rule_5_3_3_4_1 %} without-nullok{% endif %}"
|
||||
changed_when: true
|
||||
notify: Authselect update
|
||||
|
||||
- name: "5.3.2.4 | PATCH | Ensure pam_pwhistory module is enabled"
|
||||
|
|
@ -115,7 +120,8 @@
|
|||
|
||||
- name: "5.3.2.4 | PATCH | Ensure pam_pwhistory module is enabled | enable feature"
|
||||
when: discovered_authselect_current_history.rc != 0
|
||||
ansible.builtin.shell: "/usr/bin/authselect select custom/{{ rhel9cis_authselect_custom_profile_name }}{% if rhel9cis_rule_5_3_2_2 %} with-faillock{% endif %}{% if rhel9cis_rule_5_3_2_3 %} with-pwquality{% endif %}{% if rhel9cis_rule_5_3_2_4 %} with-pwhistory{% endif %}{% if rhel9cis_rule_5_3_3_4_1 %} without-nullok{% endif %}"
|
||||
ansible.builtin.command: "/usr/bin/authselect select custom/{{ rhel9cis_authselect_custom_profile_name }}{% if rhel9cis_rule_5_3_2_2 %} with-faillock{% endif %}{% if rhel9cis_rule_5_3_2_3 %} with-pwquality{% endif %}{% if rhel9cis_rule_5_3_2_4 %} with-pwhistory{% endif %}{% if rhel9cis_rule_5_3_3_4_1 %} without-nullok{% endif %}"
|
||||
changed_when: true
|
||||
notify: Authselect update
|
||||
|
||||
- name: "5.3.2.5 | PATCH | Ensure pam_unix module is enabled"
|
||||
|
|
@ -133,8 +139,7 @@
|
|||
- rule_5.3.2.5
|
||||
block:
|
||||
- name: "5.3.2.5 | AUDIT | Ensure pam_unix module is enabled"
|
||||
ansible.builtin.shell: |
|
||||
grep -P -- '\b(pam_unix\.so)\b' /etc/authselect/"$(head -1 /etc/authselect/authselect.conf)"/{system,password}-auth
|
||||
ansible.builtin.command: grep -P -- '\b(pam_unix\.so)\b' /etc/authselect/"$(head -1 /etc/authselect/authselect.conf)"/{system,password}-auth
|
||||
changed_when: false
|
||||
failed_when: discovered_discovered_authselect_pam_unix.rc not in [ 0, 1 ]
|
||||
register: discovered_discovered_authselect_pam_unix
|
||||
|
|
@ -142,12 +147,12 @@
|
|||
- name: "5.3.2.5 | PATCH | Ensure pam_unix module is enabled | system-auth"
|
||||
when: "'system-auth:password' not in discovered_authselect_pam_unix.stdout"
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/authselect/custom/{{ rhel9cis_authselect['custom_profile_name'] }}/system-auth
|
||||
path: /etc/authselect/custom/{{ rhel9cis_authselect_custom_profile_name }}/system-auth
|
||||
regexp: "{{ item.regexp }}"
|
||||
line: "{{ item.line }}"
|
||||
backrefs: true
|
||||
insertafter: "{{ item.after | default (omit) }}"
|
||||
insertbefore: "{{ item.before | default (omit) }}"
|
||||
insertafter: "{{ item.after | default(omit) }}"
|
||||
insertbefore: "{{ item.before | default(omit) }}"
|
||||
loop:
|
||||
- { regexp: '^(auth\s+)sufficient(\s+pam_unix.so.*)(.*)', line: '\1sufficient\2\3', after: '^auth.*pam_faillock.*preauth' }
|
||||
- { regexp: '^(password\s+)sufficient(\s+pam_unix.so.*)(.*)', line: '\1sufficient\2\3', before: '^password.*pam_deny.so' }
|
||||
|
|
@ -156,12 +161,12 @@
|
|||
- name: "5.3.2.5 | PATCH | Ensure pam_unix module is enabled | password-auth"
|
||||
when: "'password-auth:password' not in discovered_authselect_pam_unix.stdout"
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/authselect/custom/{{ rhel9cis_authselect['custom_profile_name'] }}/password-auth
|
||||
path: /etc/authselect/custom/{{ rhel9cis_authselect_custom_profile_name }}/password-auth
|
||||
line: "{{ item.line }}"
|
||||
regexp: "{{ item.regexp }}"
|
||||
backrefs: true
|
||||
insertafter: "{{ item.after | default (omit) }}"
|
||||
insertbefore: "{{ item.before | default (omit) }}"
|
||||
insertafter: "{{ item.after | default(omit) }}"
|
||||
insertbefore: "{{ item.before | default(omit) }}"
|
||||
loop:
|
||||
- { regexp: '^(auth\s+)sufficient(\s+pam_unix.so.*)(.*)', line: '\1sufficient\2\2', after: '^auth.*pam_faillock.*preauth' }
|
||||
- { regexp: '^(password\s+)sufficient(\s+pam_unix.so.*)(.*)', line: '\1sufficient\2\3', before: '^password.*pam_deny.so' }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue