Jiří Locker
2020-02-13 6ac16f67f5dc12123ca6d53b1d71fde39981d3b1
commit | author | age
37d997 1 = ocp-workload-developer-environment - Sample Config
JL 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 == Review the defaults variable file
25
26 * This file link:./defaults/main.yml[./defaults/main.yml] contains all the variables you
27  need to define to control the deployment of your workload.
28
29 * You can modify any of these default values by adding
30 `-e"variable_name=variable_value"` to the command line
31
32 === Deploy Workload on OpenShift Cluster from an existing playbook:
33
34 [source,yaml]
35 ----
36 - name: Deploy a workload role on a master host
37   hosts: all
38   become: true
39   gather_facts: False
40   tags:
41     - step007
42   roles:
43     - { role: "{{ocp_workload}}", when: 'ocp_workload is defined' }
44
45 ----
46 NOTE: You might want to change `hosts: all` to fit your requirements
47
48
49 === Common configuration to run these playbooks
50 You should have these environment variables defined/exported in your system in order
51 to run these playbooks.
52
53 ----
54 HOST_GUID=dev37
55 TARGET_HOST="bastion.$HOST_GUID.openshift.opentlc.com"
56 OCP_USERNAME="ddoyle-redhat.com"
57 SSH_USER="opentlc-mgr"
58 SSH_PRIVATE_KEY="id_rsa"
59 GUID=duncandoyle
60 ----
61
62 === Deploy a Workload with the `ocp-workload` playbook [Mostly for testing]
63 ----
64 WORKLOAD="ocp-workload-optaweb-employee-rostering"
65
66 # a TARGET_HOST is specified in the command line, without using an inventory file
67 ansible-playbook -i ${TARGET_HOST}, ./configs/ocp-workloads/ocp-workload.yml \
6ac16f 68                  -e"ansible_python_interpreter=/usr/bin/python" \
37d997 69                  -e"ansible_ssh_private_key_file=~/.ssh/${SSH_PRIVATE_KEY}" \
JL 70                  -e"ansible_user=${SSH_USER}" \
71                  -e"ocp_username=${OCP_USERNAME}" \
72                  -e"ocp_workload=${WORKLOAD}" \
73                  -e"guid=${GUID}" \
74                  -e"ocp_user_needs_quota=true" \
75                  -e"ocp_master=master.${HOST_GUID}.openshift.opentlc.com" \
76                  -e"ocp_apps_domain=apps.${HOST_GUID}.openshift.opentlc.com" \
77                  -e"ACTION=create"
78 ----
79
80 === To Delete an environment
81 Use the common configuration first. Then run this.
82
83 ----
84 WORKLOAD="ocp-workload-optaweb-employee-rostering"
85
86 # a TARGET_HOST is specified in the command line, without using an inventory file
87 ansible-playbook -i ${TARGET_HOST}, ./configs/ocp-workloads/ocp-workload.yml \
88                     -e"ansible_ssh_private_key_file=~/.ssh/${SSH_PRIVATE_KEY}" \
89                     -e"ansible_user=${SSH_USER}" \
90                     -e"ocp_username=${OCP_USERNAME}" \
91                     -e"ocp_workload=${WORKLOAD}" \
92                     -e"guid=${GUID}" \
93                     -e"ACTION=remove"
94 ----
95
96 == Set up your Ansible inventory file
97
98 * You can create an Ansible inventory file to define your connection
99  method to your host (Master/Bastion with OC command)
100
101 * You can also use the command line to define the hosts directly if your `ssh`
102  configuration is set to connect to the host correctly
103
104 * You can also use the command line to use localhost or if your cluster is
105  already authenticated and configured in your `oc` configuration
106 [source, ini]
107
108 .example inventory file
109 ----
110 [gptehosts:vars]
111 ansible_ssh_private_key_file=~/.ssh/keytoyourhost.pem
112 ansible_user=ec2-user
113
114 [gptehosts:children]
115 openshift
116
117 [openshift]
118 bastion.cluster1.openshift.opentlc.com
119 bastion.cluster2.openshift.opentlc.com
120 bastion.cluster3.openshift.opentlc.com ansible_ssh_host=ec2-11-111-111-11.us-west-2.compute.amazonaws.com
121 bastion.cluster4.openshift.opentlc.com
122
123
124 [dev]
125 bastion.cluster1.openshift.opentlc.com
126 bastion.cluster2.openshift.opentlc.com
127
128
129 [prod]
130 bastion.cluster3.openshift.opentlc.com
131 bastion.cluster4.openshift.opentlc.com
132 ----