Browse Source

#40: improve the galaxy quality score

pull/50/head
Nicolas Massé 7 years ago
parent
commit
d45f90517a
  1. 1
      support/docker/install.yaml
  2. 3
      support/jenkins/jenkins-slave-template-centos.yaml
  3. 18
      tasks/api-calls/create_activedoc.yml
  4. 7
      tasks/api-calls/create_application.yml
  5. 18
      tasks/api-calls/create_application_plan.yml
  6. 4
      tasks/api-calls/create_mapping_rule.yml
  7. 18
      tasks/api-calls/create_method.yml
  8. 18
      tasks/api-calls/create_service.yml
  9. 11
      tasks/api-calls/delete_mapping_rule.yml
  10. 8
      tasks/api-calls/delete_metric.yml
  11. 7
      tasks/api-calls/find_application.yml
  12. 5
      tasks/api-calls/find_first_account.yml
  13. 31
      tasks/api-calls/get_proxy_version.yml
  14. 6
      tasks/api-calls/keycloak/authenticate.yml
  15. 4
      tasks/api-calls/keycloak/patch_client.yml
  16. 5
      tasks/api-calls/keycloak/wait_for_client.yml
  17. 9
      tasks/api-calls/promote_proxy.yml
  18. 4
      tasks/api-calls/update_activedoc.yml
  19. 11
      tasks/api-calls/update_application.yml
  20. 10
      tasks/api-calls/update_application_plan.yml
  21. 4
      tasks/api-calls/update_mapping_rule.yml
  22. 9
      tasks/api-calls/update_method.yml
  23. 4
      tasks/api-calls/update_policies.yml
  24. 4
      tasks/api-calls/update_proxy.yml
  25. 4
      tasks/api-calls/update_service.yml
  26. 12
      tasks/cleanup.yaml
  27. 2
      tasks/main.yml
  28. 11
      tasks/steps/ansible_requirements.yml
  29. 1
      tasks/steps/application_plan.yml
  30. 6
      tasks/steps/default_application.yml
  31. 52
      tasks/steps/discover.yml
  32. 8
      tasks/steps/find_goswagger.yml
  33. 8
      tasks/steps/install_goswagger.yml
  34. 11
      tasks/steps/mapping_rules.yml
  35. 14
      tasks/steps/methods.yml
  36. 8
      tasks/steps/policies.yml
  37. 22
      tasks/steps/read_openapi.yml
  38. 6
      tasks/steps/requirements.yml
  39. 2
      tasks/steps/smoke_test.yml
  40. 2
      tasks/steps/validate_openapi.yml
  41. 19
      tasks/steps/variables_from_inventory.yml
  42. 1
      tests/setup/delete-travis-logs.yml

1
support/docker/install.yaml

@ -1,4 +1,3 @@
- name: Install the pre-requisites - name: Install the pre-requisites
hosts: localhost hosts: localhost
gather_facts: no gather_facts: no

3
support/jenkins/jenkins-slave-template-centos.yaml

@ -29,7 +29,6 @@ objects:
- name: latest - name: latest
annotations: annotations:
role: jenkins-slave role: jenkins-slave
- apiVersion: v1 - apiVersion: v1
kind: ImageStream kind: ImageStream
metadata: metadata:
@ -44,7 +43,6 @@ objects:
name: docker.io/openshift/jenkins-slave-base-centos7:${OPENSHIFT_VERSION} name: docker.io/openshift/jenkins-slave-base-centos7:${OPENSHIFT_VERSION}
importPolicy: importPolicy:
scheduled: true scheduled: true
- apiVersion: v1 - apiVersion: v1
kind: BuildConfig kind: BuildConfig
metadata: metadata:
@ -89,4 +87,3 @@ objects:
triggers: triggers:
- type: ConfigChange - type: ConfigChange
- type: ImageChange - type: ImageChange

18
tasks/api-calls/create_activedoc.yml

@ -3,7 +3,7 @@
- debug: - debug:
var: threescale_cicd_create_activedoc_payload var: threescale_cicd_create_activedoc_payload
verbosity: 1 verbosity: 1
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
- name: Create the ActiveDocs - name: Create the ActiveDocs
uri: uri:
@ -14,11 +14,19 @@
status_code: 201 status_code: 201
register: threescale_cicd_tmpresponse register: threescale_cicd_tmpresponse
changed_when: 'threescale_cicd_tmpresponse.status == 201' changed_when: 'threescale_cicd_tmpresponse.status == 201'
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
- set_fact: - name: Store the list of existing ActiveDocs as fact
threescale_cicd_existing_activedocs: '{{ threescale_cicd_existing_activedocs|union([ threescale_cicd_tmpresponse.json.api_doc.system_name ]) }}' set_fact:
threescale_cicd_existing_activedocs_details: '{{ threescale_cicd_existing_activedocs_details|union([ { ''id'': threescale_cicd_tmpresponse.json.api_doc.id, ''system_name'': threescale_cicd_tmpresponse.json.api_doc.system_name } ]) }}' threescale_cicd_existing_activedocs: >-
{{ threescale_cicd_existing_activedocs|union([ threescale_cicd_tmpresponse.json.api_doc.system_name ]) }}
threescale_cicd_existing_activedocs_details: >-
{{ threescale_cicd_existing_activedocs_details|union([
{
'id': threescale_cicd_tmpresponse.json.api_doc.id,
'system_name': threescale_cicd_tmpresponse.json.api_doc.system_name
}
]) }}
- name: Wait for a couple seconds - name: Wait for a couple seconds
pause: pause:

7
tasks/api-calls/create_application.yml

@ -3,7 +3,7 @@
- debug: - debug:
var: threescale_cicd_create_application_payload var: threescale_cicd_create_application_payload
verbosity: 1 verbosity: 1
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
- name: Create the application - name: Create the application
uri: uri:
@ -14,9 +14,10 @@
status_code: 201 status_code: 201
register: threescale_cicd_tmpresponse register: threescale_cicd_tmpresponse
changed_when: 'threescale_cicd_tmpresponse.status == 201' changed_when: 'threescale_cicd_tmpresponse.status == 201'
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
- set_fact: - name: Store the default application details as fact
set_fact:
threescale_cicd_default_application_details: '{{ threescale_cicd_tmpresponse.json.application }}' threescale_cicd_default_application_details: '{{ threescale_cicd_tmpresponse.json.application }}'
- name: Wait for a couple seconds - name: Wait for a couple seconds

18
tasks/api-calls/create_application_plan.yml

@ -3,7 +3,7 @@
- debug: - debug:
var: threescale_cicd_create_application_plan_payload var: threescale_cicd_create_application_plan_payload
verbosity: 1 verbosity: 1
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
- name: Create the application plan - name: Create the application plan
uri: uri:
@ -14,11 +14,19 @@
status_code: 201 status_code: 201
register: threescale_cicd_tmpresponse register: threescale_cicd_tmpresponse
changed_when: 'threescale_cicd_tmpresponse.status == 201' changed_when: 'threescale_cicd_tmpresponse.status == 201'
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
- set_fact: - name: Store the list of existing Application Plans as fact
threescale_cicd_existing_application_plans: '{{ threescale_cicd_existing_application_plans|union([ threescale_cicd_application_plan.system_name ]) }}' set_fact:
threescale_cicd_existing_application_plans_details: '{{ threescale_cicd_existing_application_plans_details|union([{ "system_name": threescale_cicd_application_plan.system_name, "id": threescale_cicd_tmpresponse.json.application_plan.id }]) }}' threescale_cicd_existing_application_plans: >-
{{ threescale_cicd_existing_application_plans|union([ threescale_cicd_application_plan.system_name ]) }}
threescale_cicd_existing_application_plans_details: >-
{{ threescale_cicd_existing_application_plans_details|union([
{
"system_name": threescale_cicd_application_plan.system_name,
"id": threescale_cicd_tmpresponse.json.application_plan.id
}
]) }}
- name: Wait for a couple seconds - name: Wait for a couple seconds
pause: pause:

4
tasks/api-calls/create_mapping_rule.yml

@ -3,7 +3,7 @@
- debug: - debug:
var: threescale_cicd_create_mapping_rule_payload var: threescale_cicd_create_mapping_rule_payload
verbosity: 1 verbosity: 1
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
- name: Create the mapping rule - name: Create the mapping rule
uri: uri:
@ -14,7 +14,7 @@
status_code: 201 status_code: 201
register: threescale_cicd_tmpresponse register: threescale_cicd_tmpresponse
changed_when: 'threescale_cicd_tmpresponse.status == 201' changed_when: 'threescale_cicd_tmpresponse.status == 201'
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
- name: Wait for a couple seconds - name: Wait for a couple seconds
pause: pause:

18
tasks/api-calls/create_method.yml

@ -3,7 +3,7 @@
- debug: - debug:
var: threescale_cicd_create_method_payload var: threescale_cicd_create_method_payload
verbosity: 1 verbosity: 1
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
- name: Create the method - name: Create the method
uri: uri:
@ -14,11 +14,19 @@
status_code: 201 status_code: 201
register: threescale_cicd_tmpresponse register: threescale_cicd_tmpresponse
changed_when: 'threescale_cicd_tmpresponse.status == 201' changed_when: 'threescale_cicd_tmpresponse.status == 201'
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
- set_fact: - name: Store the metrics details as fact
threescale_cicd_existing_metrics: '{{ threescale_cicd_existing_metrics|union([ threescale_cicd_api_operation.key ]) }}' set_fact:
threescale_cicd_existing_metrics_details: '{{ threescale_cicd_existing_metrics_details|union([ { "system_name": threescale_cicd_api_operation.key, "id": threescale_cicd_tmpresponse.json|json_query("method.id") } ]) }}' threescale_cicd_existing_metrics: >-
{{ threescale_cicd_existing_metrics|union([ threescale_cicd_api_operation.key ]) }}
threescale_cicd_existing_metrics_details: >-
{{ threescale_cicd_existing_metrics_details|union([
{
"system_name": threescale_cicd_api_operation.key,
"id": threescale_cicd_tmpresponse.json|json_query("method.id")
}
]) }}
- name: Wait for a couple seconds - name: Wait for a couple seconds
pause: pause:

18
tasks/api-calls/create_service.yml

@ -3,7 +3,7 @@
- debug: - debug:
var: threescale_cicd_create_service_payload var: threescale_cicd_create_service_payload
verbosity: 1 verbosity: 1
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
- name: Create the service - name: Create the service
uri: uri:
@ -14,11 +14,19 @@
status_code: 201 status_code: 201
register: threescale_cicd_tmpresponse register: threescale_cicd_tmpresponse
changed_when: 'threescale_cicd_tmpresponse.status == 201' changed_when: 'threescale_cicd_tmpresponse.status == 201'
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
- set_fact: - name: Add the new service to the existing service list
threescale_cicd_existing_services: '{{ threescale_cicd_existing_services|union([ threescale_cicd_tmpresponse.json.service.system_name ]) }}' set_fact:
threescale_cicd_existing_services_details: '{{ threescale_cicd_existing_services_details|union([ { ''id'': threescale_cicd_tmpresponse.json.service.id, ''system_name'': threescale_cicd_tmpresponse.json.service.system_name } ]) }}' threescale_cicd_existing_services: >-
{{ threescale_cicd_existing_services|union([ threescale_cicd_tmpresponse.json.service.system_name ]) }}
threescale_cicd_existing_services_details: >-
{{ threescale_cicd_existing_services_details|union([
{
"id": threescale_cicd_tmpresponse.json.service.id,
"system_name": threescale_cicd_tmpresponse.json.service.system_name
}
]) }}
cacheable: true cacheable: true
- name: Wait for a couple seconds - name: Wait for a couple seconds

11
tasks/api-calls/delete_mapping_rule.yml

@ -1,14 +1,21 @@
--- ---
- debug:
msg: "Deleting unused mapping rule {{ threescale_cicd_mapping_rule }}..."
verbosity: 1
- name: Delete the unused mapping rules - name: Delete the unused mapping rules
uri: uri:
url: "https://{{ inventory_hostname }}/admin/api/services/{{ threescale_cicd_api_service_id }}/proxy/mapping_rules/{{ threescale_cicd_existing_mapping_rules[threescale_cicd_mapping_rule] }}.json?access_token={{ threescale_cicd_access_token|urlencode }}" url: "{{ service_url }}/proxy/mapping_rules/{{ rule_id }}.json?access_token={{ threescale_cicd_access_token|urlencode }}"
validate_certs: no validate_certs: no
method: DELETE method: DELETE
status_code: 200,404 status_code: 200,404
register: threescale_cicd_tmpresponse register: threescale_cicd_tmpresponse
changed_when: 'threescale_cicd_tmpresponse.status == 200' changed_when: 'threescale_cicd_tmpresponse.status == 200'
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
vars:
rule_id: '{{ threescale_cicd_existing_mapping_rules[threescale_cicd_mapping_rule] }}'
service_url: https://{{ inventory_hostname }}/admin/api/services/{{ threescale_cicd_api_service_id }}
- name: Wait for a couple seconds - name: Wait for a couple seconds
pause: pause:

8
tasks/api-calls/delete_metric.yml

@ -2,16 +2,20 @@
- debug: - debug:
msg: "Deleting unused metric {{ threescale_cicd_metric.system_name }}..." msg: "Deleting unused metric {{ threescale_cicd_metric.system_name }}..."
verbosity: 1
- name: Delete the metric - name: Delete the metric
uri: uri:
url: "https://{{ inventory_hostname }}/admin/api/services/{{ threescale_cicd_api_service_id }}/metrics/{{ threescale_cicd_metric_id }}/methods/{{ threescale_cicd_metric.id }}.json?access_token={{ threescale_cicd_access_token|urlencode }}" url: "{{ service_url }}{{ metric_path }}?access_token={{ threescale_cicd_access_token|urlencode }}"
validate_certs: no validate_certs: no
method: DELETE method: DELETE
status_code: 200,404 status_code: 200,404
register: threescale_cicd_tmpresponse register: threescale_cicd_tmpresponse
changed_when: 'threescale_cicd_tmpresponse.status == 200' changed_when: 'threescale_cicd_tmpresponse.status == 200'
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
vars:
metric_path: /metrics/{{ threescale_cicd_metric_id }}/methods/{{ threescale_cicd_metric.id }}.json
service_url: https://{{ inventory_hostname }}/admin/api/services/{{ threescale_cicd_api_service_id }}
- name: Wait for a couple seconds - name: Wait for a couple seconds
pause: pause:

7
tasks/api-calls/find_application.yml

@ -2,13 +2,14 @@
- name: Check if the default application exists - name: Check if the default application exists
uri: uri:
url: 'https://{{ inventory_hostname }}/admin/api/applications/find.json?{{ threescale_cicd_find_application_payload }}' url: 'https://{{ inventory_hostname }}/admin/api/applications/find.json?{{ threescale_cicd_find_application_payload }}'
validate_certs: no validate_certs: no
method: GET method: GET
status_code: 200,404 status_code: 200,404
register: threescale_cicd_tmpresponse register: threescale_cicd_tmpresponse
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
- set_fact: - name: Set the default application id as a fact
set_fact:
threescale_cicd_default_application_id: '{{ threescale_cicd_tmpresponse.json.application.id }}' threescale_cicd_default_application_id: '{{ threescale_cicd_tmpresponse.json.application.id }}'
when: 'threescale_cicd_tmpresponse.status == 200' when: 'threescale_cicd_tmpresponse.status == 200'

5
tasks/api-calls/find_first_account.yml

@ -5,7 +5,8 @@
url: https://{{ inventory_hostname }}/admin/api/accounts.json?access_token={{ threescale_cicd_access_token|urlencode }}&state=approved&page=1&per_page=1 url: https://{{ inventory_hostname }}/admin/api/accounts.json?access_token={{ threescale_cicd_access_token|urlencode }}&state=approved&page=1&per_page=1
validate_certs: no validate_certs: no
register: threescale_cicd_tmpresponse register: threescale_cicd_tmpresponse
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
- set_fact: - name: Set the default first account id as a fact
set_fact:
threescale_cicd_default_account_id: '{{ threescale_cicd_tmpresponse.json.accounts[0].account.id }}' threescale_cicd_default_account_id: '{{ threescale_cicd_tmpresponse.json.accounts[0].account.id }}'

31
tasks/api-calls/get_proxy_version.yml

@ -2,21 +2,36 @@
- name: Get the version of the staging proxy definition - name: Get the version of the staging proxy definition
uri: uri:
url: 'https://{{ inventory_hostname }}/admin/api/services/{{ threescale_cicd_api_service_id }}/proxy/configs/{{ threescale_cicd_staging_environment_name }}/latest.json?access_token={{ threescale_cicd_access_token|urlencode }}' url: '{{ service_url }}{{ proxy_path }}?access_token={{ threescale_cicd_access_token|urlencode }}'
validate_certs: no validate_certs: no
register: threescale_cicd_tmpresponse register: threescale_cicd_tmpresponse
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
vars:
proxy_path: /proxy/configs/{{ threescale_cicd_staging_environment_name }}/latest.json
service_url: https://{{ inventory_hostname }}/admin/api/services/{{ threescale_cicd_api_service_id }}
- set_fact: - name: Set the staging proxy version number as a fact
threescale_cicd_staging_proxy_version: '{{ threescale_cicd_tmpresponse.json.proxy_config.version }}' set_fact:
threescale_cicd_staging_proxy_version: >-
{{ threescale_cicd_tmpresponse.json.proxy_config.version }}
- debug: # TODO
var: threescale_cicd_staging_proxy_version
- name: Get the version of the production proxy definition - name: Get the version of the production proxy definition
uri: uri:
url: 'https://{{ inventory_hostname }}/admin/api/services/{{ threescale_cicd_api_service_id }}/proxy/configs/{{ threescale_cicd_production_environment_name }}/latest.json?access_token={{ threescale_cicd_access_token|urlencode }}' url: '{{ service_url }}{{ proxy_path }}?access_token={{ threescale_cicd_access_token|urlencode }}'
validate_certs: no validate_certs: no
status_code: 200,404 status_code: 200,404
register: threescale_cicd_tmpresponse register: threescale_cicd_tmpresponse
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
vars:
proxy_path: /proxy/configs/{{ threescale_cicd_production_environment_name }}/latest.json
service_url: https://{{ inventory_hostname }}/admin/api/services/{{ threescale_cicd_api_service_id }}
- set_fact: - name: Set the production proxy version number as a fact
threescale_cicd_production_proxy_version: '{{ threescale_cicd_tmpresponse.json.proxy_config.version if threescale_cicd_tmpresponse.status == 200 else ''NONE'' }}' set_fact:
threescale_cicd_production_proxy_version: >-
{{ threescale_cicd_tmpresponse.json.proxy_config.version
if threescale_cicd_tmpresponse.status == 200
else 'NONE' }}

6
tasks/api-calls/keycloak/authenticate.yml

@ -3,7 +3,7 @@
- debug: - debug:
var: threescale_cicd_authenticate_to_keycloak_payload var: threescale_cicd_authenticate_to_keycloak_payload
verbosity: 1 verbosity: 1
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
- name: Authenticate to RH-SSO - name: Authenticate to RH-SSO
uri: uri:
@ -17,9 +17,9 @@
delay: '{{ threescale_cicd_delay }}' delay: '{{ threescale_cicd_delay }}'
# temporary fix for https://github.com/ansible/ansible/issues/28078 # temporary fix for https://github.com/ansible/ansible/issues/28078
until: 'threescale_cicd_tmpresponse is success' until: 'threescale_cicd_tmpresponse is success'
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
- name: Extract the access_token - name: Extract the access_token
set_fact: set_fact:
threescale_cicd_keycloak_access_token: '{{ threescale_cicd_tmpresponse.json |json_query("access_token") }}' threescale_cicd_keycloak_access_token: '{{ threescale_cicd_tmpresponse.json |json_query("access_token") }}'
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'

4
tasks/api-calls/keycloak/patch_client.yml

@ -3,7 +3,7 @@
- debug: - debug:
var: threescale_cicd_patch_keycloak_client_payload var: threescale_cicd_patch_keycloak_client_payload
verbosity: 1 verbosity: 1
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
- name: Patch the client in RH-SSO to support the "client_credentials" and "password" grant_type. - name: Patch the client in RH-SSO to support the "client_credentials" and "password" grant_type.
uri: uri:
@ -18,7 +18,7 @@
Content-Type: 'application/json' Content-Type: 'application/json'
register: threescale_cicd_tmpresponse register: threescale_cicd_tmpresponse
changed_when: 'threescale_cicd_tmpresponse.status == 200' changed_when: 'threescale_cicd_tmpresponse.status == 200'
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
- name: Wait for a couple seconds - name: Wait for a couple seconds
pause: pause:

5
tasks/api-calls/keycloak/wait_for_client.yml

@ -12,8 +12,9 @@
retries: '{{ threescale_cicd_retries }}' retries: '{{ threescale_cicd_retries }}'
delay: '{{ threescale_cicd_delay }}' delay: '{{ threescale_cicd_delay }}'
until: 'threescale_cicd_tmpresponse is success and threescale_cicd_tmpresponse.json|length > 0' until: 'threescale_cicd_tmpresponse is success and threescale_cicd_tmpresponse.json|length > 0'
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
- set_fact: - name: Set the new client details and id as a fact
set_fact:
threescale_cicd_default_application_sso_id: '{{ threescale_cicd_tmpresponse.json[0].id }}' threescale_cicd_default_application_sso_id: '{{ threescale_cicd_tmpresponse.json[0].id }}'
threescale_cicd_default_application_sso_body: '{{ threescale_cicd_tmpresponse.json[0] }}' threescale_cicd_default_application_sso_body: '{{ threescale_cicd_tmpresponse.json[0] }}'

9
tasks/api-calls/promote_proxy.yml

@ -3,18 +3,21 @@
- debug: - debug:
var: threescale_cicd_promote_proxy_payload var: threescale_cicd_promote_proxy_payload
verbosity: 1 verbosity: 1
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
- name: Promote to production - name: Promote to production
uri: uri:
url: 'https://{{ inventory_hostname }}/admin/api/services/{{ threescale_cicd_api_service_id }}/proxy/configs/{{ threescale_cicd_staging_environment_name }}/{{ threescale_cicd_staging_proxy_version }}/promote.json' url: '{{ service_url }}{{ promote_path }}'
body: '{{ threescale_cicd_promote_proxy_payload }}' body: '{{ threescale_cicd_promote_proxy_payload }}'
status_code: 201 status_code: 201
validate_certs: no validate_certs: no
method: POST method: POST
register: threescale_cicd_tmpresponse register: threescale_cicd_tmpresponse
changed_when: 'threescale_cicd_tmpresponse.status == 201' changed_when: 'threescale_cicd_tmpresponse.status == 201'
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
vars:
service_url: https://{{ inventory_hostname }}/admin/api/services/{{ threescale_cicd_api_service_id }}
promote_path: /proxy/configs/{{ threescale_cicd_staging_environment_name }}/{{ threescale_cicd_staging_proxy_version }}/promote.json
- name: Wait for a couple seconds - name: Wait for a couple seconds
pause: pause:

4
tasks/api-calls/update_activedoc.yml

@ -3,7 +3,7 @@
- debug: - debug:
var: threescale_cicd_update_activedoc_payload var: threescale_cicd_update_activedoc_payload
verbosity: 1 verbosity: 1
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
- name: Update the ActiveDocs - name: Update the ActiveDocs
uri: uri:
@ -14,7 +14,7 @@
status_code: 200 status_code: 200
register: threescale_cicd_tmpresponse register: threescale_cicd_tmpresponse
changed_when: 'threescale_cicd_tmpresponse.status == 200' changed_when: 'threescale_cicd_tmpresponse.status == 200'
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
- name: Wait for a couple seconds - name: Wait for a couple seconds
pause: pause:

11
tasks/api-calls/update_application.yml

@ -3,19 +3,22 @@
- debug: - debug:
var: threescale_cicd_update_application_payload var: threescale_cicd_update_application_payload
verbosity: 1 verbosity: 1
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
- name: Update the application - name: Update the application
uri: uri:
url: https://{{ inventory_hostname }}/admin/api/accounts/{{ threescale_cicd_default_account_id }}/applications/{{ threescale_cicd_default_application_id }}.json url: '{{ default_account_url }}/applications/{{ threescale_cicd_default_application_id }}.json'
validate_certs: no validate_certs: no
method: PUT method: PUT
body: '{{ threescale_cicd_update_application_payload }}' body: '{{ threescale_cicd_update_application_payload }}'
status_code: 200 status_code: 200
register: threescale_cicd_tmpresponse register: threescale_cicd_tmpresponse
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
vars:
default_account_url: https://{{ inventory_hostname }}/admin/api/accounts/{{ threescale_cicd_default_account_id }}
- set_fact: - name: Set the default application details as a fact
set_fact:
threescale_cicd_default_application_details: '{{ threescale_cicd_tmpresponse.json.application }}' threescale_cicd_default_application_details: '{{ threescale_cicd_tmpresponse.json.application }}'
- name: Wait for a couple seconds - name: Wait for a couple seconds

10
tasks/api-calls/update_application_plan.yml

@ -3,18 +3,22 @@
- debug: - debug:
var: threescale_cicd_update_application_plan_payload var: threescale_cicd_update_application_plan_payload
verbosity: 1 verbosity: 1
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
- name: Update the application plan - name: Update the application plan
uri: uri:
url: 'https://{{ inventory_hostname }}/admin/api/services/{{ threescale_cicd_api_service_id }}/application_plans/{{ (threescale_cicd_existing_application_plans_details|selectattr("system_name", "equalto", threescale_cicd_application_plan.system_name)|first).id }}.json' url: '{{ service_url }}/application_plans/{{ application_plan_id }}.json'
validate_certs: no validate_certs: no
method: PUT method: PUT
body: '{{ threescale_cicd_update_application_plan_payload }}' body: '{{ threescale_cicd_update_application_plan_payload }}'
status_code: 200 status_code: 200
register: threescale_cicd_tmpresponse register: threescale_cicd_tmpresponse
changed_when: 'threescale_cicd_tmpresponse.status == 200' changed_when: 'threescale_cicd_tmpresponse.status == 200'
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
vars:
service_url: https://{{ inventory_hostname }}/admin/api/services/{{ threescale_cicd_api_service_id }}
application_plan_id: >-
{{ (threescale_cicd_existing_application_plans_details|selectattr("system_name", "equalto", threescale_cicd_application_plan.system_name)|first).id }}
- name: Wait for a couple seconds - name: Wait for a couple seconds
pause: pause:

4
tasks/api-calls/update_mapping_rule.yml

@ -3,7 +3,7 @@
- debug: - debug:
var: threescale_cicd_update_mapping_rule_payload var: threescale_cicd_update_mapping_rule_payload
verbosity: 1 verbosity: 1
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
- name: Update the mapping rule - name: Update the mapping rule
uri: uri:
@ -16,7 +16,7 @@
changed_when: 'threescale_cicd_tmpresponse.status == 200' changed_when: 'threescale_cicd_tmpresponse.status == 200'
vars: vars:
threescale_cicd_mapping_rule_id: '{{ threescale_cicd_existing_mapping_rules[threescale_cicd_mapping_rule] }}' threescale_cicd_mapping_rule_id: '{{ threescale_cicd_existing_mapping_rules[threescale_cicd_mapping_rule] }}'
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
- name: Wait for a couple seconds - name: Wait for a couple seconds
pause: pause:

9
tasks/api-calls/update_method.yml

@ -3,17 +3,20 @@
- debug: - debug:
var: threescale_cicd_update_method_payload var: threescale_cicd_update_method_payload
verbosity: 1 verbosity: 1
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
- name: Update the method - name: Update the method
uri: uri:
url: https://{{ inventory_hostname }}/admin/api/services/{{ threescale_cicd_api_service_id }}/metrics/{{ threescale_cicd_metric_id }}/methods/{{ (threescale_cicd_existing_metrics_details|selectattr('system_name', 'equalto', threescale_cicd_api_operation.key)|first).id }}.json url: '{{ service_url }}/metrics/{{ threescale_cicd_metric_id }}/methods/{{ method_id }}.json'
validate_certs: no validate_certs: no
method: PATCH method: PATCH
body: '{{ threescale_cicd_update_method_payload }}' body: '{{ threescale_cicd_update_method_payload }}'
register: threescale_cicd_tmpresponse register: threescale_cicd_tmpresponse
changed_when: 'threescale_cicd_tmpresponse.status == 200' changed_when: 'threescale_cicd_tmpresponse.status == 200'
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
vars:
service_url: https://{{ inventory_hostname }}/admin/api/services/{{ threescale_cicd_api_service_id }}
method_id: "{{ (threescale_cicd_existing_metrics_details|selectattr('system_name', 'equalto', threescale_cicd_api_operation.key)|first).id }}"
- name: Wait for a couple seconds - name: Wait for a couple seconds
pause: pause:

4
tasks/api-calls/update_policies.yml

@ -7,7 +7,7 @@
- debug: - debug:
var: threescale_cicd_update_policies_payload var: threescale_cicd_update_policies_payload
verbosity: 1 verbosity: 1
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
- name: Update the policies chain - name: Update the policies chain
uri: uri:
@ -18,7 +18,7 @@
status_code: 200 status_code: 200
register: threescale_cicd_tmpresponse register: threescale_cicd_tmpresponse
changed_when: 'threescale_cicd_tmpresponse.status == 200' changed_when: 'threescale_cicd_tmpresponse.status == 200'
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
- name: Wait for a couple seconds - name: Wait for a couple seconds
pause: pause:

4
tasks/api-calls/update_proxy.yml

@ -3,7 +3,7 @@
- debug: - debug:
var: threescale_cicd_update_proxy_payload var: threescale_cicd_update_proxy_payload
verbosity: 1 verbosity: 1
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
- name: Update the proxy definition - name: Update the proxy definition
uri: uri:
@ -13,7 +13,7 @@
body: '{{ threescale_cicd_update_proxy_payload }}' body: '{{ threescale_cicd_update_proxy_payload }}'
register: threescale_cicd_tmpresponse register: threescale_cicd_tmpresponse
changed_when: 'threescale_cicd_tmpresponse.status == 200' changed_when: 'threescale_cicd_tmpresponse.status == 200'
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
- name: Extract the staging and production gateway endpoint from the proxy definition - name: Extract the staging and production gateway endpoint from the proxy definition
set_fact: set_fact:

4
tasks/api-calls/update_service.yml

@ -3,7 +3,7 @@
- debug: - debug:
var: threescale_cicd_update_service_payload var: threescale_cicd_update_service_payload
verbosity: 1 verbosity: 1
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
- name: Update the service - name: Update the service
uri: uri:
@ -14,7 +14,7 @@
status_code: 200 status_code: 200
register: threescale_cicd_tmpresponse register: threescale_cicd_tmpresponse
changed_when: 'threescale_cicd_tmpresponse.status == 200' changed_when: 'threescale_cicd_tmpresponse.status == 200'
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
- name: Wait for a couple seconds - name: Wait for a couple seconds
pause: pause:

12
tasks/cleanup.yaml

@ -2,22 +2,26 @@
- name: Delete the created service and any dependent object - name: Delete the created service and any dependent object
uri: uri:
url: 'https://{{ inventory_hostname }}/admin/api/services/{{ threescale_cicd_api_service_id }}.json?access_token={{ threescale_cicd_access_token|urlencode }}' url: '{{ service_url }}?access_token={{ threescale_cicd_access_token|urlencode }}'
validate_certs: no validate_certs: no
method: DELETE method: DELETE
status_code: 200,404 status_code: 200,404
register: threescale_cicd_tmpresponse register: threescale_cicd_tmpresponse
changed_when: 'threescale_cicd_tmpresponse.status == 200' changed_when: 'threescale_cicd_tmpresponse.status == 200'
when: 'threescale_cicd_api_service_id is defined' when: 'threescale_cicd_api_service_id is defined'
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
vars:
service_url: https://{{ inventory_hostname }}/admin/api/services/{{ threescale_cicd_api_service_id }}.json
- name: Delete the created ActiveDocs - name: Delete the created ActiveDocs
uri: uri:
url: 'https://{{ inventory_hostname }}/admin/api/active_docs/{{ threescale_cicd_api_activedocs_id }}.json?access_token={{ threescale_cicd_access_token|urlencode }}' url: '{{ activedocs_url }}?access_token={{ threescale_cicd_access_token|urlencode }}'
validate_certs: no validate_certs: no
method: DELETE method: DELETE
status_code: 200,404 status_code: 200,404
register: threescale_cicd_tmpresponse register: threescale_cicd_tmpresponse
changed_when: 'threescale_cicd_tmpresponse.status == 200' changed_when: 'threescale_cicd_tmpresponse.status == 200'
when: 'threescale_cicd_api_activedocs_id is defined' when: 'threescale_cicd_api_activedocs_id is defined'
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
vars:
activedocs_url: https://{{ inventory_hostname }}/admin/api/active_docs/{{ threescale_cicd_api_activedocs_id }}.json

2
tasks/main.yml

@ -43,7 +43,7 @@
- include_tasks: steps/smoke_test.yml - include_tasks: steps/smoke_test.yml
vars: vars:
threescale_cicd_smoke_test_env: staging threescale_cicd_smoke_test_env: staging
when: > when: >-
threescale_cicd_openapi_smoketest_operation|length > 0 and threescale_cicd_application_plans is defined threescale_cicd_openapi_smoketest_operation|length > 0 and threescale_cicd_application_plans is defined
and threescale_cicd_apicast_sandbox_endpoint != threescale_cicd_apicast_production_endpoint and threescale_cicd_apicast_sandbox_endpoint != threescale_cicd_apicast_production_endpoint

11
tasks/steps/ansible_requirements.yml

@ -3,7 +3,7 @@
- name: Verify that Ansible version is >= 2.4.6 - name: Verify that Ansible version is >= 2.4.6
assert: assert:
that: "ansible_version.full is version_compare('2.4.6', '>=')" that: "ansible_version.full is version_compare('2.4.6', '>=')"
msg: > msg: >-
This module requires at least Ansible 2.4.6. The version that comes This module requires at least Ansible 2.4.6. The version that comes
with RHEL and CentOS by default (2.4.2) has a known bug that prevent with RHEL and CentOS by default (2.4.2) has a known bug that prevent
this role from running properly. this role from running properly.
@ -31,17 +31,20 @@
register: check_jinja_do_ext register: check_jinja_do_ext
ignore_errors: yes ignore_errors: yes
- assert: - name: Ensure JMESPath is installed
assert:
that: that:
- 'check_jmespath is success' - 'check_jmespath is success'
msg: "The JMESPath library is required by this role. Please install the JMESPath library with 'pip install jmespath'." msg: "The JMESPath library is required by this role. Please install the JMESPath library with 'pip install jmespath'."
- assert: - name: Ensure at least Jinja 2.8 is installed
assert:
that: that:
- 'check_jinja28 is success' - 'check_jinja28 is success'
msg: "At least Jinja v2.8 is required by this role. Please update Jinja with 'pip install -U Jinja2'." msg: "At least Jinja v2.8 is required by this role. Please update Jinja with 'pip install -U Jinja2'."
- assert: - name: Ensure the "do" extension of Jinja is enabled
assert:
that: that:
- 'check_jinja_do_ext is success' - 'check_jinja_do_ext is success'
msg: |- msg: |-

1
tasks/steps/application_plan.yml

@ -5,4 +5,3 @@
- include_tasks: api-calls/create_application_plan.yml - include_tasks: api-calls/create_application_plan.yml
when: 'threescale_cicd_application_plan.system_name not in threescale_cicd_existing_application_plans' when: 'threescale_cicd_application_plan.system_name not in threescale_cicd_existing_application_plans'

6
tasks/steps/default_application.yml

@ -17,7 +17,7 @@
## ##
- include_tasks: api-calls/keycloak/authenticate.yml - include_tasks: api-calls/keycloak/authenticate.yml
when: 'threescale_cicd_api_security_scheme.type == ''oauth2''' when: "threescale_cicd_api_security_scheme.type == 'oauth2'"
vars: vars:
oauth_payload: oauth_payload:
client_id: '{{ threescale_cicd_sso_issuer_endpoint|urlsplit(''username'') }}' client_id: '{{ threescale_cicd_sso_issuer_endpoint|urlsplit(''username'') }}'
@ -26,7 +26,7 @@
grant_type: 'client_credentials' grant_type: 'client_credentials'
- include_tasks: api-calls/keycloak/wait_for_client.yml - include_tasks: api-calls/keycloak/wait_for_client.yml
when: 'threescale_cicd_api_security_scheme.type == ''oauth2''' when: "threescale_cicd_api_security_scheme.type == 'oauth2'"
- include_tasks: api-calls/keycloak/patch_client.yml - include_tasks: api-calls/keycloak/patch_client.yml
when: 'threescale_cicd_api_security_scheme.type == ''oauth2''' when: "threescale_cicd_api_security_scheme.type == 'oauth2'"

52
tasks/steps/discover.yml

@ -6,11 +6,14 @@
validate_certs: no validate_certs: no
register: threescale_cicd_tmpresponse register: threescale_cicd_tmpresponse
when: threescale_cicd_existing_services is not defined when: threescale_cicd_existing_services is not defined
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
- set_fact: - name: Set the list of existing service as a fact
threescale_cicd_existing_services: '{{ threescale_cicd_tmpresponse.json|json_query(''services[*].service.system_name'') }}' set_fact:
threescale_cicd_existing_services_details: '{{ threescale_cicd_tmpresponse.json|json_query(''services[].{"system_name": service.system_name, "id": service.id}'') }}' threescale_cicd_existing_services: >-
{{ threescale_cicd_tmpresponse.json|json_query('services[*].service.system_name') }}
threescale_cicd_existing_services_details: >-
{{ threescale_cicd_tmpresponse.json|json_query('services[].{"system_name": service.system_name, "id": service.id}') }}
cacheable: true cacheable: true
when: threescale_cicd_existing_services is not defined when: threescale_cicd_existing_services is not defined
@ -24,15 +27,24 @@
- name: Get the list of existing application plans - name: Get the list of existing application plans
uri: uri:
url: https://{{ inventory_hostname }}/admin/api/services/{{ threescale_cicd_api_service_id }}/application_plans.json?access_token={{ threescale_cicd_access_token|urlencode }} url: '{{ service_url }}/application_plans.json?access_token={{ threescale_cicd_access_token|urlencode }}'
validate_certs: no validate_certs: no
register: threescale_cicd_tmpresponse register: threescale_cicd_tmpresponse
when: threescale_cicd_api_system_name in threescale_cicd_existing_services when: threescale_cicd_api_system_name in threescale_cicd_existing_services
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
vars:
- set_fact: service_url: https://{{ inventory_hostname }}/admin/api/services/{{ threescale_cicd_api_service_id }}
threescale_cicd_existing_application_plans: '{{ threescale_cicd_tmpresponse.json|json_query(''plans[*].application_plan.system_name'') if threescale_cicd_api_system_name in threescale_cicd_existing_services else [] }}'
threescale_cicd_existing_application_plans_details: '{{ threescale_cicd_tmpresponse.json|json_query(''plans[].{"system_name": application_plan.system_name, "id": application_plan.id}'') if threescale_cicd_api_system_name in threescale_cicd_existing_services else [] }}' - name: Set the list of existing application plans as a fact
set_fact:
threescale_cicd_existing_application_plans: >-
{{ threescale_cicd_tmpresponse.json|json_query('plans[*].application_plan.system_name')
if threescale_cicd_api_system_name in threescale_cicd_existing_services
else [] }}
threescale_cicd_existing_application_plans_details: >-
{{ threescale_cicd_tmpresponse.json|json_query('plans[].{"system_name": application_plan.system_name, "id": application_plan.id}')
if threescale_cicd_api_system_name in threescale_cicd_existing_services
else [] }}
- debug: - debug:
msg: "Found {{ threescale_cicd_existing_application_plans|length }} application plans" msg: "Found {{ threescale_cicd_existing_application_plans|length }} application plans"
@ -47,11 +59,14 @@
url: "https://{{ inventory_hostname }}/admin/api/active_docs.json?access_token={{ threescale_cicd_access_token|urlencode }}" url: "https://{{ inventory_hostname }}/admin/api/active_docs.json?access_token={{ threescale_cicd_access_token|urlencode }}"
validate_certs: no validate_certs: no
register: threescale_cicd_tmp_allactivedocs register: threescale_cicd_tmp_allactivedocs
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
- set_fact: - name: Set the list of existing active docs as a fact
threescale_cicd_existing_activedocs: '{{ threescale_cicd_tmp_allactivedocs.json|json_query(''api_docs[*].api_doc.system_name'') }}' set_fact:
threescale_cicd_existing_activedocs_details: '{{ threescale_cicd_tmp_allactivedocs.json|json_query(''api_docs[].{"system_name": api_doc.system_name, "id": api_doc.id}'') }}' threescale_cicd_existing_activedocs: >-
{{ threescale_cicd_tmp_allactivedocs.json|json_query('api_docs[*].api_doc.system_name') }}
threescale_cicd_existing_activedocs_details: >-
{{ threescale_cicd_tmp_allactivedocs.json|json_query('api_docs[].{"system_name": api_doc.system_name, "id": api_doc.id}') }}
- debug: - debug:
msg: "Found {{ threescale_cicd_existing_activedocs|length }} active docs" msg: "Found {{ threescale_cicd_existing_activedocs|length }} active docs"
@ -68,7 +83,7 @@
status_code: 200,404 status_code: 200,404
register: threescale_cicd_tmp_policy_response register: threescale_cicd_tmp_policy_response
changed_when: false changed_when: false
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
when: threescale_cicd_capabilities is not defined when: threescale_cicd_capabilities is not defined
- name: Poke around for the OIDC Configuration Show API - name: Poke around for the OIDC Configuration Show API
@ -78,10 +93,11 @@
status_code: 404 status_code: 404
register: threescale_cicd_tmp_oidc_config_response register: threescale_cicd_tmp_oidc_config_response
changed_when: false changed_when: false
no_log: '{{ threescale_cicd_nolog }}' no_log: '{{ threescale_cicd_nolog }}'
when: threescale_cicd_capabilities is not defined when: threescale_cicd_capabilities is not defined
- set_fact: - name: Set the list of 3scale capabilities as a fact
set_fact:
threescale_cicd_capabilities: threescale_cicd_capabilities:
policy_registry_api: '{{ threescale_cicd_tmp_policy_response.status == 200 }}' policy_registry_api: '{{ threescale_cicd_tmp_policy_response.status == 200 }}'
oidc_configuration_api: '{{ threescale_cicd_tmp_oidc_config_response.content_type.startswith(''application/json'') }}' oidc_configuration_api: '{{ threescale_cicd_tmp_oidc_config_response.content_type.startswith(''application/json'') }}'

8
tasks/steps/find_goswagger.yml

@ -6,8 +6,10 @@
changed_when: false changed_when: false
ignore_errors: yes ignore_errors: yes
- set_fact: - name: Set the 'swagger' command path as fact
set_fact:
threescale_cicd_goswagger_command: 'swagger' threescale_cicd_goswagger_command: 'swagger'
cacheable: true
when: check_global_goswagger_version is success when: check_global_goswagger_version is success
- name: Check if go-swagger is installed locally - name: Check if go-swagger is installed locally
@ -17,6 +19,8 @@
ignore_errors: yes ignore_errors: yes
when: check_global_goswagger_version is failed when: check_global_goswagger_version is failed
- set_fact: - name: Set the 'swagger' command path as fact
set_fact:
threescale_cicd_goswagger_command: '{{ threescale_cicd_local_bin_path }}/swagger' threescale_cicd_goswagger_command: '{{ threescale_cicd_local_bin_path }}/swagger'
cacheable: true
when: check_local_goswagger_version is success and check_local_goswagger_version is not skipped when: check_local_goswagger_version is success and check_local_goswagger_version is not skipped

8
tasks/steps/install_goswagger.yml

@ -14,7 +14,7 @@
- name: Create the folder to download go-swagger - name: Create the folder to download go-swagger
file: file:
path: '{{ threescale_cicd_local_bin_path }}' path: '{{ threescale_cicd_local_bin_path }}'
state: directory state: directory
- name: Download go-swagger - name: Download go-swagger
@ -23,7 +23,7 @@
dest: '{{ threescale_cicd_local_bin_path }}/swagger' dest: '{{ threescale_cicd_local_bin_path }}/swagger'
mode: 0755 mode: 0755
vars: vars:
goswagger_download_url: '{{ goswagger_asset.browser_download_url }}' goswagger_download_url: '{{ goswagger_asset.browser_download_url }}'
goswagger_asset: '{{ goswagger_assets|selectattr(''name'', ''equalto'', artifact_name)|first }}' goswagger_asset: '{{ goswagger_assets|selectattr(''name'', ''equalto'', artifact_name)|first }}'
goswagger_assets: '{{ latest_goswagger_version.json.assets }}' goswagger_assets: '{{ latest_goswagger_version.json.assets }}'
artifact_name: 'swagger_{{ ansible_system|lower }}_{{ swagger_architecture }}' artifact_name: 'swagger_{{ ansible_system|lower }}_{{ swagger_architecture }}'
@ -32,5 +32,7 @@
x86_64: amd64 x86_64: amd64
armv7l: arm armv7l: arm
- set_fact: - name: Set the 'swagger' command path as fact
set_fact:
threescale_cicd_goswagger_command: '{{ threescale_cicd_local_bin_path }}/swagger' threescale_cicd_goswagger_command: '{{ threescale_cicd_local_bin_path }}/swagger'
cacheable: true

11
tasks/steps/mapping_rules.yml

@ -2,12 +2,17 @@
- name: Retrieve existing mapping rules from the 3scale Admin Portal - name: Retrieve existing mapping rules from the 3scale Admin Portal
uri: uri:
url: "https://{{ inventory_hostname }}/admin/api/services/{{ threescale_cicd_api_service_id }}/proxy/mapping_rules.json?access_token={{ threescale_cicd_access_token|urlencode }}" url: "{{ service_url }}/proxy/mapping_rules.json?access_token={{ threescale_cicd_access_token|urlencode }}"
validate_certs: no validate_certs: no
register: threescale_cicd_tmpresponse register: threescale_cicd_tmpresponse
no_log: '{{ threescale_cicd_nolog }}'
vars:
service_url: https://{{ inventory_hostname }}/admin/api/services/{{ threescale_cicd_api_service_id }}
- set_fact: - name: Set the list of existing mapping rules as a fact
threescale_cicd_existing_mapping_rules_details: '{{ threescale_cicd_tmpresponse.json|json_query(''mapping_rules[].{"metric_id": mapping_rule.metric_id, "id": mapping_rule.id}'') }}' set_fact:
threescale_cicd_existing_mapping_rules_details: >-
{{ threescale_cicd_tmpresponse.json|json_query('mapping_rules[].{"metric_id": mapping_rule.metric_id, "id": mapping_rule.id}') }}
- include_tasks: "api-calls/create_mapping_rule.yml" - include_tasks: "api-calls/create_mapping_rule.yml"
with_items: '{{ threescale_cicd_mapping_rules_to_create }}' with_items: '{{ threescale_cicd_mapping_rules_to_create }}'

14
tasks/steps/methods.yml

@ -2,13 +2,19 @@
- name: Retrieve existing metrics from the 3scale Admin Portal - name: Retrieve existing metrics from the 3scale Admin Portal
uri: uri:
url: "https://{{ inventory_hostname }}/admin/api/services/{{ threescale_cicd_api_service_id }}/metrics.json?access_token={{ threescale_cicd_access_token|urlencode }}" url: "{{ service_url }}/metrics.json?access_token={{ threescale_cicd_access_token|urlencode }}"
validate_certs: no validate_certs: no
register: threescale_cicd_tmpresponse register: threescale_cicd_tmpresponse
no_log: '{{ threescale_cicd_nolog }}'
vars:
service_url: https://{{ inventory_hostname }}/admin/api/services/{{ threescale_cicd_api_service_id }}
- set_fact: - name: Set the list of existing metrics as facts
threescale_cicd_existing_metrics: '{{ threescale_cicd_tmpresponse.json|json_query(''metrics[*].metric.system_name'') }}' set_fact:
threescale_cicd_existing_metrics_details: '{{ threescale_cicd_tmpresponse.json|json_query(''metrics[].{"system_name": metric.system_name, "id": metric.id}'') }}' threescale_cicd_existing_metrics: >-
{{ threescale_cicd_tmpresponse.json|json_query('metrics[*].metric.system_name') }}
threescale_cicd_existing_metrics_details: >-
{{ threescale_cicd_tmpresponse.json|json_query('metrics[].{"system_name": metric.system_name, "id": metric.id}') }}
- include_tasks: "steps/method.yml" - include_tasks: "steps/method.yml"
with_dict: '{{ threescale_cicd_api_operations }}' with_dict: '{{ threescale_cicd_api_operations }}'

8
tasks/steps/policies.yml

@ -2,11 +2,15 @@
- name: Retrieve existing policies from the 3scale Admin Portal - name: Retrieve existing policies from the 3scale Admin Portal
uri: uri:
url: "https://{{ inventory_hostname }}/admin/api/services/{{ threescale_cicd_api_service_id }}/proxy/policies.json?access_token={{ threescale_cicd_access_token|urlencode }}" url: "{{ service_url }}/proxy/policies.json?access_token={{ threescale_cicd_access_token|urlencode }}"
validate_certs: no validate_certs: no
register: threescale_cicd_tmpresponse register: threescale_cicd_tmpresponse
no_log: '{{ threescale_cicd_nolog }}'
vars:
service_url: https://{{ inventory_hostname }}/admin/api/services/{{ threescale_cicd_api_service_id }}
- set_fact: - name: Set the list of existing policies as a fact
set_fact:
threescale_cicd_existing_policies_details: '{{ threescale_cicd_tmpresponse.json|json_query(''policies_config[]'') }}' threescale_cicd_existing_policies_details: '{{ threescale_cicd_tmpresponse.json|json_query(''policies_config[]'') }}'
- include_tasks: "api-calls/update_policies.yml" - include_tasks: "api-calls/update_policies.yml"

22
tasks/steps/read_openapi.yml

@ -10,29 +10,37 @@
assert: assert:
that: that:
- 'threescale_cicd_api_security_requirements|length == 1' - 'threescale_cicd_api_security_requirements|length == 1'
msg: 'You have {{ threescale_cicd_api_security_requirements|length }} global security requirements. There must be one and only one security requirement.' msg: >-
You have {{ threescale_cicd_api_security_requirements|length }} global security requirements.
There must be one and only one security requirement.
- name: Make sure the security scheme is consistent with 3scale - name: Make sure the security scheme is consistent with 3scale
assert: assert:
that: that:
- '''type'' in threescale_cicd_api_security_scheme and threescale_cicd_api_security_scheme.type == ''apiKey'' or (threescale_cicd_api_security_scheme.type == ''oauth2'' and threescale_cicd_sso_issuer_endpoint is defined)' - >-
msg: |- 'type' in threescale_cicd_api_security_scheme and threescale_cicd_api_security_scheme.type == 'apiKey'
or (threescale_cicd_api_security_scheme.type == 'oauth2' and threescale_cicd_sso_issuer_endpoint is defined)
msg: >-
The embedded security definition {{ threescale_cicd_api_security_scheme_name }} is not compatible with 3scale. The embedded security definition {{ threescale_cicd_api_security_scheme_name }} is not compatible with 3scale.
Please make sure you chose an "apiKey" or "oauth2" scheme. Please make sure you chose an "apiKey" or "oauth2" scheme.
Also, if you chose "oauth2", you will need to pass the threescale_cicd_sso_issuer_endpoint extra variable. Also, if you chose "oauth2", you will need to pass the threescale_cicd_sso_issuer_endpoint extra variable.
The security definition you chose: {{ threescale_cicd_api_security_scheme|to_nice_json }} The security definition you chose: {{ threescale_cicd_api_security_scheme|to_nice_json }}
- assert: - name: Make sure the Private Base URL is defined
assert:
that: that:
- 'threescale_cicd_private_base_url is defined' - 'threescale_cicd_private_base_url is defined'
msg: 'Either the private base url or the tuple backend hostname/scheme must be declared as extra variables (either threescale_cicd_private_base_url or threescale_cicd_api_backend_scheme / threescale_cicd_api_backend_hostname)' msg: >-
Either the private base url or the tuple backend hostname/scheme must be declared as extra variables
(either threescale_cicd_private_base_url or threescale_cicd_api_backend_scheme / threescale_cicd_api_backend_hostname)
- assert: - name: Smoketests consistency
assert:
that: that:
# Operation must exists # Operation must exists
- 'threescale_cicd_openapi_smoketest_operation in threescale_cicd_api_operations' - 'threescale_cicd_openapi_smoketest_operation in threescale_cicd_api_operations'
# Must be a GET # Must be a GET
- 'threescale_cicd_api_operations[threescale_cicd_openapi_smoketest_operation].verb == ''get''' - "threescale_cicd_api_operations[threescale_cicd_openapi_smoketest_operation].verb == 'get'"
# Must NOT have a placeholder in the path # Must NOT have a placeholder in the path
- 'threescale_cicd_api_operations[threescale_cicd_openapi_smoketest_operation].path.find("{") == -1' - 'threescale_cicd_api_operations[threescale_cicd_openapi_smoketest_operation].path.find("{") == -1'
msg: "The smoketest operation {{ threescale_cicd_openapi_smoketest_operation }} must be a GET and cannot have a placeholder in its path." msg: "The smoketest operation {{ threescale_cicd_openapi_smoketest_operation }} must be a GET and cannot have a placeholder in its path."

6
tasks/steps/requirements.yml

@ -7,8 +7,10 @@
- "threescale_cicd_openapi_file is defined" - "threescale_cicd_openapi_file is defined"
msg: |- msg: |-
This module requires at least two variables: This module requires at least two variables:
- threescale_cicd_access_token that contains an Access Token with Read/Write privileges on the 3scale Account Management API. This variable is usually set in your inventory file. - threescale_cicd_access_token that contains an Access Token with Read/Write privileges on the 3scale Account Management API.
- threescale_cicd_openapi_file that is the path to the OpenAPI file you want to deploy in 3scale. This variable is usually passed as an extra variable (-e threescale_cicd_openapi_file=...) This variable is usually set in your inventory file.
- threescale_cicd_openapi_file that is the path to the OpenAPI file you want to deploy in 3scale.
This variable is usually passed as an extra variable (-e threescale_cicd_openapi_file=...)
- name: Make sure the OpenAPI File Format is YAML or JSON - name: Make sure the OpenAPI File Format is YAML or JSON
assert: assert:

2
tasks/steps/smoke_test.yml

@ -2,7 +2,7 @@
# Retrieve a valid access token if the API is secured with OAuth/OIDC # Retrieve a valid access token if the API is secured with OAuth/OIDC
- include_tasks: api-calls/keycloak/authenticate.yml - include_tasks: api-calls/keycloak/authenticate.yml
when: 'threescale_cicd_api_security_scheme.type == ''oauth2''' when: "threescale_cicd_api_security_scheme.type == 'oauth2'"
vars: vars:
oauth_payload: oauth_payload:
client_id: '{{ threescale_cicd_default_application_details.client_id }}' client_id: '{{ threescale_cicd_default_application_details.client_id }}'

2
tasks/steps/validate_openapi.yml

@ -1,7 +1,7 @@
--- ---
- debug: - debug:
msg: > msg: >-
Will use go-swagger at '{{ threescale_cicd_goswagger_command }}' as instructed. Will use go-swagger at '{{ threescale_cicd_goswagger_command }}' as instructed.
Auto-detection and download is DISABLED. Auto-detection and download is DISABLED.
when: threescale_cicd_goswagger_command is defined when: threescale_cicd_goswagger_command is defined

19
tasks/steps/variables_from_inventory.yml

@ -2,27 +2,34 @@
- name: Abort on deprecated feature -> the "sso" inventory group - name: Abort on deprecated feature -> the "sso" inventory group
fail: fail:
msg: > msg: >-
You are currently using a deprecated feature (the 'sso' group in your inventory). You are currently using a deprecated feature (the 'sso' group in your inventory).
Please replace it with the 'threescale_cicd_sso_issuer_endpoint' variable. Please replace it with the 'threescale_cicd_sso_issuer_endpoint' variable.
Alternatively, you can also bypass this warning by setting the 'threescale_cicd_deprecated_features' Alternatively, you can also bypass this warning by setting the 'threescale_cicd_deprecated_features'
extra variable to 'true'. extra variable to 'true'.
when: 'threescale_cicd_sso_issuer_endpoint|default("")|length > 0 and ''sso'' in groups and groups[''sso''] > 0 and threescale_cicd_api_backend_version == ''oidc'' and not threescale_cicd_deprecated_features|default(false)|bool' when: >-
threescale_cicd_sso_issuer_endpoint|default("")|length > 0 and 'sso' in groups
and groups['sso'] > 0 and threescale_cicd_api_backend_version == 'oidc'
and not threescale_cicd_deprecated_features|default(false)|bool
- name: Abort on deprecated feature -> the "apicast-sandbox" inventory group - name: Abort on deprecated feature -> the "apicast-sandbox" inventory group
fail: fail:
msg: > msg: >-
You are currently using a deprecated feature (the 'apicast-sandbox' group in your inventory). You are currently using a deprecated feature (the 'apicast-sandbox' group in your inventory).
Please replace it with the 'threescale_cicd_apicast_sandbox_endpoint' variable. Please replace it with the 'threescale_cicd_apicast_sandbox_endpoint' variable.
Alternatively, you can also bypass this warning by setting the 'threescale_cicd_deprecated_features' Alternatively, you can also bypass this warning by setting the 'threescale_cicd_deprecated_features'
extra variable to 'true'. extra variable to 'true'.
when: 'threescale_cicd_apicast_sandbox_endpoint|default("")|length > 0 and ''apicast-sandbox'' in groups and groups[''apicast-sandbox''] > 0 and not threescale_cicd_deprecated_features|default(false)|bool' when: >-
threescale_cicd_apicast_sandbox_endpoint|default("")|length > 0 and 'apicast-sandbox' in groups
and groups['apicast-sandbox'] > 0 and not threescale_cicd_deprecated_features|default(false)|bool
- name: Abort on deprecated feature -> the "apicast-production" inventory group - name: Abort on deprecated feature -> the "apicast-production" inventory group
fail: fail:
msg: > msg: >-
You are currently using a deprecated feature (the 'apicast-production' group in your inventory). You are currently using a deprecated feature (the 'apicast-production' group in your inventory).
Please replace it with the 'threescale_cicd_apicast_production_endpoint' variable. Please replace it with the 'threescale_cicd_apicast_production_endpoint' variable.
Alternatively, you can also bypass this warning by setting the 'threescale_cicd_deprecated_features' Alternatively, you can also bypass this warning by setting the 'threescale_cicd_deprecated_features'
extra variable to 'true'. extra variable to 'true'.
when: 'threescale_cicd_apicast_production_endpoint|default("")|length > 0 and ''apicast-production'' in groups and groups[''apicast-production''] > 0 and not threescale_cicd_deprecated_features|default(false)|bool' when: >-
threescale_cicd_apicast_production_endpoint|default("")|length > 0 and 'apicast-production' in groups
and groups['apicast-production'] > 0 and not threescale_cicd_deprecated_features|default(false)|bool

1
tests/setup/delete-travis-logs.yml

@ -53,4 +53,3 @@
with_items: '{{ travis_jobs }}' with_items: '{{ travis_jobs }}'
vars: vars:
travis_jobs: '{{ get_build_response.json|json_query(''@.matrix[].id'') }}' travis_jobs: '{{ get_build_response.json|json_query(''@.matrix[].id'') }}'

Loading…
Cancel
Save