]>
Commit | Line | Data |
---|---|---|
1a33ca31 GD |
1 | - name: Get plugins |
2 | uri: | |
767c0e53 | 3 | url: "{{ kong_app_admin_url }}/services/{{ service.name }}/plugins" |
1a33ca31 GD |
4 | method: GET |
5 | validate_certs: no | |
ad5e125a GD |
6 | headers: |
7 | apikey: "{{ kong_app_admin_apikey }}" | |
1a33ca31 GD |
8 | register: kong_app_service_plugins_check |
9 | ||
ad5e125a | 10 | - name: Setup plugin |
1a33ca31 | 11 | uri: |
767c0e53 | 12 | url: "{{ kong_app_admin_url }}/{{ exists_plugin | ternary('services/' ~ service.name ~ '/plugins','plugins/' ~ current_config.id) }}" |
d213edd1 | 13 | method: "{{ exists_plugin | ternary ('POST', 'PATCH') }}" |
1a33ca31 GD |
14 | body: "{{ plugin | combine(current_body) | to_json }}" |
15 | headers: | |
16 | apikey: "{{ kong_app_admin_apikey }}" | |
17 | Content-Type: application/json | |
18 | status_code: 200,201 | |
767c0e53 | 19 | with_items: "{{ service.plugins | default([]) }}" |
1a33ca31 GD |
20 | loop_control: |
21 | loop_var: plugin | |
22 | vars: | |
ad5e125a | 23 | current_config: "{{ kong_app_service_plugins_check.json.data | selectattr('name', 'equalto', plugin.name) | first |default({\"id\": ''}) }}" |
1a33ca31 | 24 | current_id_hash: |
ad5e125a | 25 | id: "{{ current_config.id }}" |
1a33ca31 | 26 | current_body: "{{ (current_id_hash.id == '') | ternary({}, current_id_hash) }}" |
d213edd1 | 27 | exists_plugin: "{{ current_id_hash.id == '' }}" |
0682b865 | 28 | when: not kong_app_service_plugins_check is skipped |