Hi,
*Background:*
We are developing a system using a Microservices approach and deploying it
with Ansible 2.5.0.
I'm writing a site.yml playbook that will provision two Ubuntu 16.04
servers for each of eight different microservices. We're provisioning two
of each microservice for HA and we may increase that number in the future.
For example, here are the microservice instances I want to create grouped
by subnet (note this is not YAML):
SubNet-a:
MicroService-1-a
MicroService-2-a
:
:
MicroService-8-a
SubNet-b:
MicroService-1-b
MicroService-2-b
:
:
MicroService-8-b
Now I want to create a Target Group for each kind of microservice (e.g. one
for MicroService-1, one for Microservice-2, etc.). For example, here are
the target groups and their targets:
MicroService-1-TargetGroup:
MicroService-1-a
MicroService-1-b
MicroService-2-TargetGroup:
MicroService-2-a
MicroService-2-b
:
:
MicroService-8-TargetGroup:
MicroService-8-a
MicroService-8-b
I then want to set up my ALB (using the elb_application_lb module) so that
it has a *listener* with eight *rules* that route requests to the various
Target groups based on a *path_pattern* condition.
Here is an example *elb_target_group* with hard-coded targets (based on
Ansible's documentation on elb_target_groups):
- elb_target_group:
name: Microservice-1
protocol: http
port: 81
vpc_id: vpc-01234567
health_check_path: /
successful_response_codes: "200"
targets:* - Id: i-01234567
Port: 80
- Id: i-98765432
Port: 80*
state: present
wait_timeout: 200
wait: True
But since my site.yml playbook creates the EC2 instances, I won't have
access to the *instance_id*s referred to in the *Id* parameter above.
What is a good way of specifying the *targets* property of the
*elb_target_group* (above) such that it only includes all of the EC2
instances of a particular kind of microservice?
For example:
- elb_target_group:
name: *Microservice-1*
protocol: http
port: 81
vpc_id: vpc-01234567
health_check_path: /
successful_response_codes: "200,250-260"
targets: - Id: *< **Microservice-1-a's instance_id >*
Port: 80
- Id:* < **Microservice-2-a's instance_id >*
Port: 80
state: present
wait_timeout: 200
wait: True
Thanks!
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/4e9d9b34-f63f-43ac-a205-ae2aadafcebb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.