theforeman.foreman.scap_policy module – Manage SCAP Policies
Note
This module is part of the theforeman.foreman collection (version 6.1.0-dev).
It is not included in ansible-core.
To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install theforeman.foreman.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: theforeman.foreman.scap_policy.
New in theforeman.foreman 6.1.0
Synopsis
Create, update, and delete SCAP compliance policies.
Policies tie SCAP content and a profile to host groups or individual hosts with a scan schedule and deployment method.
Requirements
The below requirements are needed on the host that executes this module.
requests
Parameters
Parameter |
Comments |
|---|---|
PEM formatted file that contains a CA certificate to be used for validation. If the value is not specified in the task, the value of environment variable |
|
Cron expression for custom scan schedules. Required when period=custom. |
|
Day of the month for the scan (1-31). Required when period=monthly. |
|
How the policy should be deployed to hosts. Choices:
|
|
Description of the SCAP policy. |
|
List of host groups to apply the policy to. |
|
List of hosts to apply the policy to. |
|
List of locations the entity should be assigned to |
|
Name of the SCAP policy. |
|
OAuth1 consumer key for accessing the Foreman server. If the value is not specified in the task, the value of environment variable |
|
OAuth1 consumer secret for accessing the Foreman server. If the value is not specified in the task, the value of environment variable |
|
List of organizations the entity should be assigned to |
|
Password of the user accessing the Foreman server. If the value is not specified in the task, the value of environment variable |
|
Schedule period for policy scans. Choices:
|
|
Title of the SCAP content to use. Required when state=present. |
|
Title of the XCCDF profile within the SCAP content. The profile must exist in the uploaded SCAP content XML. Required when state=present. |
|
URL of the Foreman server. If the value is not specified in the task, the value of environment variable |
|
State of the entity Choices:
|
|
Name of the tailoring file to apply. |
|
Title of the XCCDF profile within the tailoring file. Required when tailoring_file is specified. |
|
New name for the SCAP policy. When this parameter is set, the module will not be idempotent. |
|
Use GSSAPI to perform the authentication, typically this is for Kerberos or Kerberos through Negotiate authentication. Requires the Python library requests-gssapi to be installed. If the value is not specified in the task, the value of environment variable Choices:
|
|
Username accessing the Foreman server. If the value is not specified in the task, the value of environment variable |
|
Whether or not to verify the TLS certificates of the Foreman server. If the value is not specified in the task, the value of environment variable Choices:
|
|
Day of the week for the scan. Required when period=weekly. Choices:
|
Attributes
Attribute |
Support |
Description |
|---|---|---|
Support: full |
Can run in check_mode and return changed status prediction without modifying the entity |
|
Support: full |
Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode |
Examples
- name: Create a weekly STIG compliance policy deployed via Ansible
theforeman.foreman.scap_policy:
name: "RHEL 9 STIG Weekly"
description: "Weekly DISA STIG scan for RHEL 9 production servers"
scap_content: "Red Hat rhel9 default content"
scap_content_profile: "DISA STIG for Red Hat Enterprise Linux 9"
deploy_by: ansible
period: weekly
weekday: monday
hostgroups:
- "RHEL9/Production"
organizations:
- "Default Organization"
locations:
- "Default Location"
server_url: "https://satellite.example.com"
username: "admin"
password: "changeme"
state: present
- name: Create a monthly PCI-DSS policy with a tailoring file
theforeman.foreman.scap_policy:
name: "PCI-DSS Monthly Audit"
scap_content: "Red Hat rhel9 default content"
scap_content_profile: "PCI-DSS v4.0 Control Baseline for Red Hat Enterprise Linux 9"
tailoring_file: "RHEL 9 PCI customizations"
tailoring_file_profile: "Customized PCI-DSS v4.0"
deploy_by: ansible
period: monthly
day_of_month: 1
hostgroups:
- "RHEL9/PCI"
organizations:
- "Default Organization"
locations:
- "Default Location"
server_url: "https://satellite.example.com"
username: "admin"
password: "changeme"
state: present
- name: Create a policy with a custom cron schedule
theforeman.foreman.scap_policy:
name: "Nightly CIS Scan"
scap_content: "Red Hat rhel9 default content"
scap_content_profile: "CIS Red Hat Enterprise Linux 9 Benchmark for Level 1 - Server"
deploy_by: ansible
period: custom
cron_line: "0 2 * * *"
hostgroups:
- "RHEL9/Production"
- "RHEL9/Staging"
organizations:
- "Default Organization"
locations:
- "Default Location"
server_url: "https://satellite.example.com"
username: "admin"
password: "changeme"
state: present
- name: Create a manual policy (no automatic deployment)
theforeman.foreman.scap_policy:
name: "Ad-hoc Security Audit"
scap_content: "Red Hat rhel9 default content"
scap_content_profile: "DISA STIG for Red Hat Enterprise Linux 9"
deploy_by: manual
hostgroups:
- "RHEL9/Production"
organizations:
- "Default Organization"
locations:
- "Default Location"
server_url: "https://satellite.example.com"
username: "admin"
password: "changeme"
state: present
- name: Delete a SCAP policy
theforeman.foreman.scap_policy:
name: "RHEL 9 STIG Weekly"
server_url: "https://satellite.example.com"
username: "admin"
password: "changeme"
state: absent
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
|---|---|
Final state of the affected entities grouped by their type. Returned: success |
|
List of SCAP policies. Returned: success |