blob: b62d2d15fd9f45945dc8744e8a09f52ebb900588 (
plain)
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
|
# Copyright (c) 2018 Huawei Technologies Co., Ltd. All Rights Reserved.
#
# 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.
---
- name: install python-pip, lvm2, thin-provisioning-tools and docker-compose
apt:
name: "{{ item }}"
state: present
with_items:
- python-pip
- lvm2
- thin-provisioning-tools
- docker-compose
- name: configure cinder section in opensds global info if specify cinder backend
shell: |
cat >> opensds.conf <<OPENSDS_GLOABL_CONFIG_DOC
[cinder]
name = {{ cinder_name }}
description = {{ cinder_description }}
driver_name = {{ cinder_driver_name }}
config_path = {{ cinder_config_path }}
args:
chdir: "{{ opensds_config_dir }}"
ignore_errors: yes
- name: copy opensds cinder backend file to cinder config path if specify cinder backend
copy:
src: ../../../group_vars/cinder/cinder.yaml
dest: "{{ cinder_config_path }}"
- name: create directory to save source code and volume group file
file:
path: "{{ cinder_data_dir }}"
state: directory
recurse: yes
- name: create volume group in thin mode
shell:
_raw_params: |
function _create_lvm_volume_group {
local vg=$1
local size=$2
local backing_file={{ cinder_data_dir }}/${vg}.img
if ! sudo vgs $vg; then
# Only create if the file doesn't already exists
[[ -f $backing_file ]] || truncate -s $size $backing_file
local vg_dev
vg_dev=`sudo losetup -f --show $backing_file`
# Only create physical volume if it doesn't already exist
if ! sudo pvs $vg_dev; then
sudo pvcreate $vg_dev
fi
# Only create volume group if it doesn't already exist
if ! sudo vgs $vg; then
sudo vgcreate $vg $vg_dev
fi
fi
}
modprobe dm_thin_pool
_create_lvm_volume_group {{ cinder_volume_group }} 10G
args:
executable: /bin/bash
become: true
- name: check for python-cinderclient source code existed
stat:
path: "{{ cinder_data_dir }}/python-cinderclient"
ignore_errors: yes
register: cinderclient_existed
- name: download python-cinderclient source code
git:
repo: https://github.com/openstack/python-cinderclient.git
dest: "{{ cinder_data_dir }}/python-cinderclient"
when:
- cinderclient_existed.stat.exists is undefined or cinderclient_existed.stat.exists == false
# Tested successfully in this version `ab0185bfc6e8797a35a2274c2a5ee03afb03dd60`
# git checkout -b ab0185bfc6e8797a35a2274c2a5ee03afb03dd60
- name: pip install cinderclinet
shell: |
pip install -e .
become: true
args:
chdir: "{{ cinder_data_dir }}/python-cinderclient"
- name: check for python-brick-cinderclient-ext source code existed
stat:
path: "{{ cinder_data_dir }}/python-brick-cinderclient-ext"
ignore_errors: yes
register: brick_existed
- name: download python-brick-cinderclient-ext source code
git:
repo: https://github.com/openstack/python-brick-cinderclient-ext.git
dest: "{{ cinder_data_dir }}/python-brick-cinderclient-ext"
when:
- brick_existed.stat.exists is undefined or brick_existed.stat.exists == false
# Tested successfully in this version `a281e67bf9c12521ea5433f86cec913854826a33`
# git checkout -b a281e67bf9c12521ea5433f86cec913854826a33
- name: pip install python-brick-cinderclient-ext
shell: |
pip install -e .
become: true
args:
chdir: "{{ cinder_data_dir }}/python-brick-cinderclient-ext"
- name: check for cinder source code existed
stat:
path: "{{ cinder_data_dir }}/cinder"
ignore_errors: yes
register: cinder_existed
- name: download cinder source code
git:
repo: https://github.com/openstack/cinder.git
dest: "{{ cinder_data_dir }}/cinder"
when:
- cinder_existed.stat.exists is undefined or cinder_existed.stat.exists == false
# Tested successfully in this version `7bbc95344d3961d0bf059252723fa40b33d4b3fe`
# git checkout -b 7bbc95344d3961d0bf059252723fa40b33d4b3fe
- name: update blockbox configuration
shell: |
sed -i "s/PLATFORM ?= debian:stretch/PLATFORM ?= {{ cinder_container_platform }}/g" Makefile
sed -i "s/TAG ?= debian-cinder:latest/TAG ?= {{ cinder_image_tag }}:latest/g" Makefile
sed -i "s/image: debian-cinder/image: {{ cinder_image_tag }}/g" docker-compose.yml
sed -i "s/image: lvm-debian-cinder/image: lvm-{{ cinder_image_tag }}/g" docker-compose.yml
sed -i "s/3306:3306/3307:3306/g" docker-compose.yml
sed -i "s/volume_group = cinder-volumes /volume_group = {{ cinder_volume_group }}/g" etc/cinder.conf
become: true
args:
chdir: "{{ cinder_data_dir }}/cinder/contrib/block-box"
- name: make blockbox
shell: make blockbox
become: true
args:
chdir: "{{ cinder_data_dir }}/cinder/contrib/block-box"
- name: start cinder-standalone service
shell: docker-compose up -d
become: true
args:
chdir: "{{ cinder_data_dir }}/cinder/contrib/block-box"
- name: wait for cinder service to start normally
wait_for:
host: 127.0.0.1
port: 8776
delay: 15
timeout: 120
|