Hello,

I am trying to launch an ec2-instance, a classic load balancer and then 
register the ec2 instance under the load balancer. When I run the playbook, 
I see no errors and was able to successfully launch ec2 instance and the 
load balancer, but when I check the console, I do not see the ec2 instance 
registered under the load balancer. Below is my code. Please help me out of 
it. Thank you!


---
- name: spinning up an instance
  hosts: localhost
  connection: local
  gather_facts: False
  tasks:
    - name: spin up the webserver instance
      ec2:
        key_name: nv
        instance_tags: Name=instancexyz

        instance_type: t2.micro
        image: ami-0ff8a91507f77f867
        region: us-east-1
        vpc_subnet_id: subnet-5e076e03
        user_data: |
                   #!/bin/bash
                   sudo yum install httpd -y
                   sudo service httpd start
                   sudo echo "Instnace is up and running" >> 
/var/www/html/index.html
      register: ec2

    - name: wait for the servers to appear on the network
      wait_for: host={{ item.public_dns_name }} port=22 delay=10 
timeout=180 state=started
      with_items: ec2.tagged_instances

- name: spin up the load balancer and add the servers to it
  hosts: 127.0.0.1
  connection: local
  gather_facts: False
  tasks:
    - name: setup a simple load balancer
      ec2_elb_lb:
        name: elb-test-ELB
        state: present
        region: us-east-1
        zones:
          - us-east-1a
          - us-east-1d
        listeners:
          - protocol: http
            load_balancer_port: 80
            instance_port: 80
        health_check:
            ping_protocol: http # options are http, https, ssl, tcp
            ping_port: 80
            ping_path: /index.html
            response_timeout: 3 # seconds
            interval: 5 # seconds
            unhealthy_threshold: 2
            healthy_threshold: 3
      register: elb

- name: adding ec2 instance to elb
  hosts: localhost
  tasks:
    - name: Add each EC2 instance to the ELB
      ec2_elb:
        state: present
        ec2_elb: elb-test-ELB
        region: us-east-1
        instance_id: "{{ item.instance_id}}"
      with_items: ec2.tagged_instances





And this is the verbose output of the last play when I run this playbook. I 
do not see any details about success or failure


TASK [Add each EC2 instance to the ELB] 
****************************************
task path: /home/shashank/practice/test7.yml:55

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a6672ee6-e8c7-47dc-8ba8-4a38fc9b2651%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to