satyaj
2020-03-10 8b7a067b545c772e5c04cfb97a72427787473dc8
API Lifecycle Lab playbook fixes (#1281)

* Added role to install 3scale toolbox and ruby.

* Added camel-k CLI tool to bastion.

* Added role for API CICD Lab.

* Added tenant creation, and installing camel-k & tekton operators clusterwide.

* Updated tenant creation to use Admin API.

* Added post workload and remove workloads.

* Added steps to install lxml module to virtualenv

* Added tekton SA, role and permissions to workload.

* Provided Dev User ID & Fix remove workload to use k8s.

* Fixed typo

* Fixed user-info for clarity.
4 files modified
75 ■■■■■ changed files
ansible/roles/ocp4-workload-summit-api-cicd/tasks/post_workload.yml 2 ●●●●● patch | view | raw | blame | history
ansible/roles/ocp4-workload-summit-api-cicd/tasks/remove_workload.yml 34 ●●●●● patch | view | raw | blame | history
ansible/roles/ocp4-workload-summit-api-cicd/tasks/tenant_loop.yml 31 ●●●●● patch | view | raw | blame | history
ansible/roles/ocp4-workload-summit-api-cicd/tasks/workload.yml 8 ●●●●● patch | view | raw | blame | history
ansible/roles/ocp4-workload-summit-api-cicd/tasks/post_workload.yml
@@ -13,10 +13,12 @@
    - "user.info: 3scale DEV Tenant Admin Console : https://{{ dev_tenant }}-admin.{{ ocp_apps_domain }}"
    - "user.info: Admin login with credentials {{ dev_tenant_admin }} / admin "
    - "user.info: 3scale DEV Tenant Endpoint : {{ dev_tenant_endpoint }}"
    - "user.info: 3scale DEV Tenant Developer Account ID : {{ dev_tenant_developer_user_id }}"
    - "user.info: "
    - "user.info: 3scale PROD Tenant Admin Console : https://{{ prod_tenant }}-admin.{{ ocp_apps_domain }}"
    - "user.info: Admin login with credentials {{ prod_tenant_admin }} / admin"
    - "user.info: 3scale PROD Tenant Endpoint : {{ prod_tenant_endpoint }}"
    - "user.info: 3scale PROD Tenant Developer Account ID : {{ prod_tenant_developer_user_id }}"
    - "user.info: "
    - "user.info: NOTE: Follow the Lab Instructions to set the environment correctly"
    - "user.info: before accessing the administration consoles above."
ansible/roles/ocp4-workload-summit-api-cicd/tasks/remove_workload.yml
@@ -7,26 +7,20 @@
  command: "{{ pip_path }}/pip uninstall lxml -y"
  become: True
- name: "Remove {{ API_MANAGER_NS }} Project"
  shell: "oc delete project {{API_MANAGER_NS}}"
- name: "Remove {{ DEV_GW_PROJECT }} Project"
  shell: "oc delete project {{DEV_GW_PROJECT}}"
- name: "Remove {{ PROD_GW_PROJECT }} Project"
  shell: "oc delete project {{PROD_GW_PROJECT}}"
- name: "Remove {{ DEV_API_PROJECT }} Project"
  shell: "oc delete project {{DEV_API_PROJECT}}"
- name: "Remove {{ TEST_API_PROJECT }} Project"
  shell: "oc delete project {{TEST_API_PROJECT}}"
- name: "Remove {{ PROD_API_PROJECT }} Project"
  shell: "oc delete project {{PROD_API_PROJECT}}"
- name: "Remove {{ CICD_PROJECT }} Project"
  shell: "oc delete project {{CICD_PROJECT}}"
- name: Remove all projects created for this workload
  k8s:
    state: absent
    api_version: project.openshift.io/v1
    kind: Project
    name: "{{ item }}"
  loop:
  - "{{ API_MANAGER_NS }}"
  - "{{ DEV_GW_PROJECT }}"
  - "{{ PROD_GW_PROJECT }}"
  - "{{ DEV_API_PROJECT }}"
  - "{{ TEST_API_PROJECT }}"
  - "{{ PROD_API_PROJECT }}"
  - "{{ CICD_PROJECT }}"
- name: post_workload Tasks Complete
  debug:
ansible/roles/ocp4-workload-summit-api-cicd/tasks/tenant_loop.yml
@@ -33,9 +33,7 @@
    content: text
    xmlstring: "{{create_tenant_response.content}}"
    xpath: "//user[state = \"pending\"]/id"
- debug:
    msg: "{{tenant_access_token.matches[0].value}}  {{account_id.matches[0].id}} {{user_id.matches[0].id}}"
    verbosity: 0
- name: "{{orgName}}     4) activate new user"
  set_fact: 
    activate_user_url: "https://master.{{ocp_apps_domain}}/admin/api/accounts/{{account_id.matches[0].id}}/users/{{user_id.matches[0].id}}/activate.xml"
@@ -50,6 +48,33 @@
    url: "{{activate_user_url}}"
    validate_certs: false
# Routes are created after some delay. Wait here for routes to  be ready.
- pause:
    minutes: 1
- name: "{{orgName}}     4) List developer user id"
  set_fact:
    developer_user_url: "https://{{orgName}}-admin.{{ocp_apps_domain}}/admin/api/accounts.xml"
- register: developer_user_response
  uri:
    body: "access_token={{tenant_access_token.matches[0].value}}"
    method: GET
    return_content: true
    status_code: 200
    timeout: 10
    url: "{{developer_user_url}}"
    validate_certs: false
- register: developer_user_id
  xml:
    content: text
    xmlstring: "{{developer_user_response.content}}"
    xpath: //account/id
- debug:
    msg: "ORG NAME: {{ orgName }} , ACCESS TOKEN: {{tenant_access_token.matches[0].value}}  ADMIN ACCOUNT: {{account_id.matches[0].id}} ADMIN_USER: {{user_id.matches[0].id}} DEVELOPER_ACCOUNT: {{ developer_user_id.matches[0].id }}"
    verbosity: 0
# create the DEV tenant Gateway
- block:
ansible/roles/ocp4-workload-summit-api-cicd/tasks/workload.yml
@@ -96,6 +96,9 @@
  - set_fact:
      dev_tenant_endpoint: "{{ THREESCALE_PORTAL_ENDPOINT }}"
  - set_fact:
      dev_tenant_developer_user_id: "{{ developer_user_id.matches[0].id }}"
# Create Prod Tenant & Gateway
- block:
@@ -116,6 +119,8 @@
  - set_fact:
      prod_tenant_endpoint: "{{ THREESCALE_PORTAL_ENDPOINT }}"
  - set_fact:
      prod_tenant_developer_user_id: "{{ developer_user_id.matches[0].id }}"
# Create OpenBanking API Implementation Projects:
@@ -190,6 +195,9 @@
  - name: "**********  PROD API PROJECT  Edit Access **********"
    command: "oc policy add-role-to-user edit system:serviceaccount:{{ CICD_PROJECT }}:pipeline -n {{ PROD_API_PROJECT }}"
  - name: "********** READ ACCESS to 3scale API Manager PROJECT ********"
    command: "oc adm policy add-role-to-user view {{ocp_user}} -n {{API_MANAGER_NS}}"
# Workload tasks complete
- name: workload Tasks Complete
  debug: