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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
|
---
# Copyright 2015 Open Platform for NFV Project, Inc. and its contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# What this is: An Ansible playbook for installing OpenStack Congress on Centos 7.
# Status: this is a work in progress, under test
#
# How to use:
# ansible-playbook -vvv -u root -k -i hosts.ini deploy_congress.yml
#
# Update packages
# yum update_cache=yes name=*
- name: updating package cache
# apt: update_cache=yes
yum: update_cache=yes name=*
# Install dependencies
# Direct command:
# yum pkg=python-pip,mariadb-libs,MySQL-python,git,gcc,python-devel,libxml2,libxslt-devel,libzip-devel,mysql-server state=present
- name: installing dependancies
yum: pkg={{item}} state=present
with_items:
- python-pip
- mariadb-libs
- MySQL-python
- git
- gcc
# - python-dev
# - libxslt1-dev
# - libzip-dev
- python-devel
- libxml2
- libxslt-devel
- libzip-devel
- mysql-server
# - libmysqlclient-dev
# - python-mysqldb
# Upgrade pip
# Direct command: pip install --upgrade pip
#- name: upgrade pip
# shell: pip install --upgrade pip
# Install python dependencies
# Direct command: pip name=virtualenv
- name: installing python dependancies
# pip: name={{item}} extra_args='--upgrade'
pip: name={{item}}
with_items:
- virtualenv
- oslo.middleware
# - MySQL-python
# Create the congress user group
# Direct command: group name=congress state=present
- name: creating congress group
group: name=congress state=present
when: init == "True"
# Create the congress user
# Direct command: user name=congress group=congress state=present createhome=no
- name: creating congress user
user: name=congress group=congress state=present createhome=no
# Create the congress install directory
# Direct command: mkdir {{item}}; chown congress {{item}}; chgrp congress {{item}};
- name: creating remote install directory
file: path={{item}} state=directory owner=congress group=congress
with_items:
- /etc/congress
- /etc/congress/snapshot
# - "{{installDir}}"
- /var/log/congress
# Copying congress build to prod host
# Direct command: what direct command this maps to is TBD
- name: copying congress build to prod host
unarchive: src={{tempDir}}/congress-{{congressVersion}}.tar.gz dest={{installDir}} owner=congress group=congress
args:
creates: "{{installDir}}/congress-{{congressVersion}}"
# Run the congress python setup
# Direct command: cd /opt/congress-{{congressVersion}}; python setup.py install
- name: run setup.py
shell: python setup.py install
args:
chdir: "{{installDir}}/congress-{{congressVersion}}"
creates: /usr/bin/congress-db-manage
# Activate virtualenv (creates virtual python script library to avoid conflicts with other code on the server)
# TODO: clarify need or benefit from virtualenv
# Direct command: virtualenv /opt/congress-{{congressVersion}}
- name: activating virtualenv
shell: virtualenv {{installDir}}/congress-{{congressVersion}}
# Install dependencies in virtualenv
# Direct command: pip install --upgrade {{item}}
# TODO: how to invoke virtualenv install in manual command
#- name: Install dependencies in virtualenv
# pip: name={{item}} virtualenv={{installDir}}/congress-{{congressVersion}} virtualenv_site_packages=yes extra_args='--upgrade'
# with_items:
# - pbr
# - oslo.middleware
# - i18n
# Copy api-paste.ini to the config directory
# Direct command: cd /opt/congress-{{congressVersion}}; cp etc/api-paste.ini /etc/congress
- name: copy /etc/congress/api-paste.ini
shell: cp etc/api-paste.ini /etc/congress
args:
creates: /etc/congress/api-paste.ini
chdir: "{{installDir}}/congress-{{congressVersion}}"
# Copy policy.json to the config directory
# Direct command: cd /opt/congress-{{congressVersion}}; cp etc/policy.json /etc/congress
- name: copy /etc/congress/policy.json
shell: cp etc/policy.json /etc/congress
args:
creates: /etc/congress/policy.json
chdir: "{{installDir}}/congress-{{congressVersion}}"
# Copy congress.conf to the config directory
# Direct command: what direct command this maps to is TBD)
- name: updating congress.conf
template: src=congress.conf dest=/etc/congress/congress.conf owner=congress group=congress
# Create the congress service
# Direct command: bin/keystone --os-auth-url=http://localhost:35357/v2.0 --os-username=admin --os-tenant-name=admin --os-password=octopus service-create --name congress --type "policy" --description "Congress Service"
- name: create congress service
shell: >
/bin/keystone \
--os-auth-url={{keystoneAuthProto}}://{{keystoneAuthHost}}:35357/v2.0 \
--os-username={{keystoneAdminUser}} \
--os-tenant-name={{adminTenantName}} \
--os-password={{keystoneAdminPassword}} \
service-create --name congress --type "policy" --description "Congress Service"
# Create the congress service endpoint
# Direct command: bin/keystone --os-auth-url=http://localhost:35357/v2.0 --os-username=admin --os-tenant-name=admin --os-password=octopus endpoint-create --service congress --region RegionOne --publicurl http://192.168.1.204:1789/
- name: creating keystone endpoint
shell: >
/bin/keystone \
--os-auth-url={{keystoneAuthProto}}://{{keystoneAuthHost}}:35357/v2.0 \
--os-username={{keystoneAdminUser}} \
--os-tenant-name={{adminTenantName}} \
--os-password={{keystoneAdminPassword}} \
endpoint-create --service congress \
--region {{authRegion}} \
--publicurl {{publicEndpoint}} \
--adminurl {{adminEndpoint}} \
--internalurl {{internalEndpoint}}
# Create the congress database
# TODO: fix some bug resulting in "msg: unable to connect, check login credentials "
# Workaround: on controller
# mysql mysql
# update user set host = '%' where user = 'root';
# exit
# Direct command: mysql_db name=congress state=present login_host=192.168.1.204 login_user=root login_password=VALUE_HIDDEN
- name: creating congress database
mysql_db: name=congress state=present login_host={{mysqlDBIP}} login_user={{mysqlDBUser}} login_password={{mysqlDBPassword}}
# Create the congress database user and access
# Direct command: mysql_user name=congress password=VALUE_HIDDEN login_host=localhost login_user=root login_password=VALUE_HIDDEN priv=congress.*:ALL host=%
- name: creating and granting congress user access to database
mysql_user: name={{dbUser}} password={{dbPassword}} login_host={{mysqlDBIP}} login_user={{mysqlDBUser}} login_password={{mysqlDBPassword}} priv=congress.*:ALL host={{ item }}
with_items:
- "%"
- "localhost"
# Fix bug with congress-db-manage failure to import i18n
# See https://bugs.launchpad.net/tripleo/+bug/1468028
# It's unclear if this patch causes other problems...
# Direct command: pip install oslo.i18n==1.7.0
#- name: pip install oslo.i18n==1.7.0
# shell: >
# pip install oslo.i18n==1.7.0
# Create the congress database schema
# Direct command: /usr/bin/congress-db-manage --config-file /etc/congress/congress.conf upgrade head
- name: creating congress database schema
shell: >
/usr/bin/congress-db-manage --config-file /etc/congress/congress.conf upgrade head
# Enable congress to start on system restart
# Direct command: what direct command this maps to is TBD
- name: copy and enable congress-api.service thru systemd
template: src=congress-api.service dest=/usr/lib/systemd/system/congress-api.service
# Install clients
# Direct command: pip install {{item}}
# pip: name={{item}} virtualenv={{installDir}}/congress-{{congressVersion}} virtualenv_site_packages=yes extra_args='--upgrade'
- name: Install clients
pip: name={{item}}
with_items:
- python-openstackclient
- python-congressclient
# stderr: Exception raised: (pbr 0.11.0 (/usr/lib/python2.7/site-packages), Requirement.parse('pbr>=1.6'))
# Install pbr-1.8.1
# Direct command: pip install pbr==1.8.1
- name: Install pbr-1.8.1
shell: >
pip install pbr==1.8.1
# stderr: Exception raised: (pbr 1.8.1 (/usr/lib/python2.7/site-packages), Requirement.parse('pbr>=0.6,!=0.7,<1.0'))
# fix per https://ask.openstack.org/en/question/83174/whole-cli-doesnt-work-anymore-kilo/
# pip install --upgrade python-openstackclient
- name: Upgrade python-openstackclient
shell: >
pip install --upgrade python-openstackclient
# stderr: Unable to establish connection to http://192.168.10.6:1789/v1/data-sources
# systemctl | grep congress
# congress-api.service loaded failed failed OpenStack Congress Server
# https://wiki.archlinux.org/index.php/Systemd#Investigating_systemd_errors
# systemctl status congress-api -l
# oscontroller1.opnfv.com systemd[4175]: Failed at step EXEC spawning /opt/congress/bin/congress-server: No such file or directory
# error in congress-api.service, needed to completely remove from systemd and reinstall
# systemctl stop congress-api.service
# systemctl disable congress-api.service
# rm /etc/systemd/system/congress-api.service
# systemctl daemon-reload
# systemctl reset-failed
# restart at
# ansible-playbook -vvv -u root -k -i hosts.ini deploy_congress.yml --start-at-task="copy and enable congress-api.service thru systemd"
# congress-server: Traceback (most recent call last):
# congress-server: File "/opt/congress-2015.1.0/bin/congress-server", line 33, in <module>
# congress-server: from congress.server import congress_server
# congress-server: File "/opt/congress-2015.1.0/congress/server/congress_server.py", line 26, in <module>
# congress-server: from congress.common import config
# congress-server: File "/opt/congress-2015.1.0/congress/common/config.py", line 20, in <module>
# congress-server: from congress.managers import datasource as datasource_mgr
# congress-server: File "/opt/congress-2015.1.0/congress/managers/datasource.py", line 19, in <module>
# congress-server: from oslo.db import exception as db_exc
# congress-server: File "/usr/lib/python2.7/site-packages/oslo/db/exception.py", line 48, in <module>
# congress-server: from oslo.db._i18n import _
# congress-server: File "/usr/lib/python2.7/site-packages/oslo/db/_i18n.py", line 19, in <module>
# congress-server: from oslo import i18n
# congress-server: ImportError: cannot import name i18n
# systemd: congress-api.service: main process exited, code=exited, status=1/FAILURE
# systemd: Unit congress-api.service entered failed state.
# See https://bugs.launchpad.net/tripleo/+bug/1468028
# It's unclear if this patch causes other problems...
# Direct command: pip install oslo.i18n==1.7.0
- name: install oslo.i18n==1.7.0
shell: >
pip install oslo.i18n==1.7.0
# congress-server: 2015-11-26 00:30:42.754 24988 TRACE congress from oslo.middleware import request_id
# congress-server: 2015-11-26 00:30:42.754 24988 TRACE congress ImportError: No module named middleware
- name: install oslo.middleware
pip: name={{item}}
with_items:
- oslo.middleware
# Start the congress service
# Direct command: systemctl start congress-api
- name: start congress-api service
shell: systemctl start congress-api
# Create congress datasources
# leave out swift for now, as it seems to break access to the other datasources
# Direct command: openstack congress datasource create {{item}} "{{item}}" --os-username=admin --os-tenant-name=admin --os-password=octopus --os-auth-url=http://localhost:35357/v2.0
- name: install datasource drivers
shell: openstack congress datasource create {{item}} "{{item}}" \
--os-username={{keystoneAdminUser}} \
--os-tenant-name={{adminTenantName}} \
--os-password={{keystoneAdminPassword}} \
--os-auth-url={{keystoneAuthProto}}://{{keystoneAuthHost}}:35357/v2.0
--config username={{keystoneAdminUser}} \
--config tenant-name={{adminTenantName}} \
--config password={{keystoneAdminPassword}} \
--config auth-url={{keystoneAuthProto}}://{{keystoneAuthHost}}:35357/v2.0
with_items:
- ceilometer
- cinder
- glancev2
- keystone
- neutronv2
- nova
# - swift
|