Hi There, I am able to get the list of subnets for a VPC ID or tag name with the help of set_fact. While using the subnets (Subnet Output of set_fact) to create an ALB I am getting error as "load balancer cannot be attached to multiple subnets in the same availability zone"
Here is the playbook - name: Getting facts about subnet and VPC from an Instance with Tags ec2_instance_facts: filters: "tag:Name": AWX region: eu-west-1 register: output - name: displaying output debug: var=output.instances.0.vpc_id - name: Querying subnets from the vpc id ec2_vpc_subnet_facts: filters: vpc-id: "{{ output.instances.0.vpc_id }}" region: eu-west-1 register: subnetoutput - name : displaying subnet zone set_fact: subnetzone: "{{ subnetoutput.subnets | map(attribute='availability_zone') | list }}" register: subnetzoneout - name: displaying subnet id set_fact: subnetid: "{{ subnetoutput.subnets | map(attribute='subnet_id') | list }}" register: subnetidout - name: displaying subnetoutput set_fact: hostlist: "{{ subnetoutput.subnets | map(attribute='availability_zone') | list }}" register: subout - name: Creating Target Group elb_target_group: region: eu-west-1 name: DemoTargetGroup protocol: https port: 443 vpc_id: "{{ output.instances.0.vpc_id }}" health_check_path: / successful_response_codes: "{{response_codes}}" state: present register: tgoutput - name: Creating ALB elb_application_lb: name: DemoALB-new region: eu-west-1 security_groups: - sg-02a1426d scheme: internet-facing #zones: "{{ subout.ansible_facts.hostlist }}" subnets: "{{ subnetidout.ansible_facts.subnetid }}" # - "{{ subnetidout.ansible_facts.subnetid.0 }}" # - "{{ subnetidout.ansible_facts.subnetid.1 }}" Red marked not working but green working, I want to set the subnet-ID as dynamic not static -- 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/da1aa0d5-4d30-49b6-a80e-592aa0064085%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.