Last active
June 2, 2017 22:49
-
-
Save joejulian/f5f84d4fb1fca833cf644cb7b21185aa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| - set_fact: | |
| nodepool: "{{ a_nodepool }}" | |
| - name: Set Expected Node Count | |
| set_fact: | |
| expected_node_count: "{{ nodepool.count }}" | |
| - name: Collect nodes | |
| command: > | |
| {{ kubectl }} --kubeconfig={{ kubeconfig }} get nodes -l nodepool={{ nodepool.name }} -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | |
| register: node_names | |
| - name: Delete and Terminate Nodes | |
| set_fact: | |
| node_destruction: "{{ item.0 | delete_and_terminate_node_filter( item.1, expected_node_count, kubeconfig, aws_region, nodepool.name ) }}" | |
| with_together: | |
| - "{{ instance_info.instances | map(attribute='private_dns_name') | list }}" | |
| - "{{ instance_info.instances | map(attribute='id') | list }}" | |
| when: item.0 in nodes | |
| vars: | |
| nodes: "{{ node_names.stdout_lines }}" | |
| failed_when: node_destruction == False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment