3.4. 从 Automation Hub 安装 Collections
如果使用 Automation Hub,您可以安装托管在 Automation Hub 上的 RHEL 系统角色集合。
先决条件
- 访问一个或多个 受管节点。
对 控制节点 的访问和权限,这是 Red Hat Ansible Core 配置其他系统的系统。
在控制节点上:
-
ansible-core和rhel-system-roles软件包已安装 。 - 列出受管节点的清单文件。
-
流程
-
定义 Red Hat Automation Hub 作为
ansible.cfg配置文件中内容的默认源。请参阅 将 Red Hat Automation Hub 配置为内容的主源。 从 Automation Hub 安装
redhat.rhel_system_roles集合:ansible-galaxy collection install redhat.rhel_system_roles
# ansible-galaxy collection install redhat.rhel_system_rolesCopy to Clipboard Copied! Toggle word wrap Toggle overflow 安装完成后,角色作为
redhat.rhel_system_roles.<role_name>提供。另外,您可以在/usr/share/ansible/collections/ansible_collections/redhat/rhel_system_roles/roles/<role_name>/README.md找到每个角色的文档。
验证步骤
要验证安装,请在 localhost 上以 check 模式运行 kernel_settings 角色。您还必须使用 --become 参数,因为对于 Ansible package 模块,它是必需的。但是,该参数不会更改您的系统:
运行以下命令:
ansible-playbook -c local -i localhost, --check --become /usr/share/ansible/collections/ansible_collections/redhat/rhel_system_roles/tests/kernel_settings/tests_default.yml
$ ansible-playbook -c local -i localhost, --check --become /usr/share/ansible/collections/ansible_collections/redhat/rhel_system_roles/tests/kernel_settings/tests_default.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
命令输出的最后一行应包含值 failed=0。
localhost 之后的逗号是必需的。即使列表中只有一个主机,您页必须添加它。如果没有它,ansible-playbook 会将 localhost 识别为文件或目录。