#############################################
|
# Deployment of Lab Instructions in cluster #
|
#############################################
|
|
- name: Import workshopper image
|
shell: >
|
oc import-image quay.io/osevg/workshopper -n openshift --confirm
|
|
- name: Check if project exists
|
k8s_facts:
|
api_version: apps.openshift.io/v1
|
kind: Project
|
name: "{{labguide_project_name}}"
|
register: project_exists
|
|
- name: Create {{labguide_project_name}} project
|
k8s:
|
state: present
|
definition:
|
apiVersion: project.openshift.io/v1
|
kind: Project
|
metadata:
|
name: "{{labguide_project_name}}"
|
when:
|
- project_exists.resources | list | length < 1
|
|
- name: check if guide is deployed
|
k8s_facts:
|
api_version: apps.openshift.io/v1
|
kind: DeploymentConfig
|
name: "{{ _deployed_guide_name }}"
|
namespace: "{{labguide_project_name}}"
|
register: guide_exists
|
|
- name: Workshop guide deployment
|
shell: >
|
oc new-app -n {{labguide_project_name}} --name {{ _deployed_guide_name }} --image-stream=workshopper
|
-e API_URL={{api_url}}
|
-e MASTER_URL={{console_url}}
|
-e ROUTE_SUBDOMAIN={{ apps_base_domain }}
|
-e CONTENT_URL_PREFIX={{_deployed_guide_string_url}}
|
-e WORKSHOPS_URLS={{_deployed_guide_string_url}}/_index.yml
|
when:
|
- guide_exists.resources | list | length < 1
|
|
- name: lab guide route
|
k8s:
|
state: present
|
definition:
|
apiVersion: route.openshift.io/v1
|
kind: Route
|
metadata:
|
labels:
|
app: "{{ _deployed_guide_name }}"
|
name: "{{ _deployed_guide_name }}"
|
namespace: "{{labguide_project_name}}"
|
spec:
|
port:
|
targetPort: 8080-tcp
|
to:
|
kind: Service
|
name: "{{ _deployed_guide_name }}"
|
weight: 100
|
wildcardPolicy: None
|
when:
|
- guide_exists.resources | list | length < 1
|
|
# - name: Clean temp directory
|
# file:
|
# state: absent
|
# path: "/tmp/{{lab_name}}"
|
|
|
# - name: Check that the binary doesn't exists
|
# stat:
|
# path: /tmp/{{lab_name}}/currency
|
# register: stat_result
|
|
# - name: clone a private repository into
|
# git:
|
# repo: "{{_lab_code_repo}}"
|
# version: master
|
# dest: /tmp/{{lab_name}}
|
# update: yes
|
# when: stat_result.stat.exists == False
|
|
# - name: check if user project exists
|
# k8s_facts:
|
# api_version: apps.openshift.io/v1
|
# kind: Project
|
# name: "{{content_sources_project_name}}"
|
# register: user_project_exists
|
|
# - name: "create {{content_sources_project_name}} project"
|
# k8s:
|
# state: present
|
# definition:
|
# apiVersion: project.openshift.io/v1
|
# kind: Project
|
# metadata:
|
# name: "{{content_sources_project_name}}"
|
# when:
|
# - user_project_exists.resources | list | length < 1
|
|
############################################
|
## OPERATOR SUBSCRIPTIONS ##
|
############################################
|
|
# - name: Check if RedHat csc exists
|
# k8s_facts:
|
# api_version: operators.coreos.com/v1
|
# kind: CatalogSourceConfig
|
# name: installed-redhat-openshift-operators
|
# namespace: openshift-marketplace
|
# register: redhat_csc_exists
|
|
# - debug:
|
# var: redhat_csc_exists
|
# verbosity: 3
|
|
# - name: Check if Community csc exists
|
# k8s_facts:
|
# api_version: operators.coreos.com/v1
|
# kind: CatalogSourceConfig
|
# name: installed-community-openshift-operators
|
# namespace: openshift-marketplace
|
# register: community_csc_exists
|
|
# - name: Check if AMQStreans subscription exists
|
# k8s_facts:
|
# api_version: operators.coreos.com/v1alpha1
|
# kind: Subscription
|
# name: amq-streams
|
# namespace: openshift-operators
|
# register: amqstreans_sub_exists
|
|
# - name: Check if CamelK subscription exists
|
# k8s_facts:
|
# api_version: operators.coreos.com/v1alpha1
|
# kind: Subscription
|
# name: camel-k
|
# namespace: openshift-operators
|
# register: camelk_sub_exists
|
|
|
#- name: Red Hat CSC deployment
|
# shell: oc apply -f {{role_path}}/templates/installed-redhat-openshift-operators.yml -n openshift-marketplace
|
|
#- name: Community CSC deployment
|
# shell: oc apply -f {{role_path}}/templates/installed-community-openshift-operators.yml -n openshift-marketplace
|
|
#- name: CamelK subscription deployment
|
# shell: oc apply -f {{role_path}}/templates/camelk-subscription.yml -n openshift-operators
|
|
#- name: AMQ Streams subscription deployment
|
# shell: oc apply -f {{role_path}}/templates/amqstreams-subscription.yml -n openshift-operators
|
|
##############################
|
## CURRENCY ##
|
##############################
|
|
- set_fact:
|
appname: currency
|
|
- set_fact:
|
project_name: content-sources
|
|
# - name: Running Pre Workload Tasks
|
# import_tasks: ./workload_app.yml
|
# become: "{{ become_override | bool }}"
|
|
- name: Check if {{project_name}} project exists
|
k8s_facts:
|
api_version: apps.openshift.io/v1
|
kind: Project
|
name: "{{project_name}}"
|
register: project_exists
|
|
- name: Create {{labguide_project_name}} project
|
k8s:
|
state: present
|
definition:
|
apiVersion: project.openshift.io/v1
|
kind: Project
|
metadata:
|
name: "{{project_name}}"
|
when:
|
- project_exists.resources | list | length < 1
|
|
- name: Import {{appname}} image
|
shell: oc import-image quay.io/pnavascu/{{appname}}:1.0.0 -n {{project_name}} --confirm
|
|
- name: Deploy {{appname}} application
|
shell: oc new-app -i {{appname}}:1.0.0 -n {{project_name}}
|
|
- name: Create {{appname}} route
|
shell: oc expose svc/{{appname}} -n {{project_name}}
|
|
# - name: Check that the binary doesn't exists
|
# stat:
|
# path: /tmp/{{lab_name}}/{{appname}}/target/{{appname}}-1.0.0.jar
|
# register: stat_result
|
|
# - name: Check that the binary doesn't exists
|
# stat:
|
# path: /tmp/{{lab_name}}/{{appname}}/target/{{appname}}-1.0.0.jar
|
# register: stat_result
|
|
# - name: Deploy {{appname}} server II
|
# shell: "mvn package"
|
# args:
|
# chdir: /tmp/{{lab_name}}/{{appname}}
|
# when: stat_result.stat.exists == False
|
|
# - name: Deploy {{appname}} server I
|
# shell: "odo project set {{project_name}}"
|
|
# - name: Check that the odo component doesn't exist
|
# stat:
|
# path: /tmp/{{lab_name}}/{{appname}}/.odo
|
# register: stat_result
|
|
# - name: Deploy {{appname}} server II
|
# shell: "odo create java {{appname}} --project {{project_name}} --binary target/{{appname}}-1.0.0.jar"
|
# args:
|
# chdir: /tmp/{{lab_name}}/{{appname}}
|
# when: stat_result.stat.exists == False
|
|
# - name: Deploy {{appname}} server III
|
# shell: "odo push"
|
# args:
|
# chdir: /tmp/{{lab_name}}/{{appname}}
|
|
# - name: workload tasks complete
|
# debug:
|
# msg: Workload Tasks completed successfully.
|
# when: not silent|bool
|
|
|
# ####################################
|
# ####### CONTENT SERVER ###########
|
# ####################################
|
|
- set_fact:
|
appname: contentserver
|
|
- name: Import {{appname}} image
|
shell: oc import-image quay.io/pnavascu/{{appname}}:1.0.0 -n openshift --confirm
|
|
# - name: Running Pre Workload Tasks
|
# import_tasks: ./workload_app.yml
|
# become: "{{ become_override | bool }}"
|
|
# ####################################
|
# ######### SVC REGISTRY ###########
|
# ####################################
|
|
- set_fact:
|
appname: serviceregistry
|
|
- name: Import {{appname}} image
|
shell: oc import-image quay.io/pnavascu/{{appname}}:1.0.0 -n openshift --confirm
|
|
# - name: Running Pre Workload Tasks
|
# import_tasks: ./workload_app.yml
|
# become: "{{ become_override | bool }}"
|
|
# - name: workload tasks complete
|
# debug:
|
# msg: "Workload Tasks completed successfully."
|
|
# when: not silent|bool
|