Autoscaling

The final role in our playbook creates a launch configuration and then creates/updates an autoscaling group to finally launch our instances. It then does a tiny bit of housekeeping. To create the role, run:

$ ansible-galaxy init roles/autoscaling

First of all, there are a few default variables we need to set in roles/autoscaling/default/main.yml; these details show how many instances we want running at any one time, and also how many instances we replace at a time when doing a deployment of a new AMI:

min_size: 2max_size: 9desired_capacity: 3replace_size: 2health_check_type: ELBassign_public_ip: yesec2_instance_type: "t2.micro"

What those variables are saying is that we want three instances running at all times, so if there are ...

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.