You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
2.4 KiB
67 lines
2.4 KiB
---
|
|
|
|
- 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" ~ "=" ~ (threescale_backend_map[item.backend]|urlencode) }}'
|
|
when: 'item.backend in threescale_backend_map'
|
|
|
|
- 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
|
|
|