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.
230 lines
6.9 KiB
230 lines
6.9 KiB
---
|
|
|
|
- name: Get a list of existing projects
|
|
command: oc get projects -o name
|
|
register: oc_get_projects
|
|
changed_when: false
|
|
|
|
- name: Create a new project for 3scale
|
|
command: oc new-project "{{ threescale_project }}"
|
|
when: '"project/" ~ threescale_project not in oc_get_projects.stdout_lines'
|
|
|
|
- include: common/status.yml
|
|
vars:
|
|
project: "{{ threescale_project }}"
|
|
tags: status
|
|
|
|
- set_fact:
|
|
deploy_needed: '{{ deployment_configs|intersect(threescale_expected_deployment_configs)|length < threescale_expected_deployment_configs|length }}'
|
|
|
|
- name: Process the OpenShift Template and create the OpenShift objects for the 3scale API Management Platform
|
|
shell: oc process -f "{{ threescale_template }}" -p "TENANT_NAME={{ threescale_tenant_name }}" -p "WILDCARD_DOMAIN={{ threescale_wildcard_domain }}" -n "{{ threescale_project }}" | oc create -f - -n "{{ threescale_project }}"
|
|
register: oc
|
|
failed_when: oc.rc > 0 and 'Error from server (AlreadyExists):' not in oc.stderr
|
|
changed_when: oc.rc == 0
|
|
when: deploy_needed
|
|
|
|
- name: Wait for OpenShift to create all objects
|
|
pause:
|
|
seconds: '{{ threescale_delay }}'
|
|
when: deploy_needed
|
|
|
|
# Deploy the CORS Configuration for APICast
|
|
# This is needed to make the "Try out" feature working in the Developer Portal
|
|
- include: apicast_cors.yml
|
|
|
|
- include: common/status.yml
|
|
vars:
|
|
project: "{{ threescale_project }}"
|
|
tags: status
|
|
|
|
- name: Deploy the storage tier (MySQL, Redis and Memcache) without any replicas
|
|
command: oc rollout latest "{{ item }}" -n "{{ threescale_project }}"
|
|
with_items:
|
|
- backend-redis
|
|
- system-memcache
|
|
- system-mysql
|
|
- system-redis
|
|
when: item not in deployment_configs
|
|
tags: rollout
|
|
|
|
- name: Scale the storage tier (MySQL, Redis and Memcache)
|
|
command: oc scale dc "{{ item }}" --replicas=1 -n "{{ threescale_project }}"
|
|
with_items:
|
|
- backend-redis
|
|
- system-memcache
|
|
- system-mysql
|
|
- system-redis
|
|
when: item not in replication_controllers
|
|
tags: rollout
|
|
|
|
- include: common/wait_for.yml
|
|
static: no
|
|
vars:
|
|
pod_to_wait:
|
|
- backend-redis
|
|
- system-memcache
|
|
- system-mysql
|
|
- system-redis
|
|
delay: "{{ threescale_delay }}"
|
|
retries: "{{ threescale_retries }}"
|
|
project: "{{ threescale_project }}"
|
|
tags: status
|
|
|
|
- name: Deploy the backend-listener without any replicas
|
|
command: oc rollout latest "{{ item }}" -n "{{ threescale_project }}"
|
|
with_items:
|
|
- backend-listener
|
|
when: item not in deployment_configs
|
|
tags: rollout
|
|
|
|
- name: Scale backend-listener
|
|
command: oc scale dc "{{ item }}" --replicas=1 -n "{{ threescale_project }}"
|
|
with_items:
|
|
- backend-listener
|
|
when: item not in replication_controllers
|
|
tags: rollout
|
|
|
|
- include: common/wait_for.yml
|
|
static: no
|
|
vars:
|
|
pod_to_wait:
|
|
- backend-listener
|
|
delay: "{{ threescale_delay }}"
|
|
retries: "{{ threescale_retries }}"
|
|
project: "{{ threescale_project }}"
|
|
tags: status
|
|
|
|
- name: Deploy everything else without any replicas
|
|
command: oc rollout latest "{{ item }}" -n "{{ threescale_project }}"
|
|
with_items:
|
|
- backend-worker
|
|
- system-app
|
|
- system-resque
|
|
- system-sidekiq
|
|
- backend-cron
|
|
- system-sphinx
|
|
- apicast-staging
|
|
- apicast-production
|
|
when: item not in deployment_configs
|
|
tags: rollout
|
|
|
|
- name: Scale system-app, system-resque and system-sidekiq
|
|
command: oc scale dc "{{ item }}" --replicas=1 -n "{{ threescale_project }}"
|
|
with_items:
|
|
- system-app
|
|
- system-resque
|
|
- system-sidekiq
|
|
when: item not in replication_controllers
|
|
tags: rollout
|
|
|
|
- include: common/wait_for.yml
|
|
static: no
|
|
vars:
|
|
pod_to_wait:
|
|
- system-app
|
|
- system-resque
|
|
- system-sidekiq
|
|
delay: "{{ threescale_delay }}"
|
|
retries: "{{ threescale_retries }}"
|
|
project: "{{ threescale_project }}"
|
|
tags: status
|
|
|
|
- name: Scale backend-cron, backend-worker and system-sphinx
|
|
command: oc scale dc "{{ item }}" --replicas=1 -n "{{ threescale_project }}"
|
|
with_items:
|
|
- backend-worker
|
|
- backend-cron
|
|
- system-sphinx
|
|
when: item not in replication_controllers
|
|
tags: rollout
|
|
|
|
- include: common/wait_for.yml
|
|
static: no
|
|
vars:
|
|
pod_to_wait:
|
|
- backend-worker
|
|
- backend-cron
|
|
- system-sphinx
|
|
delay: "{{ threescale_delay }}"
|
|
retries: "{{ threescale_retries }}"
|
|
project: "{{ threescale_project }}"
|
|
tags: status
|
|
|
|
- include: configure_apicast_for_oauth.yml
|
|
with_items:
|
|
- apicast-staging
|
|
- apicast-production
|
|
tags: oauth
|
|
|
|
- name: Deploy apicast-staging, apicast-production
|
|
command: oc scale dc "{{ item }}" --replicas=1 -n "{{ threescale_project }}"
|
|
with_items:
|
|
- apicast-staging
|
|
- apicast-production
|
|
when: item not in replication_controllers
|
|
tags: rollout
|
|
|
|
- include: common/wait_for.yml
|
|
static: no
|
|
vars:
|
|
pod_to_wait:
|
|
- apicast-staging
|
|
- apicast-production
|
|
delay: "{{ threescale_delay }}"
|
|
retries: "{{ threescale_retries }}"
|
|
project: "{{ threescale_project }}"
|
|
tags: status
|
|
|
|
- name: Get Route URL
|
|
command: oc get route system-provider-admin-route -n "{{ threescale_project }}" -o 'jsonpath={.spec.host}'
|
|
register: route
|
|
changed_when: false
|
|
tags: status
|
|
|
|
- set_fact:
|
|
threescale_default_backend_map:
|
|
microcks: http://{{ microcks_hostname }}
|
|
tags: vars
|
|
|
|
- set_fact:
|
|
threescale_admin_hostname: '{{ route.stdout }}'
|
|
threescale_backend_map: '{{ threescale_default_backend_map |combine(threescale_additional_backend_map|default({})) }}'
|
|
tags: vars
|
|
|
|
- name: Get the 3scale Administration Access Token
|
|
command: oc get dc system-app -n "{{ threescale_project }}" -o 'jsonpath={.spec.template.spec.containers[0].env[?(@.name=="ADMIN_ACCESS_TOKEN")].value}'
|
|
register: oc_get_dc
|
|
tags: vars
|
|
changed_when: false
|
|
|
|
- set_fact:
|
|
access_token: '{{ oc_get_dc.stdout }}'
|
|
tags: vars
|
|
|
|
- include: 3scale_status.yml
|
|
|
|
- include: create_api.yml
|
|
with_items: '{{ threescale_apis_to_create }}'
|
|
|
|
- include: oauth-client.yml
|
|
tags: oauth-client
|
|
|
|
- include: webhooks.yml
|
|
tags: webhooks
|
|
|
|
- name: Get Admin Username
|
|
command: oc get dc system-app -n "{{ threescale_project }}" -o 'jsonpath={.spec.template.spec.containers[0].env[?(@.name=="USER_LOGIN")].value}'
|
|
register: username
|
|
changed_when: false
|
|
tags: status
|
|
|
|
- name: Get Admin Password
|
|
command: oc get dc system-app -n "{{ threescale_project }}" -o 'jsonpath={.spec.template.spec.containers[0].env[?(@.name=="USER_PASSWORD")].value}'
|
|
register: password
|
|
changed_when: false
|
|
tags: status
|
|
|
|
- name: 3scale is ready !
|
|
debug: msg="Login on https://{{ threescale_admin_hostname }} with username = '{{ username.stdout }}' and password = '{{ password.stdout }}'"
|
|
tags: status
|
|
|