--- - debug: msg="Working on service {{ item.service.name }}" - set_fact: body_create_svc: '{{ "access_token=" ~ access_token|urlencode }}' - set_fact: body_create_svc: '{{ body_create_svc ~ "&" ~ (param.key|urlencode) ~ "=" ~ (param.value|urlencode) }}' with_dict: '{{ item.service }}' loop_control: loop_var: param when: 'item.service.system_name not in services' - name: Create the service uri: url: https://{{ threescale_admin_hostname }}/admin/api/services.json validate_certs: no method: POST body: '{{ body_create_svc }}' status_code: 201 register: response when: 'item.service.system_name not in services' - set_fact: services: '{{ services|union([ item.service.system_name ]) }}' services_details: '{{ services_details|union([{ "system_name": item.service.system_name, "id": response.json.service.id }]) }}' when: 'item.service.system_name not in services' - set_fact: service_id: '{{ (services_details|selectattr("system_name", "equalto", item.service.system_name)|first)["id"] }}' - set_fact: body_update_proxy: '{{ "access_token=" ~ access_token|urlencode }}' - set_fact: body_update_proxy: '{{ body_update_proxy ~ "&" ~ (param.key|urlencode) ~ "=" ~ (param.value|urlencode) }}' with_dict: '{{ item.proxy }}' loop_control: loop_var: param - name: Set Backend URL set_fact: body_update_proxy: '{{ body_update_proxy ~ "&api_backend" ~ "=" ~ (item.backend|urlencode) }}' - name: Update the proxy uri: url: https://{{ threescale_admin_hostname }}/admin/api/services/{{ service_id }}/proxy.json validate_certs: no method: PATCH body: '{{ body_update_proxy }}' - name: Get the list of existing application plans uri: url: https://{{ threescale_admin_hostname }}/admin/api/services/{{ service_id }}/application_plans.json?access_token={{ access_token|urlencode }} validate_certs: no register: response - set_fact: application_plans: '{{ response.json|json_query(''plans[*].application_plan.system_name'') }}' application_plans_details: '{{ response.json|json_query(''plans[].{"system_name": application_plan.system_name, "id": application_plan.id}'') }}' - include: create_application_plan.yml with_items: '{{ item.application_plans }}' loop_control: loop_var: plan