Hong
2020-02-17 5c7667b1884ca9627cee70a2661ecf9583cc06e5
2 new workloads for existing OPEN courses: "EAP 7 Development" and "AMQ Streams Foundations" (#1156)

* https://github.com/redhat-gpe/3scale_implementation/issues/191

* https://github.com/redhat-gpe/eap_dev_7/issues/28

* https://github.com/redhat-gpe/amq_streams_foundations/issues/37

* https://github.com/redhat-gpe/eap_dev_7/issues/28
11 files added
232 ■■■■■ changed files
ansible/roles/eap7-dev/README.adoc 16 ●●●●● patch | view | raw | blame | history
ansible/roles/eap7-dev/defaults/main.yml 3 ●●●●● patch | view | raw | blame | history
ansible/roles/eap7-dev/tasks/main.yml 33 ●●●●● patch | view | raw | blame | history
ansible/roles/eap7-dev/tasks/packages.yml 22 ●●●●● patch | view | raw | blame | history
ansible/roles/ocp-workload-amq-streams/defaults/main.yml 22 ●●●●● patch | view | raw | blame | history
ansible/roles/ocp-workload-amq-streams/readme.adoc 54 ●●●●● patch | view | raw | blame | history
ansible/roles/ocp-workload-amq-streams/tasks/main.yml 22 ●●●●● patch | view | raw | blame | history
ansible/roles/ocp-workload-amq-streams/tasks/post_workload.yml 5 ●●●●● patch | view | raw | blame | history
ansible/roles/ocp-workload-amq-streams/tasks/pre_workload.yml 32 ●●●●● patch | view | raw | blame | history
ansible/roles/ocp-workload-amq-streams/tasks/remove_workload.yml 17 ●●●●● patch | view | raw | blame | history
ansible/roles/ocp-workload-amq-streams/tasks/workload.yml 6 ●●●●● patch | view | raw | blame | history
ansible/roles/eap7-dev/README.adoc
New file
@@ -0,0 +1,16 @@
= eap7-dev
== NOTES
. This workload provisions a VM runs on RHEL 7, for use in the *EAP 7 Development* course
. The VM contains the following software that will be used as part of the labs in the course:
.. curl utility
.. EAP 7
.. Apache Maven 3.6.3
.. JDK 1.8
== Accessing the VM
. Provision the VM through labs.opentlc.com
. SSH into the VM
. Execute command `sudo jboss`
ansible/roles/eap7-dev/defaults/main.yml
New file
@@ -0,0 +1,3 @@
---
student_user: jboss
student_sudo: yes
ansible/roles/eap7-dev/tasks/main.yml
New file
@@ -0,0 +1,33 @@
---
######################### Install Software Packages
- name: Install Software Packages
  import_tasks: ./packages.yml
  tags:
    - install_software_packages
- file:
    path: "/home/{{student_user}}"
    state: directory
    owner: "{{student_user}}"
    mode: 0755
- file:
    path: "/srv"
    state: directory
    owner: "{{student_user}}"
    mode: 0755
- name: download apache-maven-3.6.3
  ignore_errors: true
  get_url:
    url: https://gpte-public.s3.amazonaws.com/apache-maven-3.6.3-bin.tar.gz
    dest: /opt
    mode: 0440
- name: download jq-linux64
  ignore_errors: true
  get_url:
    url: https://gpte-public.s3.amazonaws.com/jq-linux64
    dest: /home/jboss
    mode: 0440
ansible/roles/eap7-dev/tasks/packages.yml
New file
@@ -0,0 +1,22 @@
#vim: set ft=ansible:
---
- name: install software packages
  yum:
    name: "{{ item }}"
    state: present
  with_items:
      - git
      - zip
      - bzip2
      - unzip
      - gettext
      - wget
      - curl
      - telnet
      - tree
      - bind-utils
      - device-mapper-libs
      - device-mapper-event-libs
      - java-1.8.0-openjdk-devel
  tags:
   - install_software_packages
ansible/roles/ocp-workload-amq-streams/defaults/main.yml
New file
@@ -0,0 +1,22 @@
---
become_override: true
ocp_username: admin
ocp_user_needs_quota: True
ocp_user_groups:
  - OPENTLC-PROJECT-PROVISIONERS
quota_requests_cpu: 5
quota_limits_cpu: 10
quota_requests_memory: '6Gi'
quota_limits_memory: '20Gi'
quota_configmaps: 10
quota_pods: 20
quota_persistentvolumeclaims: 20
quota_services: 30
quota_secrets: 30
quota_requests_storage: 50Gi
admin_user: admin
ansible/roles/ocp-workload-amq-streams/readme.adoc
New file
@@ -0,0 +1,54 @@
= ocp-workload-amq-streams
== Overview
=== Purpose
This role creates an OCP Cluster primarily for supporting elab students of the _AMQ Streams Foundations_ course.
== Accessing the Cluster
. Retrieve <cluster_host_name> from notification email
. Use `oc` utility to login: `oc login <cluster_host_name>`
== Deploy a Workload with the `ocp-workload` playbook
----
GUID=admin
HOST_GUID=na
TARGET_HOST="bastion.$HOST_GUID.openshift.opentlc.com"
OCP_USERNAME="<OPENTLC_ID>"
WORKLOAD="ocp-workload-amq-streams"
SSH_USERNAME="<OPENTLC_ID>"
SSH_PRIVATE_KEY="id_ocp"
# a TARGET_HOST is specified in the command line, without using an inventory file
ansible-playbook -i ${TARGET_HOST}, ./configs/ocp-workloads/ocp-workload.yml \
                 -e"ansible_ssh_private_key_file=~/.ssh/${SSH_PRIVATE_KEY}" \
                 -e"ansible_user=${SSH_USERNAME}" \
                    -e"ocp_username=${OCP_USERNAME}" \
                    -e"ocp_workload=${WORKLOAD}" \
                    -e"guid=${GUID}" \
                    -e"ocp_user_needs_quota=true" \
                    -e"ocp_apps_domain=apps.${HOST_GUID}.openshift.opentlc.com" \
                    -e"ACTION=create"
----
== To Delete an environment
----
GUID=admin
HOST_GUID=na
TARGET_HOST="bastion.$HOST_GUID.openshift.opentlc.com"
OCP_USERNAME="<opentlc-ID>"
WORKLOAD="ocp-workload-amq-streams"
SSH_USERNAME="<opentlc-ID>"
SSH_PRIVATE_KEY="id_ocp"
# a TARGET_HOST is specified in the command line, without using an inventory file
ansible-playbook -i ${TARGET_HOST}, ./configs/ocp-workloads/ocp-workload.yml \
                 -e"ansible_ssh_private_key_file=~/.ssh/${SSH_PRIVATE_KEY}" \
                 -e"ansible_user=${SSH_USERNAME}" \
                    -e"ocp_username=${OCP_USERNAME}" \
                    -e"ocp_workload=${WORKLOAD}" \
                    -e"guid=${GUID}" \
                    -e"ACTION=remove"
----
ansible/roles/ocp-workload-amq-streams/tasks/main.yml
New file
@@ -0,0 +1,22 @@
---
- name: Running Pre Workload Tasks
  import_tasks: ./pre_workload.yml
  become: "{{ become_override | bool }}"
  when: ACTION == "create" or ACTION == "provision"
- name: Running Workload Tasks
  import_tasks: ./workload.yml
  become: "{{ become_override | bool }}"
  when: ACTION == "create" or ACTION == "provision"
- name: Running Post Workload Tasks
  import_tasks: ./post_workload.yml
  become: "{{ become_override | bool }}"
  when: ACTION == "create" or ACTION == "provision"
- name: Running Workload removal Tasks
  import_tasks: ./remove_workload.yml
  become: "{{ become_override | bool }}"
  when: ACTION == "destroy" or ACTION == "remove"
ansible/roles/ocp-workload-amq-streams/tasks/post_workload.yml
New file
@@ -0,0 +1,5 @@
---
- name: post_workload Tasks Complete
  debug:
    msg: "Post-Software checks completed successfully"
ansible/roles/ocp-workload-amq-streams/tasks/pre_workload.yml
New file
@@ -0,0 +1,32 @@
---
- name: Add user to developer group (allowed to create projects)
  shell: "oadm groups add-users {{item}} {{ocp_username}}"
  register: groupadd_register
  with_items: "{{ocp_user_groups}}"
  when: ocp_username is defined and ocp_user_groups is defined
# - name: test that command worked
#   debug:
#     var: groupadd_register
#     verbosity: 2
- name: Create user Quota - clusterresourcequota
  shell: |
        oc create clusterquota clusterquota-"{{ocp_username}}-{{guid}}" \
        --project-annotation-selector=openshift.io/requester="{{ocp_username}}" \
        --hard requests.cpu="{{quota_requests_cpu}}" \
        --hard limits.cpu="{{quota_limits_cpu}}"  \
        --hard requests.memory="{{quota_requests_memory}}" \
        --hard limits.memory="{{quota_limits_memory}}" \
        --hard configmaps="{{quota_configmaps}}" \
        --hard pods="{{quota_pods}}" \
        --hard persistentvolumeclaims="{{quota_persistentvolumeclaims}}"  \
        --hard services="{{quota_services}}" \
        --hard secrets="{{quota_secrets}}" \
        --hard requests.storage="{{quota_requests_storage}}"
  ignore_errors: true
- name: pre_workload Tasks Complete
  debug:
    msg: "Pre-Software checks completed successfully"
ansible/roles/ocp-workload-amq-streams/tasks/remove_workload.yml
New file
@@ -0,0 +1,17 @@
---
- name: post_workload Tasks Complete
  debug:
    msg: "Pre-Software checks completed successfully - Removed"
- name: Remove user Quota - oc delete clusterresourcequota  "clusterquota-{{ocp_username}}-{{guid}}"
  shell: oc delete clusterresourcequota clusterquota-{{ocp_username}}-{{guid}}
  ignore_errors: true
- name: Remove user Quota - oc delete clusterresourcequota  "clusterquota-{{ocp_username}}"
  shell: oc delete clusterresourcequota clusterquota-{{ocp_username}}
  ignore_errors: true
- name: post_workload Tasks Complete
  debug:
    msg: "Post-Software checks completed successfully - Removed"
ansible/roles/ocp-workload-amq-streams/tasks/workload.yml
New file
@@ -0,0 +1,6 @@
---
- name: workload Tasks Complete
  debug:
    msg: workload Tasks Complete