diff options
author | Gaëtan Duchaussois <gaetan.duchaussois@fretlink.com> | 2018-04-20 10:04:41 +0200 |
---|---|---|
committer | Gaëtan Duchaussois <gaetan.duchaussois@fretlink.com> | 2018-04-20 10:04:41 +0200 |
commit | 1a33ca3184dbea838ea083a7cf026cf5884dc3f4 (patch) | |
tree | c097cc0071eb765584897f1da6487702893ad6f8 /tasks/plugins.yml | |
parent | 530dddec969df385e9aa29af0917f6ca97094d68 (diff) | |
download | ansible-kong-app-1a33ca3184dbea838ea083a7cf026cf5884dc3f4.tar.gz ansible-kong-app-1a33ca3184dbea838ea083a7cf026cf5884dc3f4.tar.zst ansible-kong-app-1a33ca3184dbea838ea083a7cf026cf5884dc3f4.zip |
initial version
Diffstat (limited to 'tasks/plugins.yml')
-rw-r--r-- | tasks/plugins.yml | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tasks/plugins.yml b/tasks/plugins.yml new file mode 100644 index 0000000..c8f165c --- /dev/null +++ b/tasks/plugins.yml | |||
@@ -0,0 +1,28 @@ | |||
1 | - name: Get plugins | ||
2 | uri: | ||
3 | url: "{{ kong_app_admin_url }}/services/{{ kong_app_service_name }}/plugins" | ||
4 | method: GET | ||
5 | validate_certs: no | ||
6 | register: kong_app_service_plugins_check | ||
7 | |||
8 | - name: Set plugins facts | ||
9 | set_fact: | ||
10 | kong_app_current_plugins: "{{ kong_app_service_plugins_check.json | default('{}') | from_json }}" | ||
11 | |||
12 | - name: Setup plugin {{ plugin.name }} | ||
13 | uri: | ||
14 | url: "{{ kong_app_admin_url }}/services/{{ kong_app_service_name }}/plugins" | ||
15 | method: "{{ (current_config == {}) | ternary ('POST', 'PATCH') }}" | ||
16 | body: "{{ plugin | combine(current_body) | to_json }}" | ||
17 | headers: | ||
18 | apikey: "{{ kong_app_admin_apikey }}" | ||
19 | Content-Type: application/json | ||
20 | status_code: 200,201 | ||
21 | with_items: "{{ kong_app_plugins }}" | ||
22 | loop_control: | ||
23 | loop_var: plugin | ||
24 | vars: | ||
25 | current_config: "{{ kong_app_current_plugins.data | selectattr('name', plugin.name) | first |default({}) }}" | ||
26 | current_id_hash: | ||
27 | id: "{{ current_config.id | default('')}}" | ||
28 | current_body: "{{ (current_id_hash.id == '') | ternary({}, current_id_hash) }}" | ||