---
- name: Delete multiple routes in Kong API Gateway
hosts: localhost
gather_facts: false
tasks:
- name: Get all routes from Kong
uri:
url: "http://localhost:8001/routes"
method: GET
return_content: yes
status_code: 200
register: kong_routes
- name: Extract the list of route IDs to delete
set_fact:
route_ids: "{{ kong_routes.json.data | map(attribute='id') | list }}"
- name: Show the route IDs to delete
debug:
msg: "Route ID: {{ item }}"
loop: "{{ route_ids }}"
- name: Delete each route by its ID
uri:
url: "http://localhost:8001/routes/{{ item }}"
method: DELETE
status_code: 204
loop: "{{ route_ids }}"
when: item is defined
---
- name: Delete multiple services in Kong API Gateway
hosts: localhost
gather_facts: false
tasks:
- name: Get all services from Kong
uri:
url: "http://localhost:8001/services"
method: GET
return_content: yes
status_code: 200
register: kong_services
- name: Extract the list of route IDs to delete
set_fact:
service_ids: "{{ kong_services.json.data | map(attribute='id') | list }}"
- name: Show the service IDs to delete
debug:
msg: "Service ID: {{ item }}"
loop: "{{ service_ids }}"
- name: Delete each service by its ID
uri:
url: "http://localhost:8001/services/{{ item }}"
method: DELETE
status_code: 204
loop: "{{ service_ids }}"
when: item is defined