设置 Ansible 控制节点

要设置 Ansible 控制节点,请在 SUSE Multi-Linux Manager Web UI 中执行以下步骤。

过程:设置 Ansible 控制节点
  1. In the SUSE Multi-Linux Manager Web UI, navigate to Admin  Setup Wizard  Products, verify that SUSE Linux Enterprise Server 15 SP5 x86_64 and SUSE Multi-Linux Manager Client Tools for SLE 15 x86_64 are selected and synchronized.

  2. 部署一个 SUSE Linux Enterprise 15 SP5 客户端。

  3. In the SUSE Multi-Linux Manager Web UI, navigate to the Systems  Overview page of the client. Select Software  Software Channels and subscribe the client to the SUSE Linux Enterprise Server 15 SP5 x86_64 and SUSE Multi-Linux Manager Client Tools for SLE 15 x86_64 channels.

    SUSE Multi-Linux Manager 客户端工具包含 ansible 软件包。

  4. 选择客户端的细节  属性。在附加系统类型列表中启用 Ansible 控制节点,然后单击 更新属性

  5. 导航到客户端概览页面,选择状态  Highstate,然后单击 应用 Highstate

  6. 选择事件选项卡并校验 Highstate 的状态。

1. 安装 SCAP 安全指南软件包

要执行修复,您需要在 Ansible 控制节点上安装 SCAP 安全指南软件包。

过程:安装 SCAP 安全指南软件包
  1. 系统  概览中选择客户端。然后单击软件  软件包  安装

  2. 搜索 scap-security-guide 并安装适合您系统的软件包。有关软件包分发要求,请参见下表:

    Table 1. SCAP 安全指南软件包要求
    软件包名称 支持的系统

    scap-security-guide

    openSUSE、SLES12、SLES15

    scap-security-guide-redhat

    CentOS 7、CentOS 8、Fedora、Oracle Linux 7、Oracle Linux 8、RHEL7、RHEL8、RHEL9、Red Hat OpenStack Platform 10、Red Hat OpenStack Platform 13、Red Hat Virtualization 4、Scientific Linux

    scap-security-guide-debian

    Debian 12

    scap-security-guide-ubuntu

    Ubuntu 20.04、Ubuntu 22.04

2. 创建 Ansible 库存文件

Ansible 集成工具会将剧本部署为库存文件。请为表 1 中列出的每个操作系统创建一个库存文件。

过程:创建 Ansible 库存文件
  1. 创建主机并将其添加到由 Ansible 管理的库存文件。Ansible 库存的默认路径为 /etc/ansible/hosts

    Listing 1. 库存示例
    client240.mgr.example.org
    client241.mgr.example.org
    client242.mgr.example.org
    client243.mgr.example.org ansible_ssh_private_key_file=/etc/ansible/some_ssh_key
    
    [mygroup1]
    client241.mgr.example.org
    client242.mgr.example.org
    
    [mygroup2]
    client243.mgr.example.org
    
    [all:vars]
    ansible_ssh_private_key_file=/etc/ansible/my_ansible_private_key
  2. 在 SUSE Multi-Linux Manager Web UI 中的 Ansible 选项卡内,导航到 Ansible  控制节点,将库存文件添加到该控制节点中。

  3. 剧本目录部分下,将 /usr/share/scap-security-guide/ansible 添加到添加剧本目录字段中,然后单击 保存

  4. 库存文件下,将您的库存文件位置添加到添加库存文件字段,然后单击 保存

    Listing 2. 示例
    /etc/ansible/sles15
    /etc/ansible/sles12
    /etc/ansible/centos7

    有关更多剧本示例,请参见 https://github.com/ansible/ansible-examples

3. 与 Ansible 节点建立通信

过程:与 Ansible 节点建立通信
  1. 创建您要在库存中使用的 SSH 密钥。

    ssh-keygen -f /etc/ansible/my_ansible_private_key
  2. 将生成的 SSH 密钥复制到 Ansible 受管客户端。示例:

    ssh-copy-id -i /etc/ansible/my_ansible_private_key root@client240.mgr.example.org
  3. 如下所示在 /etc/ansible/ansible.cfg 中声明私用密钥:

    private_key_file = /etc/ansible/my_ansible_private_key

    请将 my_ansible_private_key 替换为包含私用密钥的文件的文件名。

  4. 通过从控制节点执行以下命令来测试 Ansible 是否正常运行:

    ansible all -m ping
    ansible mygroup1 -m ping
    ansible client240.mgr.example.org -m ping

现在您可以运行更新。有关详细信息,请参见 合规性即代码