Browse Source

Merge pull request #10068 from mazzystr/uninstall-standalone-masters

Update uninstall_masters play to deal with standalone instances
OpenShift Merge Robot 6 years ago
parent
commit
1193505635

+ 2 - 2
playbooks/aws/openshift-cluster/uninstall_masters.yml

@@ -8,9 +8,9 @@
 
   - name: Alert user to variables needed - region
     debug:
-      msg: "openshift_aws_region={{ openshift_aws_region }}"
+      msg: "openshift_aws_region={{ openshift_aws_region | default('us-east-1') }}"
 
-- name: Delete the master node group
+- name: Delete the master instances
   hosts: localhost
   tasks:
   - name: delete masters

+ 10 - 0
roles/openshift_aws/tasks/uninstall_ec2.yml

@@ -0,0 +1,10 @@
+---
+- name: delete instance(s)
+  ec2:
+    instance_ids: "{{ item }}"
+    region: "{{ openshift_aws_region }}"
+    state: absent
+    wait: yes
+  delay: 3
+  retries: 3
+  with_items: "{{ instancesout.instances | list | map(attribute='instance_id') | list }}"

+ 13 - 7
roles/openshift_aws/tasks/uninstall_masters.yml

@@ -1,8 +1,14 @@
 ---
-- name: scale group deletion for master
-  include_tasks: uninstall_node_group.yml
-  with_items: "{{ openshift_aws_master_group }}"
-  vars:
-    l_node_group_config: "{{ openshift_aws_master_group_config }}"
-  loop_control:
-    loop_var: openshift_aws_node_group
+- name: fetch master instances
+  ec2_instance_facts:
+    region: "{{ openshift_aws_region }}"
+    filters:
+      "tag:clusterid": "{{ openshift_aws_clusterid }}"
+      "tag:host-type": "master"
+      instance-state-name: running
+  register: instancesout
+  retries: 20
+  delay: 3
+  until: instancesout.instances|length > 0
+
+- import_tasks: uninstall_ec2.yml