diff options
Diffstat (limited to 'tasks/routes.yml')
-rw-r--r-- | tasks/routes.yml | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tasks/routes.yml b/tasks/routes.yml new file mode 100644 index 0000000..1a9f6db --- /dev/null +++ b/tasks/routes.yml | |||
@@ -0,0 +1,32 @@ | |||
1 | - name: Get app routes | ||
2 | uri: | ||
3 | url: "{{ kong_app_admin_url }}/services/{{ kong_app_service_name }}/routes" | ||
4 | method: GET | ||
5 | validate_certs: no | ||
6 | register: kong_app_service_routes_check | ||
7 | |||
8 | - name: Set routes facts | ||
9 | set_fact: | ||
10 | kong_app_current_routes: "{{ kong_app_service_routes_check.json |default('{\"data\": []}') | from_json }}" | ||
11 | |||
12 | - name: Setup route | ||
13 | uri: | ||
14 | url: "{{ kong_app_admin_url }}/services/{{ kong_app_service_name }}/routes" | ||
15 | method: POST | ||
16 | body: "{{ route | to_json }}" | ||
17 | headers: | ||
18 | apikey: "{{ kong_app_admin_apikey }}" | ||
19 | Content-Type: application/json | ||
20 | status_code: 201 | ||
21 | with_items: "{{ kong_app_routes }}" | ||
22 | loop_control: | ||
23 | loop_var: route | ||
24 | |||
25 | - name: Delete old routes | ||
26 | uri: | ||
27 | url: "{{ kong_app_admin_url }}/services/routes/{{ item.id }}" | ||
28 | method: DELETE | ||
29 | headers: | ||
30 | apikey: "{{ kong_app_admin_apikey }}" | ||
31 | status_code: 204 | ||
32 | with_items: "{{ kong_app_current_routes.data }}" | ||