Ansible角色检查主机组的运行状况

Ansible角色检查主机组的运行状况,ansible,Ansible,在我的playbook中运行了几个剧本之后,我想验证我的应用程序的部署 在我的一个角色中,我有以下任务,将创建的ec2实例作为“已启动”添加到主机: - name: Add new instance to host group local_action: add_host hostname={{ item.public_ip }} groupname=launched with_items: ec2.instances 这是我的主要剧本,site.yml: ...... Run som

在我的playbook中运行了几个剧本之后,我想验证我的应用程序的部署

在我的一个角色中,我有以下任务,将创建的ec2实例作为“已启动”添加到主机:

- name: Add new instance to host group
  local_action: add_host hostname={{ item.public_ip }} groupname=launched
  with_items: ec2.instances
这是我的主要剧本,
site.yml

......
Run some plays for deployment and provisioning
......
# Validate the deployment by reaching from the local machine
- hosts: localhost
  connection: local
  roles:
  - validate_deployment
这是我的
验证部署/tasks/main.yml

- name: Validate the deployment. Launched is my dynamically created host group
  uri: url="https://{{ inventory_hostname }}:8000"
  with_items: launched 

我做错了什么?

我不太确定您的问题是什么,但是您的
验证部署
角色将不起作用,因为您使用
库存\u主机名
变量而不是
。你可能应该写:

- name: Validate the deployment. Launched is my dynamically created host group
  uri: url="https://{{ item }}:8000"
  with_items: launched 

您在哪里注册“已启动?”您想要什么样的操作?看看我编辑的帖子中的官方示例,它们反映了我是如何创建的。干杯当你运行这个时会发生什么?你有什么错误吗?一些意想不到的结果?