Browse Source

3scale deployment: first try

master
Nicolas Massé 9 years ago
parent
commit
5a645b9d79
  1. 1
      allinone.yml
  2. 2
      roles/3scale/files/.gitignore
  3. 2889
      roles/3scale/files/amp.json
  4. 9
      roles/3scale/files/get-default-templates.sh
  5. 34
      roles/3scale/tasks/main.yml
  6. 7
      roles/3scale/vars/main.yml

1
allinone.yml

@ -18,3 +18,4 @@
become: yes become: yes
roles: roles:
- { name: 'hostpath-provisioner', tags: 'hostpath-provisioner' } - { name: 'hostpath-provisioner', tags: 'hostpath-provisioner' }
- { name: '3scale', tags: '3scale' }

2
roles/3scale/files/.gitignore

@ -0,0 +1,2 @@
amp.yml

2889
roles/3scale/files/amp.json

File diff suppressed because it is too large

9
roles/3scale/files/get-default-templates.sh

@ -0,0 +1,9 @@
#!/bin/bash
#
# This script gets the original 3scale template, converts it to JSON and
# scale down the DeploymentConfig's replicas to 0.
#
curl -s -o amp.yml https://raw.githubusercontent.com/3scale/3scale-amp-openshift-templates/2.0.0.GA/amp/amp.yml
yaml2json amp.yml |jq '(.objects[]|select(.kind== "DeploymentConfig").spec.replicas) |= 0' > amp.json

34
roles/3scale/tasks/main.yml

@ -0,0 +1,34 @@
---
- name: Create an empty threescale_options variable if it does not exist
set_fact:
threescale_options: {}
when: threescale_options is not defined
tags: vars
- name: Provision default values for the 3scale_options
set_fact:
threescale_options: "{{ threescale_default_options|combine(threescale_options) }}"
tags: vars
- name: Get a list of existing projects
command: oc get projects -o name
register: oc_get_projects
- name: Create a new project for 3scale
command: oc new-project "{{ threescale_options.project }}"
when: "project/" + threescale_options.project not in oc_get_projects.stdout_lines
- name: Process the OpenShift Template and create the OpenShift objects for the hostpath-provisioner
shell: oc process -f "{{ threescale_options.template }}" -p "TENANT_NAME={{ threescale_options.tenant_name }}" -p "WILDCARD_DOMAIN={{ threescale_options.wildcard_domain }}" | oc create -f - -n "{{ threescale_options.project }}"
- name: Get Admin Username
command: oc get dc system-app -n "{{ threescale_options.project }}" -o 'jsonpath={.spec.template.spec.containers[0].env[?(@.name=="USER_LOGIN")].value}'
register: username
- name: Get Admin Password
command: oc get dc system-app -n "{{ threescale_options.project }}" -o 'jsonpath={.spec.template.spec.containers[0].env[?(@.name=="USER_PASSWORD")].value}'
register: password
- name: 3scale is ready !
debug: msg="Login on https://{{ threescale_options.tenant_name }}-admin.{{ threescale_options.wildcard_domain }} with username = '{{ username.stdout }}' and password = '{{ password.stdout }}'"

7
roles/3scale/vars/main.yml

@ -0,0 +1,7 @@
---
threescale_default_options:
template: https://raw.githubusercontent.com/nmasse-itix/OpenShift-Lab/master/roles/3scale/files/amp.json
project: 3scale
tenant_name: 3scale
wildcard_domain: "{{ openshift_master_default_subdomain }}"
Loading…
Cancel
Save