terminate.yml 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. ---
  2. - name: Terminate instance(s)
  3. hosts: localhost
  4. gather_facts: no
  5. vars_files:
  6. - vars.yml
  7. tasks:
  8. - set_fact: scratch_group=tag_env-host-type-{{ cluster_id }}-openshift-node
  9. - add_host:
  10. name: "{{ item }}"
  11. groups: oo_hosts_to_terminate, oo_nodes_to_terminate
  12. ansible_ssh_user: "{{ deployment_vars[deployment_type].ssh_user | default(ansible_ssh_user, true) }}"
  13. ansible_sudo: "{{ deployment_vars[deployment_type].sudo }}"
  14. with_items: groups[scratch_group] | default([]) | difference(['localhost']) | difference(groups.status_terminated)
  15. - set_fact: scratch_group=tag_env-host-type-{{ cluster_id }}-openshift-master
  16. - add_host:
  17. name: "{{ item }}"
  18. groups: oo_hosts_to_terminate, oo_masters_to_terminate
  19. ansible_ssh_user: "{{ deployment_vars[deployment_type].ssh_user | default(ansible_ssh_user, true) }}"
  20. ansible_sudo: "{{ deployment_vars[deployment_type].sudo }}"
  21. with_items: groups[scratch_group] | default([]) | difference(['localhost']) | difference(groups.status_terminated)
  22. - name: Unsubscribe VMs
  23. hosts: oo_hosts_to_terminate
  24. vars_files:
  25. - vars.yml
  26. roles:
  27. - role: rhel_unsubscribe
  28. when: deployment_type == "enterprise" and
  29. ansible_distribution == "RedHat" and
  30. lookup('oo_option', 'rhel_skip_subscription') | default(rhsub_skip, True) |
  31. default('no', True) | lower in ['no', 'false']
  32. - include: ../openshift-node/terminate.yml
  33. vars:
  34. gce_service_account_email: "{{ lookup('env', 'gce_service_account_email_address') }}"
  35. gce_pem_file: "{{ lookup('env', 'gce_service_account_pem_file_path') }}"
  36. gce_project_id: "{{ lookup('env', 'gce_project_id') }}"
  37. - include: ../openshift-master/terminate.yml
  38. vars:
  39. gce_service_account_email: "{{ lookup('env', 'gce_service_account_email_address') }}"
  40. gce_pem_file: "{{ lookup('env', 'gce_service_account_pem_file_path') }}"
  41. gce_project_id: "{{ lookup('env', 'gce_project_id') }}"