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.
264 lines
8.0 KiB
264 lines
8.0 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: '"projects/" ~ 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: Fetch the latest 3scale AMP template from the 3scale repo
|
|
uri: url={{threescale_template}} return_content=yes
|
|
register: template
|
|
when: deploy_needed
|
|
|
|
- name: Parse the YAML file
|
|
set_fact:
|
|
template: '{{template.content |from_yaml }}'
|
|
when: "deploy_needed and threescale_template_format|upper == 'YAML'"
|
|
|
|
- name: Parse the JSON file
|
|
set_fact:
|
|
template: '{{template.content |from_json }}'
|
|
when: "deploy_needed and threescale_template_format|upper == 'JSON'"
|
|
|
|
- name: Disable the triggers and set the replicas to 0
|
|
set_fact:
|
|
template: >-
|
|
{% for obj in template.objects -%}
|
|
{% if obj.kind == 'DeploymentConfig' -%}
|
|
{% if obj.spec.update({'replicas': 0, 'triggers': []}) -%}{% endif -%}
|
|
{% endif -%}
|
|
{% endfor -%}
|
|
{{ template }}
|
|
when: deploy_needed
|
|
|
|
- name: Create a temporary directory
|
|
tempfile: state=directory
|
|
register: tempfile
|
|
when: deploy_needed
|
|
|
|
- name: Write the template
|
|
template: src=amp.json dest={{tempfile.path}}/amp.json
|
|
when: deploy_needed
|
|
|
|
- name: Process the OpenShift Template and create the OpenShift objects for the 3scale API Management Platform
|
|
shell: oc process -f "{{tempfile.path}}/amp.json" -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, PostgreSQL and Memcache) without any replicas
|
|
command: oc rollout latest "{{ item }}" -n "{{ threescale_project }}"
|
|
with_items:
|
|
- backend-redis
|
|
- system-memcache
|
|
- system-mysql
|
|
- system-redis
|
|
- zync-database
|
|
when: item not in deployment_configs
|
|
tags: rollout
|
|
|
|
- name: Scale the storage tier (MySQL, Redis, PostgreSQL and Memcache)
|
|
command: oc scale dc "{{ item }}" --replicas=1 -n "{{ threescale_project }}"
|
|
with_items:
|
|
- backend-redis
|
|
- system-memcache
|
|
- system-mysql
|
|
- system-redis
|
|
- zync-database
|
|
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
|
|
- zync-database
|
|
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
|
|
- apicast-wildcard-router
|
|
- zync
|
|
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
|
|
|
|
- name: Deploy zync, apicast-staging, apicast-production
|
|
command: oc scale dc "{{ item }}" --replicas=1 -n "{{ threescale_project }}"
|
|
with_items:
|
|
- zync
|
|
- apicast-wildcard-router
|
|
- 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
|
|
when: 'not is_offline|default(False)|bool'
|
|
|
|
- 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
|
|
|