---
- name: Deploy Kong Plugins
hosts: kong_servers
vars:
plugin_configs_path: "/path/to/plugin/configs/"
tasks:
- name: Read JSON configuration files
find:
paths: "{{ plugin_configs_path }}"
patterns: "*.json"
register: json_files
- name: Apply Kong plugins configuration
uri:
url: "http://localhost:8001/plugins/"
method: POST
body: "{{ lookup('file', item.path) | from_json }}"
body_format: json
with_items: "{{ json_files.files }}"
register: plugin_results
- name: Display results
debug:
var: plugin_results
second playbook
---
- name: Deploy Kong Rate Limiting Plugin
hosts: localhost
tasks:
- name: Deploy Kong Rate Limiting Plugin
uri:
url: "http://localhost:8001/services/238feb34-597a-44c1-a797-5001ef0d2aba/plugins"
method: POST
headers:
Content-Type: "application/json"
body: "{{ lookup('file', 'rate_limit_plugin.json') }}"
status_code: 201
body_format: json
json file
[root@instance-test-luks co]# more rate_limit_plugin.json
{
"name": "rate-limiting",
"config": {
"minute": 20,
"hour": 100,
"day": 2000
}
}