3 url: "{{ server.kong_app_admin_url }}/services/{{ service.name }}/plugins"
7 apikey: "{{ server.kong_app_admin_apikey }}"
8 register: kong_app_service_plugins_check
12 url: "{{ server.kong_app_admin_url }}/{{ exists_plugin | ternary(create_url, update_url) }}"
13 method: "{{ exists_plugin | ternary ('POST', 'PATCH') }}"
14 body: "{{ plugin | combine(current_body) | to_json }}"
16 apikey: "{{ server.kong_app_admin_apikey }}"
17 Content-Type: application/json
19 with_items: "{{ service.plugins | default([]) }}"
23 create_url: "services/{{ service.name }}/plugins"
24 update_url: "plugins/{{ current_config.id }}"
25 plugins_list: "{{ kong_app_service_plugins_check.json.data }}"
26 current_config: "{{ plugins_list | selectattr('name', 'equalto', plugin.name) | first |default({\"id\": ''}) }}"
28 id: "{{ current_config.id }}"
29 current_body: "{{ (not current_id_hash.id) | ternary({}, current_id_hash) }}"
30 exists_plugin: "{{ not current_id_hash.id }}"
31 when: not kong_app_service_plugins_check is skipped
34 register: kong_plugin_update_st
36 - name: Retry failed (deletion)
40 headers: "{{ headers }}"
42 loop: "{{ kong_plugin_update_st.results }}"
45 label: "{{ label_name }}"
47 method: "{{ result.invocation.module_args.method }}"
48 url: "{{ result.invocation.module_args.url }}"
49 headers: "{{ result.invocation.module_args.headers }}"
50 label_name: "{{ result.plugin.name }}"
52 - kong_plugin_update_st is failed
57 - name: Retry failed (recreation)
59 url: "{{ server.kong_app_admin_url }}/services/{{ service.name }}/plugins"
61 body: "{{ body | to_json }}"
62 headers: "{{ headers }}"
64 loop: "{{ kong_plugin_update_st.results }}"
67 label: "{{ label_name }}"
69 method: "{{ result.invocation.module_args.method }}"
70 headers: "{{ result.invocation.module_args.headers }}"
71 body: "{{ result.invocation.module_args.body }}"
72 label_name: "{{ result.plugin.name }}"
74 - kong_plugin_update_st is failed
79 - name: Give info on errors
82 loop: "{{ kong_plugin_update_st.results }}"
84 label: "{{ item.plugin.name }}"
86 - kong_plugin_update_st is failed
88 - item.plugin is defined
89 - item.plugin.name is defined
90 - item.json is defined
91 - item.json.message is defined
93 info: "{{ item.json.message }}"
95 - name: Fail otherwise
97 msg: "This plugin {{ result.plugin.name }} failed to be created"
98 loop: "{{ kong_plugin_update_st.results }}"
101 label: "{{ label_name }}"
103 method: "{{ result.invocation.module_args.method }}"
104 label_name: "{{ result.plugin.name }}"
106 - kong_plugin_update_st is failed