blob: aa2b2d9382a8c66e2ae8f7c873bf05e6b9b8a04b (
plain) (
tree)
|
|
---
- name: Build scoped path
set_fact:
rundeck_key_full_path: "{{ rundeck_keys_base_path }}/{{ item.path }}"
- name: Check key existence
uri:
url: "{{ rundeck_api_url }}/{{ rundeck_api_version }}/storage/keys/{{ rundeck_key_full_path }}"
method: GET
headers:
Accept: application/json
X-Rundeck-Auth-Token: "{{ rundeck_api_token }}"
status_code: [200, 404]
register: rundeck_existing_key
- name: Set method
set_fact:
rundeck_key_uri_method: "{{ (rundeck_existing_key.status == 404) | ternary('POST', 'PUT') }}"
- name: Import key
uri:
url: "{{ rundeck_api_url }}/{{ rundeck_api_version }}/storage/keys/{{ rundeck_key_full_path }}"
method: "{{ rundeck_key_uri_method }}"
headers:
Accept: application/json
Content-Type: "{{ item.type }}"
X-Rundeck-Auth-Token: "{{ rundeck_api_token }}"
status_code: [200, 201]
body: "{{ item.value }}"
body_format: raw
|