Applying a remediation

The boolean attribute spec.apply controls whether the remediation should be applied by the Compliance Operator. You can apply the remediation by setting the attribute to true.

Procedure
  1. Apply the remediation by setting the attribute to true:

    $ oc -n openshift-compliance \
    patch complianceremediations/<scan-name>-sysctl-net-ipv4-conf-all-accept-redirects \
    --patch '{"spec":{"apply":true}}' --type=merge

    After the Compliance Operator processes the applied remediation, the status.ApplicationState attribute would change to Applied or to Error if incorrect. When a machine config remediation is applied, that remediation along with all other applied remediations are rendered into a MachineConfig object named 75-$scan-name-$suite-name. That MachineConfig object is subsequently rendered by the Machine Config Operator and finally applied to all the nodes in a machine config pool by an instance of the machine control daemon running on each node.

    Note that when the Machine Config Operator applies a new MachineConfig object to nodes in a pool, all the nodes belonging to the pool are rebooted. This might be inconvenient when applying multiple remediations, each of which re-renders the composite 75-$scan-name-$suite-name MachineConfig object. To prevent applying the remediation immediately, you can pause the machine config pool by setting the .spec.paused attribute of a MachineConfigPool object to true.

  2. Optionally, the Compliance Operator can apply remediations automatically. Set autoApplyRemediations: true in the ScanSetting top-level object.

    Warning

    Applying remediations automatically should only be done with careful consideration.

    Important

    The Compliance Operator does not automatically resolve dependency issues that can occur between remediations. Users should perform a rescan after remediations are applied to ensure accurate results.