From 30d3b2bfee95eb816c4d9843ddfb587d3ad69edc Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Sun, 9 Oct 2022 13:27:16 +0200 Subject: [PATCH] download kubeconfig --- scaleway-k8s/tasks/k8s.yml | 16 ---------------- scaleway-k8s/tasks/kubeconfig.yml | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 16 deletions(-) delete mode 100644 scaleway-k8s/tasks/k8s.yml create mode 100644 scaleway-k8s/tasks/kubeconfig.yml diff --git a/scaleway-k8s/tasks/k8s.yml b/scaleway-k8s/tasks/k8s.yml deleted file mode 100644 index fc13648..0000000 --- a/scaleway-k8s/tasks/k8s.yml +++ /dev/null @@ -1,16 +0,0 @@ -- name: Get id of cluster - ansible.builtin.uri: - url: https://api.scaleway.com/k8s/v1/regions/fr-par/clusters - status_code: 200 - return_content: yes - method: GET - headers: - X-Auth-Token: "{{ scw_secret_key }}" - register: output - -- name: Display content GET scaleway - debug: - msg: "{{ item }}" - with_items: "{{ output.content |to_json }}" - -# | from_json | community.general.json_query('clusters[*]') \ No newline at end of file diff --git a/scaleway-k8s/tasks/kubeconfig.yml b/scaleway-k8s/tasks/kubeconfig.yml new file mode 100644 index 0000000..a579457 --- /dev/null +++ b/scaleway-k8s/tasks/kubeconfig.yml @@ -0,0 +1,21 @@ +- name: Get id of cluster + ansible.builtin.uri: + url: https://api.scaleway.com/k8s/v1/regions/fr-par/clusters + status_code: 200 + return_content: yes + method: GET + headers: + X-Auth-Token: "{{ scw_secret_key }}" + register: output + +- name: Download kubeconfig + ansible.builtin.uri: + url: "https://api.scaleway.com/k8s/v1/regions/fr-par/clusters/{{ item.id }}/kubeconfig?dl=1" + status_code: 200 + dest: "{{ project_terraform }}/kubeconfig" + method: GET + headers: + X-Auth-Token: "{{ scw_secret_key }}" + when: item.name == "terraform-test" + with_items: "{{ (output.content |from_json).clusters }}" + \ No newline at end of file