Browse Source

see #41: add the no_log option where relevant

pull/42/head
Nicolas Massé 7 years ago
parent
commit
77e43b4132
  1. 7
      defaults/main.yml
  2. 2
      tasks/api-calls/create_activedoc.yml
  3. 2
      tasks/api-calls/create_application.yml
  4. 2
      tasks/api-calls/create_application_plan.yml
  5. 2
      tasks/api-calls/create_mapping_rule.yml
  6. 2
      tasks/api-calls/create_method.yml
  7. 2
      tasks/api-calls/create_service.yml
  8. 1
      tasks/api-calls/delete_mapping_rule.yml
  9. 1
      tasks/api-calls/delete_metric.yml
  10. 1
      tasks/api-calls/find_application.yml
  11. 1
      tasks/api-calls/find_first_account.yml
  12. 2
      tasks/api-calls/get_proxy_version.yml
  13. 3
      tasks/api-calls/keycloak/authenticate.yml
  14. 2
      tasks/api-calls/keycloak/patch_client.yml
  15. 1
      tasks/api-calls/keycloak/wait_for_client.yml
  16. 2
      tasks/api-calls/promote_proxy.yml
  17. 2
      tasks/api-calls/update_activedoc.yml
  18. 2
      tasks/api-calls/update_application.yml
  19. 2
      tasks/api-calls/update_application_plan.yml
  20. 2
      tasks/api-calls/update_mapping_rule.yml
  21. 2
      tasks/api-calls/update_method.yml
  22. 2
      tasks/api-calls/update_policies.yml
  23. 2
      tasks/api-calls/update_proxy.yml
  24. 2
      tasks/api-calls/update_service.yml
  25. 56
      tests/setup/delete-travis-logs.yml

7
defaults/main.yml

@ -17,6 +17,13 @@ threescale_cicd_application_plans:
state: hidden state: hidden
name: Ansible Test Plan name: Ansible Test Plan
# Controls when to log sensitive information. Can be set to false for
# production environments.
#
# By default, log sensitive information only when Ansible is called with
# A verbosity level of at least one "-v".
threescale_cicd_nolog: '{{ ansible_verbosity|default(0) == 0 }}'
# A folder where to download dependencies, when required # A folder where to download dependencies, when required
threescale_cicd_local_bin_path: '{{ playbook_dir }}/bin' threescale_cicd_local_bin_path: '{{ playbook_dir }}/bin'

2
tasks/api-calls/create_activedoc.yml

@ -3,6 +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 }}'
- name: Create the ActiveDocs - name: Create the ActiveDocs
uri: uri:
@ -13,6 +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 }}'
- set_fact: - set_fact:
threescale_cicd_existing_activedocs: '{{ threescale_cicd_existing_activedocs|union([ 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 ]) }}'

2
tasks/api-calls/create_application.yml

@ -3,6 +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 }}'
- name: Create the application - name: Create the application
uri: uri:
@ -13,6 +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 }}'
- set_fact: - set_fact:
threescale_cicd_default_application_details: '{{ threescale_cicd_tmpresponse.json.application }}' threescale_cicd_default_application_details: '{{ threescale_cicd_tmpresponse.json.application }}'

2
tasks/api-calls/create_application_plan.yml

@ -3,6 +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 }}'
- name: Create the application plan - name: Create the application plan
uri: uri:
@ -13,6 +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 }}'
- set_fact: - set_fact:
threescale_cicd_existing_application_plans: '{{ threescale_cicd_existing_application_plans|union([ threescale_cicd_application_plan.system_name ]) }}' threescale_cicd_existing_application_plans: '{{ threescale_cicd_existing_application_plans|union([ threescale_cicd_application_plan.system_name ]) }}'

2
tasks/api-calls/create_mapping_rule.yml

@ -3,6 +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 }}'
- name: Create the mapping rule - name: Create the mapping rule
uri: uri:
@ -13,6 +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 }}'
- name: Wait for a couple seconds - name: Wait for a couple seconds
pause: pause:

2
tasks/api-calls/create_method.yml

@ -3,6 +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 }}'
- name: Create the method - name: Create the method
uri: uri:
@ -13,6 +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 }}'
- set_fact: - set_fact:
threescale_cicd_existing_metrics: '{{ threescale_cicd_existing_metrics|union([ threescale_cicd_api_operation.key ]) }}' threescale_cicd_existing_metrics: '{{ threescale_cicd_existing_metrics|union([ threescale_cicd_api_operation.key ]) }}'

2
tasks/api-calls/create_service.yml

@ -3,6 +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 }}'
- name: Create the service - name: Create the service
uri: uri:
@ -13,6 +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 }}'
- set_fact: - set_fact:
threescale_cicd_existing_services: '{{ threescale_cicd_existing_services|union([ threescale_cicd_tmpresponse.json.service.system_name ]) }}' threescale_cicd_existing_services: '{{ threescale_cicd_existing_services|union([ threescale_cicd_tmpresponse.json.service.system_name ]) }}'

1
tasks/api-calls/delete_mapping_rule.yml

@ -8,6 +8,7 @@
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 }}'
- name: Wait for a couple seconds - name: Wait for a couple seconds
pause: pause:

1
tasks/api-calls/delete_metric.yml

@ -11,6 +11,7 @@
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 }}'
- name: Wait for a couple seconds - name: Wait for a couple seconds
pause: pause:

1
tasks/api-calls/find_application.yml

@ -7,6 +7,7 @@
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 }}'
- set_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 }}'

1
tasks/api-calls/find_first_account.yml

@ -5,6 +5,7 @@
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 }}'
- set_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 }}'

2
tasks/api-calls/get_proxy_version.yml

@ -5,6 +5,7 @@
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: '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 }}'
validate_certs: no validate_certs: no
register: threescale_cicd_tmpresponse register: threescale_cicd_tmpresponse
no_log: '{{ threescale_cicd_nolog }}'
- set_fact: - set_fact:
threescale_cicd_staging_proxy_version: '{{ threescale_cicd_tmpresponse.json.proxy_config.version }}' threescale_cicd_staging_proxy_version: '{{ threescale_cicd_tmpresponse.json.proxy_config.version }}'
@ -15,6 +16,7 @@
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 }}'
- set_fact: - set_fact:
threescale_cicd_production_proxy_version: '{{ threescale_cicd_tmpresponse.json.proxy_config.version if threescale_cicd_tmpresponse.status == 200 else ''NONE'' }}' threescale_cicd_production_proxy_version: '{{ threescale_cicd_tmpresponse.json.proxy_config.version if threescale_cicd_tmpresponse.status == 200 else ''NONE'' }}'

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

@ -3,6 +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 }}'
- name: Authenticate to RH-SSO - name: Authenticate to RH-SSO
uri: uri:
@ -16,7 +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 }}'
- 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 }}'

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

@ -3,6 +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 }}'
- 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:
@ -17,6 +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 }}'
- name: Wait for a couple seconds - name: Wait for a couple seconds
pause: pause:

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

@ -12,6 +12,7 @@
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 }}'
- set_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 }}'

2
tasks/api-calls/promote_proxy.yml

@ -3,6 +3,7 @@
- debug: - debug:
var: threescale_cicd_promote_proxy_payload var: threescale_cicd_promote_proxy_payload
verbosity: 1 verbosity: 1
no_log: '{{ threescale_cicd_nolog }}'
- name: Promote to production - name: Promote to production
uri: uri:
@ -13,6 +14,7 @@
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 }}'
- name: Wait for a couple seconds - name: Wait for a couple seconds
pause: pause:

2
tasks/api-calls/update_activedoc.yml

@ -3,6 +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 }}'
- name: Update the ActiveDocs - name: Update the ActiveDocs
uri: uri:
@ -13,6 +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 }}'
- name: Wait for a couple seconds - name: Wait for a couple seconds
pause: pause:

2
tasks/api-calls/update_application.yml

@ -3,6 +3,7 @@
- debug: - debug:
var: threescale_cicd_update_application_payload var: threescale_cicd_update_application_payload
verbosity: 1 verbosity: 1
no_log: '{{ threescale_cicd_nolog }}'
- name: Update the application - name: Update the application
uri: uri:
@ -12,6 +13,7 @@
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 }}'
- set_fact: - set_fact:
threescale_cicd_default_application_details: '{{ threescale_cicd_tmpresponse.json.application }}' threescale_cicd_default_application_details: '{{ threescale_cicd_tmpresponse.json.application }}'

2
tasks/api-calls/update_application_plan.yml

@ -3,6 +3,7 @@
- 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 }}'
- name: Update the application plan - name: Update the application plan
uri: uri:
@ -13,6 +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 }}'
- name: Wait for a couple seconds - name: Wait for a couple seconds
pause: pause:

2
tasks/api-calls/update_mapping_rule.yml

@ -3,6 +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 }}'
- name: Update the mapping rule - name: Update the mapping rule
uri: uri:
@ -15,6 +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 }}'
- name: Wait for a couple seconds - name: Wait for a couple seconds
pause: pause:

2
tasks/api-calls/update_method.yml

@ -3,6 +3,7 @@
- debug: - debug:
var: threescale_cicd_update_method_payload var: threescale_cicd_update_method_payload
verbosity: 1 verbosity: 1
no_log: '{{ threescale_cicd_nolog }}'
- name: Update the method - name: Update the method
uri: uri:
@ -12,6 +13,7 @@
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 }}'
- name: Wait for a couple seconds - name: Wait for a couple seconds
pause: pause:

2
tasks/api-calls/update_policies.yml

@ -7,6 +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 }}'
- name: Update the policies chain - name: Update the policies chain
uri: uri:
@ -17,6 +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 }}'
- name: Wait for a couple seconds - name: Wait for a couple seconds
pause: pause:

2
tasks/api-calls/update_proxy.yml

@ -3,6 +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 }}'
- name: Update the proxy definition - name: Update the proxy definition
uri: uri:
@ -12,6 +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 }}'
- 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:

2
tasks/api-calls/update_service.yml

@ -3,6 +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 }}'
- name: Update the service - name: Update the service
uri: uri:
@ -13,6 +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 }}'
- name: Wait for a couple seconds - name: Wait for a couple seconds
pause: pause:

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

@ -0,0 +1,56 @@
---
- name: Delete the Travis logs of a build
hosts: localhost
gather_facts: no
vars:
ansible_connection: local
travis_repo: nmasse-itix/threescale-cicd
travis_api: https://api.travis-ci.org
tasks:
- assert:
that:
- travis_token is defined
msg: >
Please pass your Travis Token in the 'travis_token' extra var
- assert:
that:
- travis_build is defined
msg: >
Please pass Travis build number in the 'travis_build' extra var
- name: Find Build
uri:
url: '{{ travis_api }}/repos/{{ travis_repo }}/builds?number={{ travis_build }}'
headers:
Authorization: "token {{ travis_token }}"
register: find_build_response
changed_when: false
- name: Get Build
uri:
url: '{{ travis_api }}/repos/{{ travis_repo }}/builds/{{ travis_build_id }}'
headers:
Authorization: "token {{ travis_token }}"
register: get_build_response
changed_when: false
vars:
travis_build_id: '{{ find_build_response.json|json_query(''[0].id'') }}'
- name: Delete logs
uri:
url: '{{ travis_api }}/jobs/{{ item }}/log'
headers:
Authorization: "token {{ travis_token }}"
body_format: form-urlencoded
body:
reason: "Logs removed because it contains sensitive data"
method: PATCH
status_code: "200,409"
register: delete_logs_response
changed_when: delete_logs_response.status == 200
with_items: '{{ travis_jobs }}'
vars:
travis_jobs: '{{ get_build_response.json|json_query(''@.matrix[].id'') }}'
Loading…
Cancel
Save