Strong role for validating the health of a host group

After running a few plays in my book, I want to test the deployment of my applications.

In one of my roles, I have the following task, add the created ec2 instances to the hosts as "running":

- name: Add new instance to host group
  local_action: add_host hostname={{ item.public_ip }} groupname=launched
  with_items: ec2.instances

      

That's my main piece, 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

      

Here is my 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 

      

What am I doing wrong?

+3


source to share


1 answer


I'm not entirely sure about your problem, but your role verify_deployment

won't work as a item

variable is used instead inventory_hostname

. You should probably write:



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

      

+2


source







All Articles