gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 00:14:18 31 4
gpt4 key购买 nike

在我的 playbook 中运行几次 Play 后,我想验证我的应用程序的部署。

在我的角色之一中,我有以下任务,将创建的 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

我做错了什么?

最佳答案

我不太确定您的问题是什么,但您的 verify_deployment 角色将不起作用,因为您使用 inventory_hostname 变量而不是 item.你可能应该写:

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

关于用于检查主机组运行状况的 Ansible 角色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30308552/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com