From ad5e125af59a34020943158999564af4f3a41a59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Duchaussois?= Date: Fri, 20 Apr 2018 12:14:40 +0200 Subject: After testing --- tasks/plugins.yml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'tasks/plugins.yml') 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 @@ url: "{{ kong_app_admin_url }}/services/{{ kong_app_service_name }}/plugins" method: GET validate_certs: no + headers: + apikey: "{{ kong_app_admin_apikey }}" register: kong_app_service_plugins_check -- name: Set plugins facts - set_fact: - kong_app_current_plugins: "{{ kong_app_service_plugins_check.json | default('{}') | from_json }}" - -- name: Setup plugin {{ plugin.name }} +- name: Setup plugin uri: - url: "{{ kong_app_admin_url }}/services/{{ kong_app_service_name }}/plugins" - method: "{{ (current_config == {}) | ternary ('POST', 'PATCH') }}" + url: "{{ kong_app_admin_url }}/{{ (current_config.id == '') | ternary('services/' ~ kong_app_service_name ~ '/plugins','plugins/' ~ current_config.id) }}" + method: "{{ (current_config.id == '') | ternary ('POST', 'PATCH') }}" body: "{{ plugin | combine(current_body) | to_json }}" headers: apikey: "{{ kong_app_admin_apikey }}" @@ -22,7 +20,7 @@ loop_control: loop_var: plugin vars: - current_config: "{{ kong_app_current_plugins.data | selectattr('name', plugin.name) | first |default({}) }}" + current_config: "{{ kong_app_service_plugins_check.json.data | selectattr('name', 'equalto', plugin.name) | first |default({\"id\": ''}) }}" current_id_hash: - id: "{{ current_config.id | default('')}}" + id: "{{ current_config.id }}" current_body: "{{ (current_id_hash.id == '') | ternary({}, current_id_hash) }}" -- cgit v1.2.3