检查主机组健康状况的 Ansible 角色
Ansible Role to Check Health of a host group
在我的剧本中 运行 次播放后,我想验证我的应用程序的部署。
在我的一个角色中,我有以下任务,将创建的 ec2 实例添加到主机 'launched':
- 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
我做错了什么?
我不太确定你的问题是什么,但是你的 verify_deployment
角色将不起作用,因为你使用 inventory_hostname
变量而不是 item
。你应该写:
- name: Validate the deployment. Launched is my dynamically created host group
uri: url="https://{{ item }}:8000"
with_items: launched
在我的剧本中 运行 次播放后,我想验证我的应用程序的部署。
在我的一个角色中,我有以下任务,将创建的 ec2 实例添加到主机 'launched':
- 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
我做错了什么?
我不太确定你的问题是什么,但是你的 verify_deployment
角色将不起作用,因为你使用 inventory_hostname
变量而不是 item
。你应该写:
- name: Validate the deployment. Launched is my dynamically created host group
uri: url="https://{{ item }}:8000"
with_items: launched