运行自动化网格作业
自动化网格是可扩展的 Receptor 节点集群,用于执行 Ansible playbook。Ansible SDK 允许您直接在自动化网格中的节点上调用作业。
开始之前
- 安装 Ansible SDK 和所需软件。 
- 安装 Ansible Receptor。 
使用 examples/receptor_config 目录中的配置文件,创建本地运行的 Receptor 节点集群。
- 打开您的 - /etc/hosts文件进行编辑。
- 将以下条目添加到您的 - hosts文件中- 127.0.0.1 foo.example.com 127.0.0.1 bar.example.com 127.0.0.1 baz.example.com 
- 打开一个终端并启动第一个 Receptor 节点。 - 激活您的 Ansible SDK 虚拟环境。 - $ source env/bin/activate 
- 使用 - foo.yml配置启动节点。- $ receptor --config foo.yml 
 
- 打开一个新的终端并启动第二个 Receptor 节点。 - 激活您的 Ansible SDK 虚拟环境。 
- 使用 - bar.yml配置启动节点。- $ receptor --config bar.yml 
 
- 打开一个新的终端并启动第三个 Receptor 节点。 - 激活您的 Ansible SDK 虚拟环境。 
- 使用 - baz.yml配置启动节点。- $ receptor --config baz.yml 
 
- 验证自动化网格是否正在运行。 - $ receptorctl --socket /tmp/bar.sock status 
使用 Ansible SDK 在网格上运行示例自动化作业,如下所示
- 打开一个终端并切换到 - examples目录。
- 运行以下命令 - $ python example_mesh_job.py 
example_mesh_job.py 程序有一个 main() 函数,该函数连接到 Receptor 节点并运行 examples/datadir/project/pb.yml playbook。当 Ansible SDK 将以下内容打印到 stdout 时,您可以验证作业是否成功
submitting work
work submitted
payload builder completed ok
getting results
got results
waiting for jobs
job done: True, has <x> events
故障排除
如果您遇到此方案的问题,请按以下方式进行故障排除
- 确保已安装 - receptorctl。
- 确保您的 - /etc/hosts文件包含每个本地 Receptor 节点的条目。
- 确保在 Ansible SDK 虚拟环境中使用单独的终端运行每个 Receptor 节点。 
您可以在 故障排除 中找到更多帮助