c12s-kubespray/tests/cloud_playbooks/delete-gce.yml

49 lines
1.5 KiB
YAML
Raw Normal View History

2016-02-10 10:51:39 +00:00
---
- hosts: localhost
become: false
2016-02-10 10:51:39 +00:00
gather_facts: no
vars:
mode: default
2016-02-10 10:51:39 +00:00
tasks:
- name: replace_test_id
set_fact:
test_name: "{{ test_id |regex_replace('\\.', '-') }}"
2016-02-10 10:51:39 +00:00
2019-05-16 07:27:43 +00:00
- name: set instance names
set_fact:
instance_names: >-
{%- if mode in ['separate', 'ha'] -%}
k8s-{{ test_name }}-1,k8s-{{ test_name }}-2,k8s-{{ test_name }}-3
{%- else -%}
k8s-{{ test_name }}-1,k8s-{{ test_name }}-2
{%- endif -%}
- name: stop gce instances
gce:
instance_names: "{{ instance_names }}"
image: "{{ cloud_image | default(omit) }}"
service_account_email: "{{ gce_service_account_email }}"
pem_file: "{{ gce_pem_file | default(omit) }}"
credentials_file: "{{ gce_credentials_file | default(omit) }}"
project_id: "{{ gce_project_id }}"
zone: "{{ cloud_region | default('europe-west1-b') }}"
state: 'stopped'
async: 120
poll: 3
register: gce
2016-02-10 10:51:39 +00:00
- name: delete gce instances
gce:
instance_names: "{{ instance_names }}"
image: "{{ cloud_image | default(omit) }}"
2016-02-10 10:51:39 +00:00
service_account_email: "{{ gce_service_account_email }}"
pem_file: "{{ gce_pem_file | default(omit) }}"
credentials_file: "{{ gce_credentials_file | default(omit) }}"
2016-02-10 10:51:39 +00:00
project_id: "{{ gce_project_id }}"
zone: "{{ cloud_region | default('europe-west1-b') }}"
2016-02-10 10:51:39 +00:00
state: 'absent'
async: 120
poll: 3
2016-02-10 10:51:39 +00:00
register: gce