remove_scale_group.yml 994 B

123456789101112131415161718192021222324252627282930
  1. ---
  2. # FIGURE OUT HOW TO REMOVE SCALE GROUPS
  3. # use openshift_aws_current_asgs??
  4. - name: fetch the scale groups
  5. ec2_asg_facts:
  6. region: "{{ openshift_aws_region }}"
  7. name: "^{{ item }}$"
  8. tags:
  9. "{{ {'kubernetes.io/cluster/' ~ openshift_aws_clusterid: openshift_aws_clusterid} }}"
  10. with_items: "{{ openshift_aws_current_asgs if openshift_aws_current_asgs != [] else openshift_aws_asgs_to_remove }}"
  11. register: qasg
  12. - name: remove non-master scale groups
  13. ec2_asg:
  14. region: "{{ openshift_aws_region }}"
  15. state: absent
  16. name: "{{ item.auto_scaling_group_name }}"
  17. when: "'master' not in item.auto_scaling_group_name"
  18. register: asg_results
  19. with_items: "{{ qasg | json_query('results[*]') | sum(attribute='results', start=[]) }}"
  20. async: 600
  21. poll: 0
  22. - name: join the asynch scale group removals
  23. async_status:
  24. jid: "{{ item.ansible_job_id }}"
  25. register: jobs_results
  26. with_items: "{{ asg_results.results }}"
  27. until: jobs_results.finished
  28. retries: 200