在我的剧本中运行了几个剧本之后,我想验证我的应用程序的部署。
在我的一个角色中,我有以下任务,将创建的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
这是我的verify_deployment/tasks/main.yml
- name: Validate the deployment. Launched is my dynamically created host group
uri: url="https://{{ inventory_hostname }}:8000"
with_items: launched
我做错了什么?
答案 0 :(得分:2)
我不太确定您的问题是什么,但您的verify_deployment
角色不起作用,因为您使用inventory_hostname
变量而不是item
。你应该写一下:
- name: Validate the deployment. Launched is my dynamically created host group
uri: url="https://{{ item }}:8000"
with_items: launched