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

ca_path

path

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 FOREMAN_CA_PATH will be used instead.

cron_line

string

Cron expression for custom scan schedules.

Required when period=custom.

day_of_month

integer

Day of the month for the scan (1-31).

Required when period=monthly.

deploy_by

string

How the policy should be deployed to hosts.

Choices:

  • "puppet"

  • "ansible"

  • "manual"

description

string

Description of the SCAP policy.

hostgroups

list / elements=string

List of host groups to apply the policy to.

hosts

list / elements=string

List of hosts to apply the policy to.

locations

list / elements=string

List of locations the entity should be assigned to

name

string / required

Name of the SCAP policy.

oauth1_consumer_key

string

OAuth1 consumer key for accessing the Foreman server.

If the value is not specified in the task, the value of environment variable FOREMAN_OAUTH1_CONSUMER_KEY will be used instead.

oauth1_consumer_secret

string

OAuth1 consumer secret for accessing the Foreman server.

If the value is not specified in the task, the value of environment variable FOREMAN_OAUTH1_CONSUMER_SECRET will be used instead.

organizations

list / elements=string

List of organizations the entity should be assigned to

password

string

Password of the user accessing the Foreman server.

If the value is not specified in the task, the value of environment variable FOREMAN_PASSWORD will be used instead.

period

string

Schedule period for policy scans.

Choices:

  • "weekly"

  • "monthly"

  • "custom"

scap_content

string

Title of the SCAP content to use.

Required when state=present.

scap_content_profile

string

Title of the XCCDF profile within the SCAP content.

The profile must exist in the uploaded SCAP content XML.

Required when state=present.

server_url

string / required

URL of the Foreman server.

If the value is not specified in the task, the value of environment variable FOREMAN_SERVER_URL will be used instead.

state

string

State of the entity

Choices:

  • "present" ← (default)

  • "absent"

tailoring_file

string

Name of the tailoring file to apply.

tailoring_file_profile

string

Title of the XCCDF profile within the tailoring file.

Required when tailoring_file is specified.

updated_name

string

New name for the SCAP policy.

When this parameter is set, the module will not be idempotent.

use_gssapi

boolean

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 FOREMAN_USE_GSSAPI will be used instead.

Choices:

  • false ← (default)

  • true

username

string

Username accessing the Foreman server.

If the value is not specified in the task, the value of environment variable FOREMAN_USERNAME will be used instead.

validate_certs

boolean

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 FOREMAN_VALIDATE_CERTS will be used instead.

Choices:

  • false

  • true ← (default)

weekday

string

Day of the week for the scan.

Required when period=weekly.

Choices:

  • "monday"

  • "tuesday"

  • "wednesday"

  • "thursday"

  • "friday"

  • "saturday"

  • "sunday"

Attributes

Attribute

Support

Description

check_mode

Support: full

Can run in check_mode and return changed status prediction without modifying the entity

diff_mode

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

entity

dictionary

Final state of the affected entities grouped by their type.

Returned: success

policies

list / elements=dictionary

List of SCAP policies.

Returned: success

Authors

  • Paul Armstrong (@parmstro)