The ELB role

The final role we are going to look at in this chapter is one which launches an Application Load Balancer. Well, it creates a target group which is then attached to an Application Load Balancer. The load balancer we will be creating with this role is basic; we will be going into a lot more detail in the later chapter.

Like the other roles, we first need to bootstrap the files:

$ ansible-galaxy init roles/elb

Now open roles/elb/tasks/main.yml and use the elb_target_group module to create the target group:

- name: provision the target group  elb_target_group:    name: "{{ environment_name }}-target-group"    region: "{{ ec2_region }}"    protocol: "http"    port: "80"    deregistration_delay_timeout: "15"    vpc_id: "{{ vpc_info.vpc.id }}" state: ...

Get Learn Ansible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.