Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for FIPS mode #452

Merged
merged 1 commit into from Apr 1, 2022
Merged

Add support for FIPS mode #452

merged 1 commit into from Apr 1, 2022

Conversation

miskopo
Copy link
Member

@miskopo miskopo commented Feb 22, 2022

Introduce fips bool variable and its handling, implement FIPS setup to
provisioning playbooks. Include check to ensure that FIPS mode is
initialized correctly prior to launching the test phase.

Add support for reloading all machines from vagrant's side (this halts
all the machines, starts them up and reestablishes shared folder).
Reload can be triggered by creating a REBOOT_READY file in the vagrant
shared folder before the test phase (either in provisioning or upping
phase).

Signed-off-by: Michal Polovka mpolovka@redhat.com

@miskopo

This comment was marked as outdated.

shell: fips-mode-setup --enable

- name: reboot the machine
reboot:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a problem here. Vagrant is not able to detect a reboot, so it loses its synced folder functionality, that means we can't collect the artifacts once test is done.

Is the reboot really necessary?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@netoarmando first of all, thank you for your review!

The reboot is necessary, as FIPS setup includes changing the boot parameters. Without the reboot, fips-mode-setup --is-enabled returns return code 2, which means disabled.

Regarding possible solution, I think, we can either:

  • execute some sort of re-sync command after reboot (reboot has a hook for that)
  • move the reboot to provisioning phase before the synchronization is established

@miskopo miskopo force-pushed the fips_support branch 2 times, most recently from c4cdc08 to 6d05288 Compare March 25, 2022 12:33
@miskopo miskopo added the WIP Work In Progress label Mar 25, 2022
@miskopo
Copy link
Member Author

miskopo commented Mar 25, 2022

I'll leave it here, as the check has to be moved somewhere else.

    - name: check if the FIPS mode was enabled
      shell: fips-mode-setup --is-enabled
      register: fips_mode

    - name: assert the success of FIPS installation
      assert:
        that: "fips_mode.rc == 0"
        fail_msg: "FIPS installation was not successful, aborting"
        success_msg: "FIPS installation complete"

@miskopo miskopo force-pushed the fips_support branch 3 times, most recently from fa3002b to 5c0337e Compare March 25, 2022 15:44
@miskopo
Copy link
Member Author

miskopo commented Mar 25, 2022

miskopo/freeipa#11 shows that the current implementation correctly reloads the machines and fetches the test results. Great success!

@miskopo
Copy link
Member Author

miskopo commented Mar 25, 2022

Current state:

  • running in FIPS mode is now functional

To do:

  • logging
  • FIPS mode validation

@miskopo miskopo force-pushed the fips_support branch 2 times, most recently from 1dd2cf8 to 28e8b13 Compare March 26, 2022 11:34
@miskopo
Copy link
Member Author

miskopo commented Mar 26, 2022

I've added some logging, exception handling and check for status of FIPS installation.

@miskopo
Copy link
Member Author

miskopo commented Mar 26, 2022

I call this a great success

Mar 26 11:54:17 permanent-mpolovka-f35-big-runner bash[166181]: INFO: root: Executing: Process "vagrant ssh -c fips-mode-setup --is-enabled"
Mar 26 11:54:19 permanent-mpolovka-f35-big-runner bash[166181]: DEBUG: root: ==> controller: Libvirt Provider: volume_cache is deprecated. Use disk_driver :cache => 'unsafe' instead.
Mar 26 11:54:21 permanent-mpolovka-f35-big-runner bash[166181]: INFO: root: FIPS successfully installed.

@miskopo
Copy link
Member Author

miskopo commented Mar 26, 2022

See the full run here. Provisioning in FIPS, logging, checking of installation, all work as expected. I am thinking about adding some tests though. This PR, however, is ready in my humble opinion.

@miskopo miskopo added type:feature and removed WIP Work In Progress labels Mar 26, 2022
Copy link
Member

@netoarmando netoarmando left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this @miskopo. Check my comments, I'll look into the logs later today.

tasks/tasks.py Outdated Show resolved Hide resolved
self.build_url, 'rpms/freeipa-prci.repo'),
update_packages=self.update_packages,
selinux_enforcing=self.selinux_enforcing))
self.build_url, 'rpms/freeipa-prci.repo'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the other hand, I think we can replace this dict() with a beautiful literal. :D

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@netoarmando I hope this is what you meant :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is, maybe a little more formatted, like this:

constants.ANSIBLE_VARS_TEMPLATE.format(
    action_name=self.action_name),
    os.path.join(self.data_dir, 'vars.yml'),
    {
        "repofile_url": urllib.parse.urljoin(
            self.build_url, 'rpms/freeipa-prci.repo'
        ),
        "update_packages": self.update_packages,
        "selinux_enforcing": self.selinux_enforcing,
        "fips": self.fips,
    }
)

tasks/vagrant.py Outdated Show resolved Hide resolved
Introduce fips bool variable and its handling, implement FIPS setup to
provisioning playbooks. Include check to ensure that FIPS mode is
initialized correctly prior to launching the test phase.

Add support for reloading all machines from vagrant's side (this halts
all the machines, starts them up and reestablishes shared folder).
Reload can be triggered by creating a REBOOT_READY file in the vagrant
shared folder before the test phase (either in provisioning or upping
phase).

Signed-off-by: Michal Polovka <mpolovka@redhat.com>
Copy link
Member

@netoarmando netoarmando left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, formatting that dict is a plus. Approving this.

@miskopo miskopo merged commit 0c2be7a into freeipa:master Apr 1, 2022
@netoarmando
Copy link
Member

This has been deployed last Friday (Apr 1) in the nightly runners. It will be deployed in the gating runners today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants