Hey @aruzicka
`these two seem to be two faces of the same problem. As far as Foreman is concerned, it doesn’t consider the policy to be assigned to the host, but from what you wrote here I can’t really tell why. Until you resolve this, there won’t be any policy details deployed.`
What I mean to say here is, while policy creation I selected correct hostgroup, and I run the theforeman.foreman_scap_client role on client. that client in the same hostgroup.
Basically after role run successfully it create config.yaml file and inside it policy details should be there, but there is no policy details. only server name and port are there. When I run the openscap scan which can result give as policy id x not found.
this rpm is install on my server
$ rpm -qa | grep -i rubygem-foreman_openscap
rubygem-foreman_openscap-8.0.2-1.fm3_11.el8.noarch
here is the content of config.yaml file
DO NOT EDIT THIS FILE MANUALLY
IT IS MANAGED BY ANSIBLE
ANY MANUAL CHANGES WILL BE LOST ON THE NEXT ANSIBLE EXECUTION
Foreman proxy to which reports should be uploaded
:server: https://my-server-name.com
:port: 9090
Timeout for sending reports to proxy
:timeout: 60
Should --fetch-remote-resources be added to oscap xccdf eval command
:fetch_remote_resources: false
HTTP proxy server for downloading remote resources
:http_proxy_server:
:http_proxy_port:
SSL specific options
Client CA file.
It could be any valid certificate that is accepted by foreman-proxy, such as Puppet CA certificate (e.g., ‘/var/lib/puppet/ssl/certs/ca.pem’)
Or (recommended for client reporting to Katello) subscription manager CA file, (e.g., ‘/etc/rhsm/ca/katello-server-ca.pem’)
:ca_file: /etc/rhsm/ca/katello-server-ca.pem
Client host certificate.
It could be Puppet agent host certificate (e.g., ‘/var/lib/puppet/ssl/certs/myhost.example.com.pem’)
Or (recommended for client reporting to Katello) consumer certificate (e.g., ‘/etc/pki/consumer/cert.pem’)
:host_certificate: /etc/pki/consumer/cert.pem
Client private key
It could be Puppet agent private key (e.g., ‘/var/lib/puppet/ssl/private_keys/myhost.example.com.pem’)
Or (recommended for client reporting to Katello) consumer private key (e.g., ‘/etc/pki/consumer/key.pem’)
:host_private_key: /etc/pki/consumer/key.pem
policy (key is id as in Foreman)
I followed the below procedure.
Install plugins
-
# foreman-installer \
--enable-foreman-plugin-openscap \
--enable-foreman-cli-openscap \
--enable-foreman-proxy-plugin-openscap \
--foreman-proxy-plugin-openscap-ansible-module true \
--foreman-proxy-plugin-openscap-puppet-module true
-
Optional: Install the OpenSCAP plugin on any Smart Proxy servers:
# foreman-installer \
--enable-foreman-proxy-plugin-openscap \
--foreman-proxy-plugin-openscap-ansible-module true \
--foreman-proxy-plugin-openscap-puppet-module true
Install theforeman.foreman_scap_client role anyone method
Note: I used both method one by one (If first not work then tried with 2nd) but I did not get policy details in config.yaml
yum -y install ansiblerole-foreman_scap_client
ansible-galaxy -p /etc/ansible/roles install theforeman.foreman_scap_client
Creating SCAP content
# dnf install scap-security-guide openscap-scanner
content is available /usr/share/xml/scap/ssg/content/
$ ls -l /usr/share/xml/scap/ssg/content/total 152736-rw-r–r-- 1 a1303870 iffadm 1414 Jun 5 00:40 password_expiry_policy.xmllrwxrwxrwx 1 root root 18 Jun 16 09:17 ssg-firefox-ds-1.2.xml → ssg-firefox-ds.xml-rw-r–r-- 1 root root 388222 Jun 16 09:16 ssg-firefox-ds.xml-rw-r–r-- 1 root root 6768 Jun 16 09:17 ssg-rhel6-cpe-dictionary.xml-rw-r–r-- 1 root root 93922 Jun 16 09:17 ssg-rhel6-cpe-oval.xml-rw-r–r-- 1 root root 22934702 Jun 16 09:17 ssg-rhel6-ds-1.2.xml-rw-r–r-- 1 root root 22935173 Jun 16 09:17 ssg-rhel6-ds.xml-rw-r–r-- 1 root root 733916 Jun 16 09:17 ssg-rhel6-ocil.xml-rw-r–r-- 1 root root 2335663 Jun 16 09:17 ssg-rhel6-oval.xml-rw-r–r-- 1 root root 7439626 Jun 16 09:17 ssg-rhel6-xccdf.xml-rw-r–r-- 1 root root 2007 Jun 16 09:17 ssg-rhel7-cpe-dictionary.xml-rw-r–r-- 1 root root 122989 Jun 16 09:17 ssg-rhel7-cpe-oval.xml-rw-r–r-- 1 root root 24528262 Jun 16 09:17 ssg-rhel7-ds-1.2.xml-rw-r–r-- 1 root root 24528262 Jun 16 09:17 ssg-rhel7-ds.xml-rw-r–r-- 1 root root 1807448 Jun 16 09:17 ssg-rhel7-ocil.xml-rw-r–r-- 1 root root 5035445 Jun 16 09:17 ssg-rhel7-oval.xml-rw-r–r-- 1 root root 16890650 Jun 16 09:17 ssg-rhel7-xccdf.xmllrwxrwxrwx 1 root root 16 Jun 16 09:17 ssg-rhel8-ds-1.2.xml → ssg-rhel8-ds.xml-rw-r–r-- 1 root root 26578488 Jun 16 09:17 ssg-rhel8-ds.xml
Creating a compliance policy
-
In the Foreman web UI, navigate to Hosts > Compliance > Policies.
-
Click New Policy or New Compliance Policy.
-
Select the deployment method: Ansible, Puppet, or Manual. Then click Next.
-
Enter a name for this policy, a description (optional), then click Next.
-
Select the SCAP Content and XCCDF Profile to be applied, then click Next.
Note that Foreman does not detect whether the selected XCCDF profile contains any rules. An empty XCCDF profile, such as the Default XCCDF Profile, will return empty reports.
-
Optional: To customize the XCCDF profile, select a Tailoring File and a XCCDF Profile in Tailoring File, then click Next.
-
Specify the scheduled time when the policy is to be applied. Select Weekly, Monthly, or Custom from the Period list. The Custom option allows for greater flexibility in the policy’s schedule.
-
If you select Weekly, also select the desired day of the week from the Weekday list.
-
If you select Monthly, also specify the desired day of the month in the Day of month field.
-
If you select Custom, enter a valid Cron expression in the Cron line field.
-
Select the locations to which to apply the policy, then click Next.
-
Select the organizations to which to apply the policy, then click Next.
-
Select the host groups to which to assign the policy.
-
Click Submit.
Run the role on client
- login foreman UI
- nevigate to ansible role
- import ansible role (theforeman.foreman_scap_client)
- Nevigate to host (client machine)
- run ansible role (theforeman.foreman_scap_client) open scap client install and config.yaml & cron file created
- Run OpenSCAP scan on the same client machine.
-
Scan get failed (policy id 5 not found)

Please guid me what can I do, did I am following wrong steps or doing any mistakes somewhere. help me to make it successful run.