Ansible AWS AutoScale group keep adding the desire server instead of update the correct number

Viewed 152

I am using Ansible latest version 2.0.1.0

I try to create new AWS autoscale config like this

- name: Update ASG with new LC and replace all instances
  ec2_asg:
    name: "{{ asg_name }}"
    launch_config_name: "{{ lc_name }}-{{ timestamp }}"
    health_check_period: 300
    health_check_type: ELB
    min_size: 1
    max_size: 5
    desired_capacity: 1
    region: "{{ aws_region }}"
    load_balancers: "{{ lb_name }}"
    vpc_zone_identifier: "{{ vpc_zones }}"
    tags:
      - Name: "{{ asg_name }}"
      - Environment: "{{ stack_env }}"
    replace_all_instances: yes

It creates the autoscale group, but when I rerun the playbook the number of min/max/desired instances in AWS autoscale group will be sum up to 2/5/6. Basically it will sum up the config inside AWS and the setting inside playbook.

The documentation of ec2_asg said it will replace/update the number inside the config. Did I miss something here?

Thank you!

Update

Because I am using replace_all_instances then Ansible will rolling replace all running instances in the ASG. But sometimes it got timeout when waiting new instance up then the playbook exit. So the number of min/max/desire number of instances in ASG was not updated to correct number.

0 Answers
Related