From d213edd127a145821e419e80104a838da421e7ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Duchaussois?= Date: Fri, 20 Apr 2018 14:40:33 +0200 Subject: add travis configuration and fix tests --- tasks/kong-app.yml | 6 ++++-- tasks/plugins.yml | 6 ++++-- tasks/routes.yml | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'tasks') diff --git a/tasks/kong-app.yml b/tasks/kong-app.yml index e162c09..df95f2e 100644 --- a/tasks/kong-app.yml +++ b/tasks/kong-app.yml @@ -9,13 +9,15 @@ - name: Update or Create service uri: - url: "{{ kong_app_admin_url }}/services/{{ (kong_app_check_service.status == 404) | ternary('', kong_app_service_name) }}" - method: "{{ (kong_app_check_service.status == 404) | ternary('POST', 'PATCH') }}" + url: "{{ kong_app_admin_url }}/services/{{ exists_service | ternary('', kong_app_service_name) }}" + method: "{{ exists_service | ternary('POST', 'PATCH') }}" body: "{{ kong_app_service_body | to_json }}" status_code: 200,201 headers: apikey: "{{ kong_app_admin_apikey }}" Content-Type: application/json + vars: + exists_service: "{{ kong_app_check_service.status|default(404) == 404 }}" - name: Setup plugins import_tasks: plugins.yml diff --git a/tasks/plugins.yml b/tasks/plugins.yml index 84f3d49..c03bca7 100644 --- a/tasks/plugins.yml +++ b/tasks/plugins.yml @@ -9,8 +9,8 @@ - name: Setup plugin uri: - 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') }}" + url: "{{ kong_app_admin_url }}/{{ exists_plugin | ternary('services/' ~ kong_app_service_name ~ '/plugins','plugins/' ~ current_config.id) }}" + method: "{{ exists_plugin | ternary ('POST', 'PATCH') }}" body: "{{ plugin | combine(current_body) | to_json }}" headers: apikey: "{{ kong_app_admin_apikey }}" @@ -24,3 +24,5 @@ current_id_hash: id: "{{ current_config.id }}" current_body: "{{ (current_id_hash.id == '') | ternary({}, current_id_hash) }}" + exists_plugin: "{{ current_id_hash.id == '' }}" + when: not kong_app_service_plugins_check|skipped diff --git a/tasks/routes.yml b/tasks/routes.yml index bbcdb76..d4d912f 100644 --- a/tasks/routes.yml +++ b/tasks/routes.yml @@ -28,3 +28,4 @@ apikey: "{{ kong_app_admin_apikey }}" status_code: 204 with_items: "{{ kong_app_service_routes_check.json.data }}" + when: not kong_app_service_routes_check|skipped -- cgit v1.2.3