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