aboutsummaryrefslogtreecommitdiffhomepage
path: root/tasks/kong-app.yml
blob: 0d13b7fcacce19416091249a9204aa46fb3c1d82 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
- name: Upstream Creation
  import_tasks: upstream.yml
  when: service.upstream is defined

- 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: Update or Create service
  uri:
    url: "{{ server.kong_app_admin_url }}/services/{{ exists_service | ternary('', service.name) }}"
    method: "{{ exists_service | ternary('POST', 'PATCH') }}"
    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 }}"
  register: kong_service_creation_st

- name: set service id
  set-fact:
    kong_current_service_id: "{{ kong_service_creation_st.json.data.id }}"

- name: Setup plugins
  import_tasks: plugins.yml

- name: Setup routes
  import_tasks: routes.yml