From a30ab86b4f2d2fa445df52bdacd27a26a07fd5d3 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Sun, 9 Oct 2022 13:04:02 +0200 Subject: [PATCH] destroy cluster and rename terraform to create-cluster --- .../tasks/{terraform.yml => create-cluster.yml} | 4 ---- scaleway-k8s/tasks/destroy-cluster.yml | 13 +++++++++++++ scaleway-k8s/tasks/main.yml | 8 ++++++-- 3 files changed, 19 insertions(+), 6 deletions(-) rename scaleway-k8s/tasks/{terraform.yml => create-cluster.yml} (91%) create mode 100644 scaleway-k8s/tasks/destroy-cluster.yml diff --git a/scaleway-k8s/tasks/terraform.yml b/scaleway-k8s/tasks/create-cluster.yml similarity index 91% rename from scaleway-k8s/tasks/terraform.yml rename to scaleway-k8s/tasks/create-cluster.yml index f584d14..4be7131 100644 --- a/scaleway-k8s/tasks/terraform.yml +++ b/scaleway-k8s/tasks/create-cluster.yml @@ -12,10 +12,6 @@ dest: "{{ project_terraform }}/main.tf" -- name: display plan terraform - debug: - var: output - - name: Create cluster scaleway community.general.terraform: project_path: '{{ project_terraform }}' diff --git a/scaleway-k8s/tasks/destroy-cluster.yml b/scaleway-k8s/tasks/destroy-cluster.yml new file mode 100644 index 0000000..a775c78 --- /dev/null +++ b/scaleway-k8s/tasks/destroy-cluster.yml @@ -0,0 +1,13 @@ +- name: "Destroy cluster via terraform" + community.general.terraform: + project_path: '{{ project_terraform }}' + state: absent + environment: + SCW_ACCESS_KEY: "{{ scw_access_key }}" + SCW_SECRET_KEY: "{{ scw_secret_key }}" + register: output + +- name: Remove directory + file: + path: '{{ project_terraform }}' + state: absent \ No newline at end of file diff --git a/scaleway-k8s/tasks/main.yml b/scaleway-k8s/tasks/main.yml index 8edb170..2c70873 100644 --- a/scaleway-k8s/tasks/main.yml +++ b/scaleway-k8s/tasks/main.yml @@ -1,7 +1,11 @@ - name: Create cluster k8s scaleway via terraform - ansible.builtin.import_tasks: terraform.yml + ansible.builtin.import_tasks: create-cluster.yml tags: ["create-cluster"] - name: Get id Cluster ansible.builtin.import_tasks: k8s.yml - tags: ["create-cluster", "api"] \ No newline at end of file + tags: ["create-cluster", "api"] + +- name: Destroy cluster k8s scaleway via terraform + ansible.builtin.import_tasks: destroy-cluster.yml + tags: ["destroy-cluster"] \ No newline at end of file