aboutsummaryrefslogblamecommitdiffhomepage
path: root/tasks/plugins.yml
blob: 84f3d49e7f60d77cf396156792c054d85887a145 (plain) (tree)
1
2
3
4
5
6
7
8
9




                                                                                

                                           

                                          
                    
      

                                                                                                                                                              








                                                           
                                                                                                                                                
                    
                                   
                                                                                   
- name: Get plugins
  uri:
    url: "{{ kong_app_admin_url }}/services/{{ kong_app_service_name }}/plugins"
    method: GET
    validate_certs: no
    headers:
      apikey: "{{ kong_app_admin_apikey }}"
  register: kong_app_service_plugins_check

- name: Setup plugin
  uri:
    url: "{{ kong_app_admin_url }}/{{ (current_config.id == '') | ternary('services/' ~ kong_app_service_name ~ '/plugins','plugins/' ~ current_config.id) }}"
    method: "{{ (current_config.id == '') | ternary ('POST', 'PATCH') }}"
    body: "{{ plugin | combine(current_body)  | to_json }}"
    headers:
      apikey: "{{ kong_app_admin_apikey }}"
      Content-Type: application/json
    status_code: 200,201
  with_items: "{{ kong_app_plugins }}"
  loop_control:
    loop_var: plugin
  vars:
    current_config: "{{ kong_app_service_plugins_check.json.data | selectattr('name', 'equalto', plugin.name) | first |default({\"id\": ''}) }}"
    current_id_hash:
      id: "{{ current_config.id }}"
    current_body: "{{ (current_id_hash.id == '') | ternary({}, current_id_hash) }}"