Ondrej
2020-03-03 2b2dbbf393317a2918d8644f7a97231b5177cd91
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
 
== Setting up for OpenStack deployments
 
In this document we will explain how one could setup their laptop for AgnosticD deployment with OpenStack.
 
If you are a Red Hatter, you can use link:rhpds.redhat.com[rhpds.redhat.com] to request access to our OpenStack cluster.
. Log in to link:https://rhpds.opentlc.com[https://rhpds.redhat.com] using your opentlc user.
. Go to *Services* -> *Catalogs* -> *Events Development* -> *Summit DEV OSP Sandbox*.
. Click *Order* -> *Submit*
 
NOTE: You will receive three emails indicating the status of the environment and instructions for accessing the environment.
In the third email you receive all information you need to login to the client machine that would have the rest of required information.
 
NOTE: You can use the VM as your ansible host or copy the files over to your laptop and work locally.
 
 
=== Configure your environment for running OpenStack Ansible
 
. Please make sure the file `/etc/ansible/hosts` doesn't exist or is empty, otherwise this default inventory file will cause problems later. 
. Install `virtualenv` and `pip3` (On your laptop or on the clientVM):
+
[source, shell]
----
# on Linux
$ sudo yum install python3-pip python-virtualenv -y
# on Mac
$ brew install python pyenv-virtualenv
----
 
. Create virtualenv environment and download python requirements:
.. Create virtualenv and activate
+
[source, shell]
----
$ virtualenv openstack-ansible-2.9
 
##In Mac
$ pyenv virtualenv openstack-ansible-2.9
 
 
## In Mac, if you find the error " the error: error: pyenv: pip: command not found]", it could because you need pip3, in that case please do:
$ alias pip=pip3
$ pip install --upgrade pip
 
$ source openstack-ansible-2.9/bin/activate
 
## In Mac
$ source /Users/[USER]/.pyenv/versions/openstack-ansible-2.9/bin/activate
 
## ^replace [USER] with your username or the proper path
 
----
.. Install the python modules inside that virtualenv
*** On Mac
+
[source,shell]
----
$ pip3 install -r https://raw.githubusercontent.com/redhat-cop/agnosticd/development/ansible/configs/ocp4-disconnected-osp-lab/files/macos_requirements.txt
----
*** On Linux with Python 2
+
[source,shell]
----
(openstack-ansible-2.9) $ pip install -r https://raw.githubusercontent.com/redhat-cop/agnosticd/development/tools/virtualenvs/openstack-ansible-2.9-python2.txt
----
*** On Linux with python 3:
+
[source,shell]
----
(openstack-ansible-2.9) $ pip install -r https://raw.githubusercontent.com/redhat-cop/agnosticd/development/tools/virtualenvs/openstack-ansible-2.9-python3.txt
----
*** Multi-platform, latest modules (should work for all with both python2 and python3)
+
[source,shell]
----
(openstack-ansible-2.9) $ pip install -r https://raw.githubusercontent.com/redhat-cop/agnosticd/development/tools/virtualenvs/openstack-ansible-latest.txt
----
 
=== Getting your OpenStack Credentials
 
. Create the `~/.config/openstack/clouds.yaml` file on your laptop using the information provided in the final email.
+
[source,bash]
----
$ mkdir -p ~/.config/openstack
$ vim ~/.config/openstack/clouds.yaml
----
 
. Review your `~/.config/openstack/clouds.yaml`:
+
[source,bash]
----
cat ~/.config/openstack/clouds.yaml
clouds:
  35eb-project:
    auth:
      auth_url: "http://169.47.17.15:5000/v3"
      username: "35eb-user"
      project_name: "35eb-project"
      project_id: "1a79cf800ff94754bb495e2c1fd9d433"
      user_domain_name: "Default"
      password: "YOUR_TEMP_PASSWORD"
    region_name: "regionOne"
    interface: "public"
    identity_api_version: 3
----
 
. Check that your credentials are working:
+
[source,bash]
----
$ openstack --os-cloud=GUID-project server list
+--------------------------------------+-----------+--------+------------------------------------------------+-------+---------+
| ID                                   | Name      | Status | Networks                                       | Image | Flavor  |
+--------------------------------------+-----------+--------+------------------------------------------------+-------+---------+
| 653fb842-6ce8-4eb0-a51a-dc0f3d5fb103 | bastion   | ACTIVE | 35eb-ocp-network=192.168.47.33, 169.47.183.214 |       | 2c2g30d |
+--------------------------------------+-----------+--------+------------------------------------------------+-------+---------+
----
 
. Try to login to OpenStack UI: link:http://horizon.red.osp.opentlc.com/dashboard/auth/login/[]. You must use the credentials from `.config/openstack/clouds.yaml` to login to the UI.
 
=== Setting up AgnosticD and your development environment
 
. Clone the AgnosticD repository:
+
[source,bash]
----
git clone https://github.com/redhat-cop/agnosticd
----
 
. Create your `secret.yml` file *oustide the repository*, and edit it using the correct credentials based on your `clouds.yml` file:
+
[source,bash]
----
cat << EOF >> ~/secret.yml
# Authenication for OpenStack in order to create the things
# RED
osp_auth_username: CHANGEME
osp_auth_password: CHANGEME
osp_project_name: CHANGEME
osp_project_id: CHANGEME
 
 
osp_auth_url: http://169.47.188.15:5000/v3
osp_auth_project_domain: default
osp_auth_user_domain: default
 
# DNS
 
osp_cluster_dns_server: ddns01.opentlc.com
osp_cluster_dns_zone: students.osp.opentlc.com
ddns_key_name: opentlc_students
ddns_key_name: PROVIDED_BY_ADMIN          # default value is set to "hmac-dm5"
ddns_key_secret: PROVIDED_BY_ADMIN
 
# Repo
 
own_repo_path: PROVIDED_BY_ADMIN
 
# Do not create PROJECT, we already have one and want to use it
 
osp_project_create: false
 
EOF
----
 
. *First checkpoint*, make sure this secret file is correct by running the test-empty-config.
+
[source,bash]
----
cd agnosticd/ansible
 
ansible-playbook main.yml \
  -e @configs/test-empty-config/sample_vars_osp.yml \
  -e @~/secret.yml
----
 
. Copy the `sample_vars.yml` file and call it `my_vars.yml`
+
[source,bash]
----
cp configs/just-some-nodes-example/sample_vars_osp.yml \
  configs/just-some-nodes-example/my_vars.yml
----
 
. Edit the `my_vars.yml` and change the `guid` value to something short and unique.
+
WARNING: Do not pick the same GUID as the one you got for access to the OSP cluster.
 
. *Second checkpoint*, Run the ansible-playbook command to deploy just-some-nodes-example
+
[source,bash]
----
ansible-playbook main.yml \
  -e @configs/just-some-nodes-example/my_vars.yml \
  -e @~/secret.yml
----
+
NOTE: If you are having python2 Vs. Python3 issues, Add `/usr/bin/python3.6` before the ansible-playbook command. For example: `/usr/bin/python3.6 ansible-playbook ansible/main.yml -e @configs/just-some-nodes-example/my_vars.yml -e@~/secret.yml`
 
 
. Check that the VM was installed and ssh into the box using the created key
+
[source,bash]
----
openstack --os-cloud=35eb-project server list
ssh -i /tmp/output_dir/${GUID}_infra_ssh_key.pem cloud-user@169.47.183.41
----
 
. You can now adapt `my_vars.yml` to your needs. Create different kind of instances, more security groups, etc.
 
=== Clean up
 
. Destroy the deployment:
+
[source,bash]
----
ansible-playbook destroy.yml \
  -e @configs/just-some-nodes-example/my_vars.yml \
  -e @~/secret.yml
----
 
== What next ?
 
- link:../ansible/configs/ocp-workloads[ocp-workloads]: deploy an OpenShift app on a shared cluster. See link:../ansible/configs/ocp-workloads/sample_vars[`sample_vars`] directory.
- link:../ansible/configs/ocp4-cluster[ocp4-cluster]: deploy an OpenShift cluster. You can applied your workloads on top of it using the `ocp_workloads` list. See link:../ansible/configs/ocp4-cluster/sample_vars_osp.yml[sample_vars_osp.yml].