]> git.immae.eu Git - github/fretlink/ansible-kong-app.git/blobdiff - tasks/kong-app.yml
tests: allow fake Kong server to receive PUT requests
[github/fretlink/ansible-kong-app.git] / tasks / kong-app.yml
index bff2f46dc06658d05f71c7a43f5a9a0e0595ba9f..3c51e7e3092a351341657864f66fc9c9e1a04cba 100644 (file)
@@ -1,23 +1,18 @@
-- name: Check if service exists
-  uri:
-    url: "{{ server.kong_app_admin_url }}/services/{{ service.name }}"
-    method: GET
-    headers:
-      apikey: "{{ server.kong_app_admin_apikey }}"
-    status_code: 200,404
-  register: kong_app_check_service
+- name: Upstream Creation
+  import_tasks: upstream.yml
+  when: service.upstream is defined
 
+# https://docs.konghq.com/2.1.x/admin-api/#update-or-create-service
 - name: Update or Create service
   uri:
-    url: "{{ server.kong_app_admin_url }}/services/{{ exists_service | ternary('', service.name) }}"
-    method: "{{ exists_service | ternary('POST', 'PATCH') }}"
+    url: "{{ server.kong_app_admin_url }}/services/{{ service.name }}"
+    method: PUT
     body: "{{ service_body | to_json }}"
     status_code: 200,201
     headers:
       apikey: "{{ server.kong_app_admin_apikey }}"
       Content-Type: application/json
   vars:
-    exists_service: "{{ kong_app_check_service.status|default(404) == 404 }}"
     service_body:
       name: "{{ service.name }}"
       url: "{{ service.url }}"