Pranav Gaikwad
2020-02-13 daaa989d3770ee557bb3f37cf035da92ecf99ef3
New workload for demo file uploader application (#1148)

* added file uploader demo app

* updated readme
7 files added
100 ■■■■■ changed files
ansible/roles/ocp-workload-file-uploader/README.adoc 37 ●●●●● patch | view | raw | blame | history
ansible/roles/ocp-workload-file-uploader/defaults/main.yml 2 ●●●●● patch | view | raw | blame | history
ansible/roles/ocp-workload-file-uploader/tasks/main.yml 20 ●●●●● patch | view | raw | blame | history
ansible/roles/ocp-workload-file-uploader/tasks/post_workload.yml 15 ●●●●● patch | view | raw | blame | history
ansible/roles/ocp-workload-file-uploader/tasks/pre_workload.yml 6 ●●●●● patch | view | raw | blame | history
ansible/roles/ocp-workload-file-uploader/tasks/remove_workload.yml 11 ●●●●● patch | view | raw | blame | history
ansible/roles/ocp-workload-file-uploader/tasks/workload.yml 9 ●●●●● patch | view | raw | blame | history
ansible/roles/ocp-workload-file-uploader/README.adoc
New file
@@ -0,0 +1,37 @@
= File Uploader App
== Overview
This workload is a demo web application to upload arbitrary files to the server. It is intended to aid the demonstration and testing of OpenShift Cluster Application Migration Tool.
== Deploying the workload
[source, bash]
----
ansible-playbook -i "bastion.${GUID}.${BASE_DOMAIN}", ./ansible/configs/ocp-workloads/ocp-workload.yml \
    -e"ansible_ssh_private_key_file=${ANSIBLE_USER_KEY_FILE}" \
    -e"ansible_user=${ANSIBLE_USER}" \
    -e"ocp_workload=ocp-workload-file-uploader" \
    -e"silent=False" \
    -e"ACTION=create" \
    -e @./secret.yaml \ <1>
----
=== Usage
The app is launched in `file-uploader` namespace.
To get the URL to the front end : `oc get route -n file-uploader file-uploader -o go-template={{ .spec.host }}{{ println }}`
=== Delete the Workload
[source, bash]
----
ansible-playbook -i "bastion.${GUID}.${BASE_DOMAIN}", ./ansible/configs/ocp-workloads/ocp-workload.yml \
    -e"ansible_ssh_private_key_file=${ANSIBLE_USER_KEY_FILE}" \
    -e"ansible_user=${ANSIBLE_USER}" \
    -e"ocp_workload=ocp-workload-file-uploader" \
    -e"silent=False" \
    -e"ACTION=remove" \
    -e @./secret.yaml \
----
ansible/roles/ocp-workload-file-uploader/defaults/main.yml
New file
@@ -0,0 +1,2 @@
file_uploader_app_manifest: https://raw.githubusercontent.com/fusor/mig-demo-apps/master/apps/file-uploader/manifest.yaml
silent: false
ansible/roles/ocp-workload-file-uploader/tasks/main.yml
New file
@@ -0,0 +1,20 @@
---
- name: Running Pre Workload Tasks
  import_tasks: ./pre_workload.yml
  become: false
  when: ACTION == "create" or ACTION == "provision"
- name: Running Workload Tasks
  import_tasks: ./workload.yml
  become: false
  when: ACTION == "create" or ACTION == "provision"
- name: Running Post Workload Tasks
  import_tasks: ./post_workload.yml
  become: false
  when: ACTION == "create" or ACTION == "provision"
- name: Running Workload removal Tasks
  import_tasks: ./remove_workload.yml
  become: false
  when: ACTION == "destroy" or ACTION == "remove"
ansible/roles/ocp-workload-file-uploader/tasks/post_workload.yml
New file
@@ -0,0 +1,15 @@
---
- name: "Gathering facts about launched service"
  block:
  - shell: "oc get route -n file-uploader file-uploader -o go-template='{{ '{{' }} .spec.host {{ '}}' }}{{ '{{' }} println {{ '}}' }}'"
    register: file_uploader_route
  - name: "Please note the following information..."
    debug:
      msg: "App is launched at - {{ file_uploader_route.stdout }}"
# Leave this as the last task in the playbook.
- name: post_workload tasks complete
  debug:
    msg: "Post-Workload Tasks completed successfully."
  when: not silent|bool
ansible/roles/ocp-workload-file-uploader/tasks/pre_workload.yml
New file
@@ -0,0 +1,6 @@
---
# Leave this as the last task in the playbook.
- name: pre_workload tasks complete
  debug:
    msg: "Pre-Workload tasks completed successfully."
  when: not silent|bool
ansible/roles/ocp-workload-file-uploader/tasks/remove_workload.yml
New file
@@ -0,0 +1,11 @@
---
- name: "Removing File Uploader App"
  shell: "{{ item }}"
  loop:
  - "oc delete --ignore-not-found=true -f {{ file_uploader_app_manifest }}"
  - "oc delete --ignore-not-found=true project file-uploader"
# Leave this as the last task in the playbook.
- name: remove_workload tasks complete
  debug:
    msg: "Remove Workload tasks completed successfully."
  when: not silent|bool
ansible/roles/ocp-workload-file-uploader/tasks/workload.yml
New file
@@ -0,0 +1,9 @@
---
- name: "Deploying File Uploader App"
  shell: "oc apply -f {{ file_uploader_app_manifest }}"
# Leave this as the last task in the playbook.
- name: workload tasks complete
  debug:
    msg: "Workload Tasks completed successfully."
  when: not silent|bool