Skip to content

Instantly share code, notes, and snippets.

@joejulian
Last active June 2, 2017 22:49
Show Gist options
  • Select an option

  • Save joejulian/f5f84d4fb1fca833cf644cb7b21185aa to your computer and use it in GitHub Desktop.

Select an option

Save joejulian/f5f84d4fb1fca833cf644cb7b21185aa to your computer and use it in GitHub Desktop.
---
- 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