Patrick T. Rutledge III
2019-03-25 f19ad8d0fe5b2181e99b2dc0b0a8dd323638b09e
commit | author | age
b68adb 1 = ocp-workload-codeready-workspaces - Sample Config
M 2
3 == Role overview
4
5 * This is a simple role that does the following:
6 ** Playbook: link:./tasks/pre_workload.yml[pre_workload.yml] - Sets up an
7  environment for the workload deployment
8 *** Adds a user to a list of groups defined in the
9  link:./defaults/main.yml[defaults file].
10 *** Sets a cluster resource quota for the user based on the variables in the
11  link:./defaults/main.yml[defaults file] .
12 *** Debug task will print out: `pre_workload Tasks Complete`
13
14 ** Playbook: link:./tasks/workload.yml[workload.yml] - Used to deploy the actual
15  workload, i.e, 3scale, Mobile or some Demo
16 *** This role doesn't do anything here
17 *** Debug task will print out: `workload Tasks Complete`
18
19 ** Playbook: link:./tasks/post_workload.yml[post_workload.yml] - Used to
20  configure the workload after deployment
21 *** This role doesn't do anything here
22 *** Debug task will print out: `post_workload Tasks Complete`
23
24 == Set up your Ansible inventory file
25
26 * You will need to create an Ansible inventory file to define your connection
27  method to your host (Master/Bastion with OC command)
28
29 * You can also use the command line to define the hosts directly if your `ssh`
30  configuration is set to connect to the host correctly
31
32 * You can also use the command line to use localhost or if your cluster is
33  already authenticated and configured in your `oc` configuration
34 [source, ini]
35
36 .example inventory file
37 ----
38 [gptehosts:vars]
39 ansible_ssh_private_key_file=~/.ssh/keytoyourhost.pem
40 ansible_user=ec2-user
41
42 [gptehosts:children]
43 openshift
44
45 [openshift]
46 bastion.cluster1.openshift.opentlc.com
47 bastion.cluster2.openshift.opentlc.com
48 bastion.cluster3.openshift.opentlc.com ansible_ssh_host=ec2-11-111-111-11.us-west-2.compute.amazonaws.com
49 bastion.cluster4.openshift.opentlc.com
50
51
52 [dev]
53 bastion.cluster1.openshift.opentlc.com
54 bastion.cluster2.openshift.opentlc.com
55
56
57 [prod]
58 bastion.cluster3.openshift.opentlc.com
59 bastion.cluster4.openshift.opentlc.com
60 ----
61
62
63 == Review the defaults variable file
64
65 * This file link:./defaults/main.yml[./defaults/main.yml] contains all the variables you
66  need to define to control the deployment of your workload.
67
68 * You can modify any of these default values by adding
69 `-e"variable_name=variable_value"` to the command line
70
71 === Deploy Workload on OpenShift Cluster from an existing playbook:
72
73 [source,yaml]
74 ----
75 - name: Deploy a workload role on a master host
76   hosts: all
77   become: true
78   gather_facts: False
79   tags:
80     - step007
81   roles:
82     - { role: "{{ocp_workload}}", when: 'ocp_workload is defined' }
83
84 ----
85 NOTE: You might want to change `hosts: all` to fit your requirements
86
87
88 === Deploy a Workload with the `ocp-workload` playbook [Mostly for testing]
89 ----
90 HOST_GUID=dev311
91 TARGET_HOST="bastion.dev311.openshift.opentlc.com"
92 OCP_USERNAME="mcouliba-redhat.com"
93 WORKLOAD="ocp-workload-codeready-workspaces"
94 GUID=1907
95
96 # a TARGET_HOST is specified in the command line, without using an inventory file
97 ansible-playbook -i ${TARGET_HOST}, ./configs/ocp-workloads/ocp-workload.yml \
98                  -e"ansible_ssh_private_key_file=~/.ssh/id_rsa" \
99                  -e"ansible_user=opentlc-mgr" \
100                     -e"ocp_username=${OCP_USERNAME}" \
101                     -e"ocp_workload=${WORKLOAD}" \
102                     -e"guid=${GUID}" \
103                     -e"ocp_apps_domain=apps.${HOST_GUID}.openshift.opentlc.com" \
104                     -e"ACTION=create"
105
106 ----
107
108 === To Delete an environment
109 ----
110 HOST_GUID=dev311
111 TARGET_HOST="bastion.dev311.openshift.opentlc.com"
112 OCP_USERNAME="mcouliba-redhat.com"
113 WORKLOAD="ocp-workload-codeready-workspaces"
114 GUID=1907
115
116 # a TARGET_HOST is specified in the command line, without using an inventory file
117 ansible-playbook -i ${TARGET_HOST}, ./configs/ocp-workloads/ocp-workload.yml \
118                  -e"ansible_ssh_private_key_file=~/.ssh/id_rsa" \
119                     -e"ansible_user=opentlc-mgr" \
120                     -e"ocp_username=${OCP_USERNAME}" \
121                     -e"ocp_workload=${WORKLOAD}" \
122                     -e"guid=${GUID}" \
123                     -e"ACTION=remove"
124 ----