aboutsummaryrefslogtreecommitdiffhomepage
path: root/tasks/key.yml
diff options
context:
space:
mode:
Diffstat (limited to 'tasks/key.yml')
-rw-r--r--tasks/key.yml30
1 files changed, 30 insertions, 0 deletions
diff --git a/tasks/key.yml b/tasks/key.yml
new file mode 100644
index 0000000..aa2b2d9
--- /dev/null
+++ b/tasks/key.yml
@@ -0,0 +1,30 @@
1---
2- name: Build scoped path
3 set_fact:
4 rundeck_key_full_path: "{{ rundeck_keys_base_path }}/{{ item.path }}"
5
6- name: Check key existence
7 uri:
8 url: "{{ rundeck_api_url }}/{{ rundeck_api_version }}/storage/keys/{{ rundeck_key_full_path }}"
9 method: GET
10 headers:
11 Accept: application/json
12 X-Rundeck-Auth-Token: "{{ rundeck_api_token }}"
13 status_code: [200, 404]
14 register: rundeck_existing_key
15
16- name: Set method
17 set_fact:
18 rundeck_key_uri_method: "{{ (rundeck_existing_key.status == 404) | ternary('POST', 'PUT') }}"
19
20- name: Import key
21 uri:
22 url: "{{ rundeck_api_url }}/{{ rundeck_api_version }}/storage/keys/{{ rundeck_key_full_path }}"
23 method: "{{ rundeck_key_uri_method }}"
24 headers:
25 Accept: application/json
26 Content-Type: "{{ item.type }}"
27 X-Rundeck-Auth-Token: "{{ rundeck_api_token }}"
28 status_code: [200, 201]
29 body: "{{ item.value }}"
30 body_format: raw