diff options
Diffstat (limited to 'tasks/plugins.yml')
-rw-r--r-- | tasks/plugins.yml | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/tasks/plugins.yml b/tasks/plugins.yml index c8f165c..84f3d49 100644 --- a/tasks/plugins.yml +++ b/tasks/plugins.yml | |||
@@ -3,16 +3,14 @@ | |||
3 | url: "{{ kong_app_admin_url }}/services/{{ kong_app_service_name }}/plugins" | 3 | url: "{{ kong_app_admin_url }}/services/{{ kong_app_service_name }}/plugins" |
4 | method: GET | 4 | method: GET |
5 | validate_certs: no | 5 | validate_certs: no |
6 | headers: | ||
7 | apikey: "{{ kong_app_admin_apikey }}" | ||
6 | register: kong_app_service_plugins_check | 8 | register: kong_app_service_plugins_check |
7 | 9 | ||
8 | - name: Set plugins facts | 10 | - name: Setup plugin |
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: | 11 | uri: |
14 | url: "{{ kong_app_admin_url }}/services/{{ kong_app_service_name }}/plugins" | 12 | url: "{{ kong_app_admin_url }}/{{ (current_config.id == '') | ternary('services/' ~ kong_app_service_name ~ '/plugins','plugins/' ~ current_config.id) }}" |
15 | method: "{{ (current_config == {}) | ternary ('POST', 'PATCH') }}" | 13 | method: "{{ (current_config.id == '') | ternary ('POST', 'PATCH') }}" |
16 | body: "{{ plugin | combine(current_body) | to_json }}" | 14 | body: "{{ plugin | combine(current_body) | to_json }}" |
17 | headers: | 15 | headers: |
18 | apikey: "{{ kong_app_admin_apikey }}" | 16 | apikey: "{{ kong_app_admin_apikey }}" |
@@ -22,7 +20,7 @@ | |||
22 | loop_control: | 20 | loop_control: |
23 | loop_var: plugin | 21 | loop_var: plugin |
24 | vars: | 22 | vars: |
25 | current_config: "{{ kong_app_current_plugins.data | selectattr('name', plugin.name) | first |default({}) }}" | 23 | current_config: "{{ kong_app_service_plugins_check.json.data | selectattr('name', 'equalto', plugin.name) | first |default({\"id\": ''}) }}" |
26 | current_id_hash: | 24 | current_id_hash: |
27 | id: "{{ current_config.id | default('')}}" | 25 | id: "{{ current_config.id }}" |
28 | current_body: "{{ (current_id_hash.id == '') | ternary({}, current_id_hash) }}" | 26 | current_body: "{{ (current_id_hash.id == '') | ternary({}, current_id_hash) }}" |