Browse Source

update 3scale to version 2.1 (see #20), cleanup unneeded components and prepare for offline install (see #19)

master
Nicolas Massé 8 years ago
parent
commit
4bce40e26e
  1. 7
      roles/3scale/defaults/main.yml
  2. 17
      roles/3scale/tasks/apicast_cors.yml
  3. 7
      roles/3scale/tasks/configure_apicast_for_oauth.yml
  4. 31
      roles/3scale/tasks/main.yml

7
roles/3scale/defaults/main.yml

@ -1,7 +1,7 @@
--- ---
threescale_apicast_git_repo: https://github.com/3scale/apicast.git threescale_apicast_git_repo: https://github.com/3scale/apicast.git
threescale_webhooks_git_repo: https://github.com/nmasse-itix/3scale-webhooks-sample.git threescale_apicast_tag: 3.1-stable
threescale_template: https://raw.githubusercontent.com/3scale/3scale-amp-openshift-templates/2.0.0.GA/amp/amp.yml threescale_template: https://raw.githubusercontent.com/3scale/3scale-amp-openshift-templates/2.0.0.GA/amp/amp.yml
threescale_template_format: YAML threescale_template_format: YAML
threescale_project: 3scale threescale_project: 3scale
@ -9,8 +9,6 @@
threescale_wildcard_domain: "{{ openshift_master_default_subdomain }}" threescale_wildcard_domain: "{{ openshift_master_default_subdomain }}"
threescale_delay: 5 threescale_delay: 5
threescale_retries: 30 threescale_retries: 30
threescale_apicast_cors_lua: https://raw.githubusercontent.com/3scale/apicast/master/examples/cors/cors.lua
threescale_apicast_cors_conf: https://raw.githubusercontent.com/3scale/apicast/master/examples/cors/cors.conf
threescale_webhooks_secret: supersecret threescale_webhooks_secret: supersecret
threescale_expected_deployment_configs: threescale_expected_deployment_configs:
- apicast-staging - apicast-staging
@ -26,6 +24,9 @@
- system-sidekiq - system-sidekiq
- backend-cron - backend-cron
- system-sphinx - system-sphinx
- zync
- zync-database
- apicast-wildcard-router
threescale_apis_to_create: threescale_apis_to_create:
- service: - service:
name: "Hello API" name: "Hello API"

17
roles/3scale/tasks/apicast_cors.yml

@ -3,20 +3,25 @@
tempfile: state=directory tempfile: state=directory
register: tempfile register: tempfile
- name: Download 'cors.lua' - name: Use a local copy of the 3scale/apicast GIT repo
get_url: dest='{{ tempfile.path }}/cors.lua' url={{ threescale_apicast_cors_lua }} set_fact:
threescale_apicast_git_repo: 'http://{{ offline_git_route }}/{{ threescale_apicast_git_repo|basename|regex_replace(''[.]git$'', '''') }}'
when: 'is_offline|default(false)|bool'
- name: Download 'cors.conf' - name: Check out the 3scale/apicast GIT repo
get_url: dest='{{ tempfile.path }}/cors.conf' url={{ threescale_apicast_cors_conf }} git:
repo: '{{ threescale_apicast_git_repo }}'
dest: '{{ tempfile.path }}'
version: '{{ threescale_apicast_tag|default(''master'') }}'
- name: Create ConfigMap 'apicast-custom-module' - name: Create ConfigMap 'apicast-custom-module'
command: chdir={{ tempfile.path }} oc create configmap apicast-custom-module --from-file=cors.lua -n "{{ threescale_project }}" command: chdir={{ tempfile.path }} oc create configmap apicast-custom-module --from-file=examples/cors/cors.lua -n "{{ threescale_project }}"
register: oc register: oc
failed_when: oc.rc > 0 and 'Error from server (AlreadyExists):' not in oc.stderr failed_when: oc.rc > 0 and 'Error from server (AlreadyExists):' not in oc.stderr
changed_when: oc.rc == 0 changed_when: oc.rc == 0
- name: Create ConfigMap 'cors-conf' - name: Create ConfigMap 'cors-conf'
command: chdir={{ tempfile.path }} oc create configmap apicast.d --from-file=cors.conf -n "{{ threescale_project }}" command: chdir={{ tempfile.path }} oc create configmap apicast.d --from-file=examples/cors/cors.conf -n "{{ threescale_project }}"
register: oc register: oc
failed_when: oc.rc > 0 and 'Error from server (AlreadyExists):' not in oc.stderr failed_when: oc.rc > 0 and 'Error from server (AlreadyExists):' not in oc.stderr
changed_when: oc.rc == 0 changed_when: oc.rc == 0

7
roles/3scale/tasks/configure_apicast_for_oauth.yml

@ -1,7 +0,0 @@
---
- name: Update the APICast DeploymentConfig to point to RH-SSO
command: oc env dc/{{ item }} -n {{ threescale_project }} RHSSO_ENDPOINT=https://{{ sso_route_name }}/auth/realms/{{ sso_realm }}
- name: Deploy latest revision of APICast DeploymentConfig
command: oc rollout latest dc/{{ item }} -n {{ threescale_project }}

31
roles/3scale/tasks/main.yml

@ -20,16 +20,17 @@
- name: Fetch the latest 3scale AMP template from the 3scale repo - name: Fetch the latest 3scale AMP template from the 3scale repo
uri: url={{threescale_template}} return_content=yes uri: url={{threescale_template}} return_content=yes
register: template register: template
when: deploy_needed
- name: Parse the YAML file - name: Parse the YAML file
set_fact: set_fact:
template: '{{template.content |from_yaml }}' template: '{{template.content |from_yaml }}'
when: "threescale_template_format|upper == 'YAML'" when: "deploy_needed and threescale_template_format|upper == 'YAML'"
- name: Parse the JSON file - name: Parse the JSON file
set_fact: set_fact:
template: '{{template.content |from_json }}' template: '{{template.content |from_json }}'
when: "threescale_template_format|upper == 'JSON'" when: "deploy_needed and threescale_template_format|upper == 'JSON'"
- name: Disable the triggers and set the replicas to 0 - name: Disable the triggers and set the replicas to 0
set_fact: set_fact:
@ -40,13 +41,16 @@
{% endif -%} {% endif -%}
{% endfor -%} {% endfor -%}
{{ template }} {{ template }}
when: deploy_needed
- name: Create a temporary directory - name: Create a temporary directory
tempfile: state=directory tempfile: state=directory
register: tempfile register: tempfile
when: deploy_needed
- name: Write the template - name: Write the template
template: src=amp.json dest={{tempfile.path}}/amp.json 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 - 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 }}" 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 }}"
@ -69,23 +73,25 @@
project: "{{ threescale_project }}" project: "{{ threescale_project }}"
tags: status tags: status
- name: Deploy the storage tier (MySQL, Redis and Memcache) without any replicas - name: Deploy the storage tier (MySQL, Redis, PostgreSQL and Memcache) without any replicas
command: oc rollout latest "{{ item }}" -n "{{ threescale_project }}" command: oc rollout latest "{{ item }}" -n "{{ threescale_project }}"
with_items: with_items:
- backend-redis - backend-redis
- system-memcache - system-memcache
- system-mysql - system-mysql
- system-redis - system-redis
- zync-database
when: item not in deployment_configs when: item not in deployment_configs
tags: rollout tags: rollout
- name: Scale the storage tier (MySQL, Redis and Memcache) - name: Scale the storage tier (MySQL, Redis, PostgreSQL and Memcache)
command: oc scale dc "{{ item }}" --replicas=1 -n "{{ threescale_project }}" command: oc scale dc "{{ item }}" --replicas=1 -n "{{ threescale_project }}"
with_items: with_items:
- backend-redis - backend-redis
- system-memcache - system-memcache
- system-mysql - system-mysql
- system-redis - system-redis
- zync-database
when: item not in replication_controllers when: item not in replication_controllers
tags: rollout tags: rollout
@ -97,6 +103,7 @@
- system-memcache - system-memcache
- system-mysql - system-mysql
- system-redis - system-redis
- zync-database
delay: "{{ threescale_delay }}" delay: "{{ threescale_delay }}"
retries: "{{ threescale_retries }}" retries: "{{ threescale_retries }}"
project: "{{ threescale_project }}" project: "{{ threescale_project }}"
@ -137,6 +144,8 @@
- system-sphinx - system-sphinx
- apicast-staging - apicast-staging
- apicast-production - apicast-production
- apicast-wildcard-router
- zync
when: item not in deployment_configs when: item not in deployment_configs
tags: rollout tags: rollout
@ -182,15 +191,11 @@
project: "{{ threescale_project }}" project: "{{ threescale_project }}"
tags: status tags: status
- include: configure_apicast_for_oauth.yml - name: Deploy zync, apicast-staging, apicast-production
with_items:
- apicast-staging
- apicast-production
tags: oauth
- name: Deploy apicast-staging, apicast-production
command: oc scale dc "{{ item }}" --replicas=1 -n "{{ threescale_project }}" command: oc scale dc "{{ item }}" --replicas=1 -n "{{ threescale_project }}"
with_items: with_items:
- zync
- apicast-wildcard-router
- apicast-staging - apicast-staging
- apicast-production - apicast-production
when: item not in replication_controllers when: item not in replication_controllers
@ -240,9 +245,7 @@
- include: oauth-client.yml - include: oauth-client.yml
tags: oauth-client tags: oauth-client
when: 'not is_offline|default(False)|bool'
- include: webhooks.yml
tags: webhooks
- name: Get Admin Username - 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}' command: oc get dc system-app -n "{{ threescale_project }}" -o 'jsonpath={.spec.template.spec.containers[0].env[?(@.name=="USER_LOGIN")].value}'

Loading…
Cancel
Save