1.2. 配置部署以运行 Ansible 角色
在 Satellite 中,您可以导入 Ansible 角色来帮助自动化日常任务。在 Satellite 服务器上默认启用 Ansible。
Ansible 路径
Satellite 根据 /etc/ansible/ansible.cfg
中的配置从路径导入 Ansible 角色变量。然后,Satellite 根据 /etc/foreman-proxy/ansible.cfg
中的配置从路径运行导入的角色。在这两种情况下,Satellite 从 roles_path
和 collections_paths
指令读取路径。将这两个 cfg 文件保持同步,否则您可以导入无法运行的角色,否则您不会看到您可以运行的角色。
如果在配置文件中没有指定任何路径,则会使用以下默认路径:
-
/etc/ansible/roles
-
/usr/share/ansible/roles
-
/etc/ansible/collections
-
/usr/share/ansible/collections
流程
- 在 Satellite 服务器和您要使用角色的所有 Capsule 服务器中配置 Ansible 路径。
- 将角色添加到 Satellite 服务器上的 Ansible 路径中 的目录,以及您要使用该角色的所有 Capsule 服务器。如果要使用自定义或第三方 Ansible 角色,请确保配置外部版本控制系统,以在 Satellite 服务器和 Capsule 服务器之间同步角色。
在您要用来在主机上运行 Ansible 角色的所有 Capsule 服务器上,启用 Ansible 插件:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow satellite-installer --scenario capsule \ --enable-foreman-proxy-plugin-ansible
# satellite-installer --scenario capsule \ --enable-foreman-proxy-plugin-ansible
- 分发 SSH 密钥,使胶囊能够使用 SSH 连接到主机。如需更多信息,请参阅 管理主机 中的 为远程执行分配 SSH 密钥。Satellite 运行 Ansible 角色的方式与运行远程执行任务相同。
- 将 Ansible 角色导入到 Satellite。
- 继续 第 2 章 使用 Ansible 角色在 Satellite 主机上自动化重复任务。