- name: Gather the package facts
package_facts:
manager: auto
tags:
- CJIS-5.10.1.2
- DISA-STIG-OL07-00-021350 - NIST-800-171-3.13.11
- NIST-800-171-3.13.8
- NIST-800-53-CM-6(a)
- NIST-800-53-IA-7
- NIST-800-53-SC-12
- NIST-800-53-SC-12(2)
- NIST-800-53-SC-12(3)
- NIST-800-53-SC-13
- grub2_enable_fips_mode
- high_complexity
- high_severity
- medium_disruption
- reboot_required
- restrict_strategy
- name: Check prelink binary installed
stat:
path: /usr/sbin/prelink
register: prelink_exists
when:
- ( not ( lookup("env", "container") == "bwrap-osbuild" ) and "kernel" in ansible_facts.packages
)
- '"grub2-common" in ansible_facts.packages'
tags:
- CJIS-5.10.1.2
- DISA-STIG-OL07-00-021350
- NIST-800-171-3.13.11
- NIST-800-171-3.13.8
- NIST-800-53-CM-6(a)
- NIST-800-53-IA-7
- NIST-800-53-SC-12
- NIST-800-53-SC-12(2)
- NIST-800-53-SC-12(3)
- NIST-800-53-SC-13
- grub2_enable_fips_mode
- high_complexity
- high_severity
- medium_disruption
- reboot_required
- restrict_strategy
- name: Disable prelink
lineinfile:
dest: /etc/sysconfig/prelink
regexp: ^#?PRELINKING
line: PRELINKING=no
when:
- ( not ( lookup("env", "container") == "bwrap-osbuild" ) and "kernel" in ansible_facts.packages
)
- '"grub2-common" in ansible_facts.packages'
- prelink_exists.stat.exists
tags:
- CJIS-5.10.1.2
- DISA-STIG-OL07-00-021350
- NIST-800-171-3.13.11
- NIST-800-171-3.13.8
- NIST-800-53-CM-6(a)
- NIST-800-53-IA-7
- NIST-800-53-SC-12
- NIST-800-53-SC-12(2)
- NIST-800-53-SC-12(3)
- NIST-800-53-SC-13
- grub2_enable_fips_mode
- high_complexity
- high_severity
- medium_disruption
- reboot_required
- restrict_strategy
- name: Revert prelinking binaries
command: /usr/sbin/prelink -ua
when:
- ( not ( lookup("env", "container") == "bwrap-osbuild" ) and "kernel" in ansible_facts.packages
)
- '"grub2-common" in ansible_facts.packages'
- prelink_exists.stat.exists
tags:
- CJIS-5.10.1.2
- DISA-STIG-OL07-00-021350
- NIST-800-171-3.13.11
- NIST-800-171-3.13.8
- NIST-800-53-CM-6(a)
- NIST-800-53-IA-7
- NIST-800-53-SC-12
- NIST-800-53-SC-12(2)
- NIST-800-53-SC-12(3)
- NIST-800-53-SC-13
- grub2_enable_fips_mode
- high_complexity
- high_severity
- medium_disruption
- reboot_required
- restrict_strategy
- name: Check if system supports AES-NI
command: grep -q -m1 -o aes /proc/cpuinfo
failed_when: aesni_supported.rc > 1
register: aesni_supported
check_mode: false
when:
- ( not ( lookup("env", "container") == "bwrap-osbuild" ) and "kernel" in ansible_facts.packages
)
- '"grub2-common" in ansible_facts.packages'
tags:
- CJIS-5.10.1.2
- DISA-STIG-OL07-00-021350
- NIST-800-171-3.13.11
- NIST-800-171-3.13.8
- NIST-800-53-CM-6(a)
- NIST-800-53-IA-7
- NIST-800-53-SC-12
- NIST-800-53-SC-12(2)
- NIST-800-53-SC-12(3)
- NIST-800-53-SC-13
- grub2_enable_fips_mode
- high_complexity
- high_severity
- medium_disruption
- reboot_required
- restrict_strategy
- name: Ensure dracut-fips-aesni is installed
package:
name: dracut-fips-aesni
state: present
when:
- ( not ( lookup("env", "container") == "bwrap-osbuild" ) and "kernel" in ansible_facts.packages
)
- '"grub2-common" in ansible_facts.packages'
- aesni_supported.rc == 0
tags:
- CJIS-5.10.1.2
- DISA-STIG-OL07-00-021350
- NIST-800-171-3.13.11
- NIST-800-171-3.13.8
- NIST-800-53-CM-6(a)
- NIST-800-53-IA-7
- NIST-800-53-SC-12
- NIST-800-53-SC-12(2)
- NIST-800-53-SC-12(3)
- NIST-800-53-SC-13
- grub2_enable_fips_mode
- high_complexity
- high_severity
- medium_disruption
- reboot_required
- restrict_strategy
- name: Install dracut-fips
package:
name: dracut-fips
state: present
when:
- ( not ( lookup("env", "container") == "bwrap-osbuild" ) and "kernel" in ansible_facts.packages
)
- '"grub2-common" in ansible_facts.packages'
tags:
- CJIS-5.10.1.2
- DISA-STIG-OL07-00-021350
- NIST-800-171-3.13.11
- NIST-800-171-3.13.8
- NIST-800-53-CM-6(a)
- NIST-800-53-IA-7
- NIST-800-53-SC-12
- NIST-800-53-SC-12(2)
- NIST-800-53-SC-12(3)
- NIST-800-53-SC-13
- grub2_enable_fips_mode
- high_complexity
- high_severity
- medium_disruption
- reboot_required
- restrict_strategy
- name: Rebuild initramfs
command: dracut -f
when:
- ( not ( lookup("env", "container") == "bwrap-osbuild" ) and "kernel" in ansible_facts.packages
)
- '"grub2-common" in ansible_facts.packages'
tags:
- CJIS-5.10.1.2
- DISA-STIG-OL07-00-021350
- NIST-800-171-3.13.11
- NIST-800-171-3.13.8
- NIST-800-53-CM-6(a)
- NIST-800-53-IA-7
- NIST-800-53-SC-12
- NIST-800-53-SC-12(2)
- NIST-800-53-SC-12(3)
- NIST-800-53-SC-13
- grub2_enable_fips_mode
- high_complexity
- high_severity
- medium_disruption
- reboot_required
- restrict_strategy
- name: Check fips argument exists
command: grep 'GRUB_CMDLINE_LINUX.*fips=' /etc/default/grub
failed_when: false
register: fipsargcheck
check_mode: false
when:
- ( not ( lookup("env", "container") == "bwrap-osbuild" ) and "kernel" in ansible_facts.packages
)
- '"grub2-common" in ansible_facts.packages'
tags:
- CJIS-5.10.1.2
- DISA-STIG-OL07-00-021350
- NIST-800-171-3.13.11
- NIST-800-171-3.13.8
- NIST-800-53-CM-6(a)
- NIST-800-53-IA-7
- NIST-800-53-SC-12
- NIST-800-53-SC-12(2)
- NIST-800-53-SC-12(3)
- NIST-800-53-SC-13
- grub2_enable_fips_mode
- high_complexity
- high_severity
- medium_disruption
- reboot_required
- restrict_strategy
- name: Replace existing fips argument
replace:
path: /etc/default/grub
regexp: fips=.
replace: fips=1
when:
- ( not ( lookup("env", "container") == "bwrap-osbuild" ) and "kernel" in ansible_facts.packages
)
- '"grub2-common" in ansible_facts.packages'
- fipsargcheck.rc == 0
tags:
- CJIS-5.10.1.2
- DISA-STIG-OL07-00-021350
- NIST-800-171-3.13.11
- NIST-800-171-3.13.8
- NIST-800-53-CM-6(a)
- NIST-800-53-IA-7
- NIST-800-53-SC-12
- NIST-800-53-SC-12(2)
- NIST-800-53-SC-12(3)
- NIST-800-53-SC-13
- grub2_enable_fips_mode
- high_complexity
- high_severity
- medium_disruption
- reboot_required
- restrict_strategy
- name: Add fips argument
replace:
path: /etc/default/grub
regexp: (GRUB_CMDLINE_LINUX=.*)"
replace: \1 fips=1"
when:
- ( not ( lookup("env", "container") == "bwrap-osbuild" ) and "kernel" in ansible_facts.packages
)
- '"grub2-common" in ansible_facts.packages'
- fipsargcheck.rc != 0
tags:
- CJIS-5.10.1.2
- DISA-STIG-OL07-00-021350
- NIST-800-171-3.13.11
- NIST-800-171-3.13.8
- NIST-800-53-CM-6(a)
- NIST-800-53-IA-7
- NIST-800-53-SC-12
- NIST-800-53-SC-12(2)
- NIST-800-53-SC-12(3)
- NIST-800-53-SC-13
- grub2_enable_fips_mode
- high_complexity
- high_severity
- medium_disruption
- reboot_required
- restrict_strategy
- name: Get boot device uuid
command: findmnt --noheadings --output uuid --target /boot
register: bootuuid
check_mode: false
when:
- ( not ( lookup("env", "container") == "bwrap-osbuild" ) and "kernel" in ansible_facts.packages
)
- '"grub2-common" in ansible_facts.packages'
tags:
- CJIS-5.10.1.2
- DISA-STIG-OL07-00-021350
- NIST-800-171-3.13.11
- NIST-800-171-3.13.8
- NIST-800-53-CM-6(a)
- NIST-800-53-IA-7
- NIST-800-53-SC-12
- NIST-800-53-SC-12(2)
- NIST-800-53-SC-12(3)
- NIST-800-53-SC-13
- grub2_enable_fips_mode
- high_complexity
- high_severity
- medium_disruption
- reboot_required
- restrict_strategy
- name: Check boot argument exists
command: grep 'GRUB_CMDLINE_LINUX.*boot=' /etc/default/grub
failed_when: false
register: bootargcheck
check_mode: false
when:
- ( not ( lookup("env", "container") == "bwrap-osbuild" ) and "kernel" in ansible_facts.packages
)
- '"grub2-common" in ansible_facts.packages'
tags:
- CJIS-5.10.1.2
- DISA-STIG-OL07-00-021350
- NIST-800-171-3.13.11
- NIST-800-171-3.13.8
- NIST-800-53-CM-6(a)
- NIST-800-53-IA-7
- NIST-800-53-SC-12
- NIST-800-53-SC-12(2)
- NIST-800-53-SC-12(3)
- NIST-800-53-SC-13
- grub2_enable_fips_mode
- high_complexity
- high_severity
- medium_disruption
- reboot_required
- restrict_strategy
- name: Replace existing boot argument
replace:
path: /etc/default/grub
regexp: boot=\w*-\w*-\w*-\w*-\w*
replace: boot={{ bootuuid.stdout }}
when:
- ( not ( lookup("env", "container") == "bwrap-osbuild" ) and "kernel" in ansible_facts.packages
)
- '"grub2-common" in ansible_facts.packages'
- bootargcheck.rc == 0
tags:
- CJIS-5.10.1.2
- DISA-STIG-OL07-00-021350
- NIST-800-171-3.13.11
- NIST-800-171-3.13.8
- NIST-800-53-CM-6(a)
- NIST-800-53-IA-7
- NIST-800-53-SC-12
- NIST-800-53-SC-12(2)
- NIST-800-53-SC-12(3)
- NIST-800-53-SC-13
- grub2_enable_fips_mode
- high_complexity
- high_severity
- medium_disruption
- reboot_required
- restrict_strategy
- name: Add boot argument
replace:
path: /etc/default/grub
regexp: (GRUB_CMDLINE_LINUX=.*)"
replace: \1 boot=UUID={{ bootuuid.stdout }}"
when:
- ( not ( lookup("env", "container") == "bwrap-osbuild" ) and "kernel" in ansible_facts.packages
)
- '"grub2-common" in ansible_facts.packages'
- bootargcheck.rc != 0
tags:
- CJIS-5.10.1.2
- DISA-STIG-OL07-00-021350
- NIST-800-171-3.13.11
- NIST-800-171-3.13.8
- NIST-800-53-CM-6(a)
- NIST-800-53-IA-7
- NIST-800-53-SC-12
- NIST-800-53-SC-12(2)
- NIST-800-53-SC-12(3)
- NIST-800-53-SC-13
- grub2_enable_fips_mode
- high_complexity
- high_severity
- medium_disruption
- reboot_required
- restrict_strategy
- name: Update bootloader menu
command: /sbin/grubby --update-kernel=ALL --args="fips=1 boot=UUID={{ bootuuid.stdout
}}"
when:
- ( not ( lookup("env", "container") == "bwrap-osbuild" ) and "kernel" in ansible_facts.packages
)
- '"grub2-common" in ansible_facts.packages'
tags:
- CJIS-5.10.1.2
- DISA-STIG-OL07-00-021350
- NIST-800-171-3.13.11
- NIST-800-171-3.13.8
- NIST-800-53-CM-6(a)
- NIST-800-53-IA-7
- NIST-800-53-SC-12
- NIST-800-53-SC-12(2)
- NIST-800-53-SC-12(3)
- NIST-800-53-SC-13
- grub2_enable_fips_mode
- high_complexity
- high_severity
- medium_disruption
- reboot_required
- restrict_strategy