theforeman.foreman_scap_client
Foreman SCAP 客户端的 Ansible 角色 
此 Ansible 角色为 Foreman SCAP 客户端配置 foreman_scap_client,以运行扫描并将结果上传到 Foreman 代理。
配置
该角色将自动安装 foreman_scap_client(如果尚未安装),并将使用所需的参数配置 /etc/foreman_scap_client/config.yaml,以便于 foreman_scap_client 的操作,并创建一个计划任务以调度客户端执行。
变量
- 'foreman_scap_client_state':rubygem-foreman_scap_client 包的状态
- 'foreman_scap_client_package':如果包名与默认不同,则为包的名称(el7/suse 使用 rubygem-foreman_scap_client,debian/ubuntu 使用 ruby-foreman-scap-client)
- 'foreman_scap_client_server':配置代理服务器
- 'foreman_scap_client_port':配置代理服务器的端口
- 'foreman_scap_client_policies':需要配置的政策数组
- 'foreman_scap_client_ca_cert_path':颁发客户端证书的认证机构文件路径
- 'foreman_scap_client_host_cert_path':主机证书路径,可能是 Puppet agent 证书或 Katello 证书
- 'foreman_scap_client_host_private_key_path':主机私钥路径,可能是 Puppet agent 私钥或 Katello 私钥
- 'foreman_scap_client_release':要为其配置的发行版
- 'foreman_scap_client_repo_url':提供 rubygem-foreman_scap_client 的存储库 URL
- 'foreman_scap_client_apt_repo_url':提供 scap-client 和 subscription-manager 的 Debian 基础存储库
- 'foreman_scap_client_repo_state':存储库的状态
- 'foreman_scap_client_repo_key':foreman-plugins 存储库的 RPM 密钥源文件。注意:当前,软件包未签名。除非设置为其他文件源,否则将使用 URL。
- 'foreman_scap_client_repo_gpg':启用/禁用 GPG 检查
- 'foreman_scap_client_cron_template':计划任务模板路径
- 'foreman_scap_client_cron_splay_seed':用于生成随机但幂等数字的计划任务延迟时间种子
- 'foreman_scap_client_cron_splay':计划任务延迟时间的上限
- 'foreman_scap_client_fetch_remote_resources':是否从远程位置获取引用的资源
- 'foreman_scap_client_http_proxy_server':HTTP 代理服务器
- 'foreman_scap_client_http_proxy_port':HTTP 代理端口
- 'foreman_scap_client_ciphers':用于连接协商的可选加密算法列表。示例:["AES256-SHA:AES128-SHA:DES-CBC3-SHA"]
示例用法
以下示例确保每周执行一次 SCAP 审计,并将结果发送到位于 proxy.example.com:9090 的代理。该示例将自动尝试在系统上安装 foreman_scap_client。如果您不希望使用政策的自定义文件,只需将空字符串传递给自定义变量。
---
- hosts: all
become: true
roles:
- theforeman.foreman_scap_client
vars:
foreman_scap_client_server: https://proxy.example.com
foreman_scap_client_port: 9090
foreman_scap_client_policies: [{
"id": "1",
"hour": "12",
"minute": "1",
"month": "*",
"monthday": "*",
"weekday": "1",
"profile_id": "",
"content_path": "/usr/share/xml/scap/ssg/fedora/ssg-fedora-ds.xml",
"download_path": "/compliance/policies/1/content",
"tailoring_path": "/var/lib/openscap/ssg-fedora-ds-tailored.xml",
"tailoring_download_path": "/compliance/policies/1/tailoring"
}]
}
与 foreman_openscap 一起使用
当与 foreman_openscap 一起使用该角色时,通常无需进一步配置,因为值来自 Foreman 的 ENC。然而,在导入角色后,请验证服务器、端口和政策的值;它们应启用覆盖,并且政策应为 <%= @host.policies_enc %>
测试
测试已设置为使用 Docker 在 Molecule 和 Testinfra 中运行。请确保安装依赖项:
pip install -r requirements.txt
检查当前用户是否能够在不使用 sudo 的情况下连接到 Docker。如果不能,请创建 Docker 组并将用户添加到该组。要运行测试,请使用:
molecule test
在 ansible-galaxy 上发布
Galaxy 从 GitHub 导入内容,并使用 git 标签进行 版本控制。Galaxy 期待标签采用语义版本格式。