5.2. 为主机配置置备回调
在 Satellite 中创建主机时,您可以使用 Ansible Automation Platform 运行 playbook 来配置新创建的主机。这在 Ansible Automation Platform 中称为 置备回调。
置备回调功能会触发从 Ansible Automation Platform 运行 playbook,作为置备过程的一部分。playbook 在置备过程后配置主机。
有关置备回调的更多信息,请参阅 Red Hat Ansible Automation Platform 文档中的 置备回调。
在 Satellite 服务器中,Kickstart Default 和 Kickstart Default Finish 模板包括三个片断:
-
ansible_provisioning_callback -
ansible_tower_callback_script -
ansible_tower_callback_service
您可以将参数添加到主机或主机组,以提供这些片断可用于在新创建的主机上运行 Ansible playbook 的凭据。
先决条件
在配置置备回调前,您必须在 Ansible Automation Platform 中添加 Satellite 作为动态清单。如需更多信息,请参阅 集成 Satellite 和 Ansible Automation Platform。
在 Ansible Automation Platform Web UI 中,您必须完成以下任务:
流程
- 在 Satellite Web UI 中,进入到 Configure > Host Group。
- 创建主机组或编辑现有主机组。
- 在主机组窗口中,单击 参数 选项卡。
- 单击 Add Parameter。
为每个新参数输入以下信息:
Expand 表 5.3. 主机参数 Name 值 Description ansible_tower_provisioningtrue
启用部署回调。
ansible_tower_fqdnaap.example.com
Ansible Automation Platform 的完全限定域名(FQDN)。不要添加
https,因为这由 Satellite 附加。ansible_job_template_idtemplate_ID
您可以在模板的 URL 中找到的置备模板的 ID:
/templates/job_template/5。ansible_host_config_keyconfig_KEY
作业模板在 Ansible Automation Platform 中生成的主机配置密钥。
- 点 Submit。
- 使用主机组创建主机。
在新主机上,输入以下命令启动
ansible-callback服务:# systemctl start ansible-callback在新主机上,输入以下命令输出
ansible-callback服务的状态:# systemctl status ansible-callback如果命令返回以下输出,则会正确配置置备回调:
SAT_host systemd[1]: Started Provisioning callback to Ansible Automation Platform...
手动置备回调
您可以使用主机的置备回调 URL 和主机配置密钥来调用 Ansible Automation Platform:
# curl -k -s --data curl --insecure --data host_config_key=my_config_key \ https://aap.example.com/api/v2/job_templates/8/callback/在进入置备回调 URL 时,请确保使用
https。
这会触发针对主机的模板中指定的 playbook 运行。