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