My Ansible Playbook to install an OpenShift Lab
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.

157 lines
4.7 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'
- 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
# 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: status.yml
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: wait_for.yml
static: no
vars:
pod_to_wait:
- backend-redis
- system-memcache
- system-mysql
- system-redis
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: wait_for.yml
static: no
vars:
pod_to_wait:
- backend-listener
tags: status
- name: Deploy everything else without any replicas
command: oc rollout latest "{{ item }}" -n "{{ threescale_project }}"
with_items:
- backend-listener
- 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: wait_for.yml
static: no
vars:
pod_to_wait:
- system-app
- system-resque
- system-sidekiq
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: wait_for.yml
static: no
vars:
pod_to_wait:
- backend-worker
- backend-cron
- system-sphinx
tags: status
- 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: wait_for.yml
static: no
vars:
pod_to_wait:
- apicast-staging
#- apicast-production
tags: status
- 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_tenant_name }}-admin.{{ threescale_wildcard_domain }} with username = '{{ username.stdout }}' and password = '{{ password.stdout }}'"
tags: status