Christian Hernandez
2020-01-07 4671d4ed60544a222e08b1781ab4991e0715aa87
commit | author | age
53938a 1 # vim: set ft=ansible
TK 2 ---
3
4 # Implement your Workload deployment tasks here
5
09cb5e 6 # oc new-app https://raw.githubusercontent.com/openshift-homeroom/workshop-dashboard/4.3.0/templates/production-cluster-admin.json \
EJ 7 # --param TERMINAL_IMAGE="quay.io/thoraxe/lab-ocp-cns:production" --param PROJECT_NAME="lab-ocp-cns" \
8 # --param WORKSHOP_ENVVARS="`cat /tmp/settings.sh`"
375ba6 9
09cb5e 10 - name: create the variable template file
EJ 11   template: 
12     src: files/workshop-settings.j2
13     dest: /tmp/workshop-settings.sh
14
15 - name: copy the openshift template to the remote host
16   copy:
17     src: files/production-cluster-admin.json
18     dest: /tmp/production-cluster-admin.json
19
20 #- name: set variables
21 #  set_fact:
22 #    project_name: labguide
23 #    app_name: admin #don't forget to replace this value under ServiceAccount.metadata.annotations.
24 #    terminal_image: quay.io/openshiftlabs/workshop-dashboard:3.5.0
25 #    # console_version: 4.1.0 replaced by grabbing exact quay image.
26 #    workshop_env: "API_URL={{ api_url }} \
27 #          MASTER_URL={{ master_url }} \
28 #          KUBEADMIN_PASSWORD={{ kubeadmin_password }} \
29 #          SSH_USERNAME={{ student_name }} \
30 #          SSH_PASSWORD={{ student_password }} \
31 #          BASTION_FQDN={{ bastion_fqdn }} \
32 #          GUID={{ guid }} \
33 #          ROUTE_SUBDOMAIN={{ route_subdomain }} \
34 #          HOME_PATH=/opt/app-root/src"
35 #    serviceaccounts_oauth_redirectref_first: "'{\"kind\":\"OAuthRedirectReference\",\"apiVersion\":\"v1\",\"reference\":{\"kind\":\"Route\",\"name\":\"admin\"}}'"
36 #    download_url: https://raw.githubusercontent.com/openshift/openshift-cns-testdrive/ocp4-prod/labguide
37 #    workshop_file: _ocp_admin_testdrive.yaml
38 #  register: facts_set
39 #- debug:
40 #    var: facts_set
375ba6 41
TK 42 - name: create the Project
53938a 43   k8s:
TK 44     state: present
09cb5e 45     name: lab-ocp-cns
EJ 46     kind: Project
375ba6 47     api_version: project.openshift.io/v1
09cb5e 48   
53938a 49
09cb5e 50 - name: deploy the labguide with the params file
EJ 51   shell: |
52     oc new-app -n lab-ocp-cns /tmp/production-cluster-admin.json \
4671d4 53     --param TERMINAL_IMAGE="quay.io/thoraxe/lab-ocp-cns:{{ HOMEROOM_IMAGE }}" --param PROJECT_NAME="lab-ocp-cns" \
09cb5e 54     --param WORKSHOP_ENVVARS="`cat /tmp/workshop-settings.sh`"
375ba6 55
399b77 56 - name: add kubeadmin to RoleBinding admin enabling route access
TK 57   k8s:
09cb5e 58     namespace: lab-ocp-cns
399b77 59     state: present
TK 60     definition:
61       apiVersion: rbac.authorization.k8s.io/v1
62       kind: RoleBinding
63       metadata:
09cb5e 64         name: dashboard-admin
399b77 65         labels:
09cb5e 66           app: dashboard
399b77 67       subjects:
TK 68       - kind: User
69         apiGroup: rbac.authorization.k8s.io
70         name: 'kube:admin'
71       roleRef:
72         apiVersion: rbac.authorization.k8s.io/v1
73         kind: ClusterRole
74         name: admin
75   register: RoleBinding
09cb5e 76
EJ 77 - name: fetch the created route for output
78   k8s_facts:
79     api_version: route.openshift.io/v1
80     kind: Route
81     name: dashboard
82     namespace: lab-ocp-cns
83   register: Route
399b77 84
375ba6 85 - debug:
TK 86     msg:
32ecb9 87     - "user.info: "
09cb5e 88     - "user.info: Access the workshop at '{{ Route.resources[0].spec.host }}'"
399b77 89     - "user.info: Login with 'kubeadmin' and '{{ kubeadmin_password }}'"
32ecb9 90     - "user.info: "
c14d29 91     - "user.info: Workshop may not be accessible until rollout finishes shortly."
53938a 92
TK 93 # Leave this as the last task in the playbook.
375ba6 94
53938a 95 - name: workload tasks complete
TK 96   debug:
97     msg: "Workload Tasks completed successfully."
98   when: not silent|bool