1 # Copyright (c) 2018 Huawei Technologies Co., Ltd. All Rights Reserved.
\r
3 # Licensed under the Apache License, Version 2.0 (the "License");
\r
4 # you may not use this file except in compliance with the License.
\r
5 # You may obtain a copy of the License at
\r
7 # http://www.apache.org/licenses/LICENSE-2.0
\r
9 # Unless required by applicable law or agreed to in writing, software
\r
10 # distributed under the License is distributed on an "AS IS" BASIS,
\r
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
12 # See the License for the specific language governing permissions and
\r
13 # limitations under the License.
\r
16 - name: install python-pip, lvm2, thin-provisioning-tools and docker-compose
\r
23 - thin-provisioning-tools
\r
26 - name: configure cinder section in opensds global info if specify cinder backend
\r
28 cat >> opensds.conf <<OPENSDS_GLOABL_CONFIG_DOC
\r
31 name = {{ cinder_name }}
\r
32 description = {{ cinder_description }}
\r
33 driver_name = {{ cinder_driver_name }}
\r
34 config_path = {{ cinder_config_path }}
\r
36 chdir: "{{ opensds_config_dir }}"
\r
39 - name: copy opensds cinder backend file to cinder config path if specify cinder backend
\r
41 src: ../../../group_vars/cinder/cinder.yaml
\r
42 dest: "{{ cinder_config_path }}"
\r
44 - name: create directory to save source code and volume group file
\r
46 path: "{{ cinder_data_dir }}"
\r
50 - name: create volume group in thin mode
\r
53 function _create_lvm_volume_group {
\r
57 local backing_file={{ cinder_data_dir }}/${vg}.img
\r
58 if ! sudo vgs $vg; then
\r
59 # Only create if the file doesn't already exists
\r
60 [[ -f $backing_file ]] || truncate -s $size $backing_file
\r
62 vg_dev=`sudo losetup -f --show $backing_file`
\r
64 # Only create physical volume if it doesn't already exist
\r
65 if ! sudo pvs $vg_dev; then
\r
66 sudo pvcreate $vg_dev
\r
69 # Only create volume group if it doesn't already exist
\r
70 if ! sudo vgs $vg; then
\r
71 sudo vgcreate $vg $vg_dev
\r
75 modprobe dm_thin_pool
\r
76 _create_lvm_volume_group {{ cinder_volume_group }} 10G
\r
78 executable: /bin/bash
\r
81 - name: check for python-cinderclient source code existed
\r
83 path: "{{ cinder_data_dir }}/python-cinderclient"
\r
85 register: cinderclient_existed
\r
87 - name: download python-cinderclient source code
\r
89 repo: https://github.com/openstack/python-cinderclient.git
\r
90 dest: "{{ cinder_data_dir }}/python-cinderclient"
\r
92 - cinderclient_existed.stat.exists is undefined or cinderclient_existed.stat.exists == false
\r
94 # Tested successfully in this version `ab0185bfc6e8797a35a2274c2a5ee03afb03dd60`
\r
95 # git checkout -b ab0185bfc6e8797a35a2274c2a5ee03afb03dd60
\r
96 - name: pip install cinderclinet
\r
101 chdir: "{{ cinder_data_dir }}/python-cinderclient"
\r
103 - name: check for python-brick-cinderclient-ext source code existed
\r
105 path: "{{ cinder_data_dir }}/python-brick-cinderclient-ext"
\r
107 register: brick_existed
\r
109 - name: download python-brick-cinderclient-ext source code
\r
111 repo: https://github.com/openstack/python-brick-cinderclient-ext.git
\r
112 dest: "{{ cinder_data_dir }}/python-brick-cinderclient-ext"
\r
114 - brick_existed.stat.exists is undefined or brick_existed.stat.exists == false
\r
116 # Tested successfully in this version `a281e67bf9c12521ea5433f86cec913854826a33`
\r
117 # git checkout -b a281e67bf9c12521ea5433f86cec913854826a33
\r
118 - name: pip install python-brick-cinderclient-ext
\r
123 chdir: "{{ cinder_data_dir }}/python-brick-cinderclient-ext"
\r
126 - name: check for cinder source code existed
\r
128 path: "{{ cinder_data_dir }}/cinder"
\r
130 register: cinder_existed
\r
132 - name: download cinder source code
\r
134 repo: https://github.com/openstack/cinder.git
\r
135 dest: "{{ cinder_data_dir }}/cinder"
\r
137 - cinder_existed.stat.exists is undefined or cinder_existed.stat.exists == false
\r
139 # Tested successfully in this version `7bbc95344d3961d0bf059252723fa40b33d4b3fe`
\r
140 # git checkout -b 7bbc95344d3961d0bf059252723fa40b33d4b3fe
\r
141 - name: update blockbox configuration
\r
143 sed -i "s/PLATFORM ?= debian:stretch/PLATFORM ?= {{ cinder_container_platform }}/g" Makefile
\r
144 sed -i "s/TAG ?= debian-cinder:latest/TAG ?= {{ cinder_image_tag }}:latest/g" Makefile
\r
146 sed -i "s/image: debian-cinder/image: {{ cinder_image_tag }}/g" docker-compose.yml
\r
147 sed -i "s/image: lvm-debian-cinder/image: lvm-{{ cinder_image_tag }}/g" docker-compose.yml
\r
149 sed -i "s/3306:3306/3307:3306/g" docker-compose.yml
\r
151 sed -i "s/volume_group = cinder-volumes /volume_group = {{ cinder_volume_group }}/g" etc/cinder.conf
\r
154 chdir: "{{ cinder_data_dir }}/cinder/contrib/block-box"
\r
156 - name: make blockbox
\r
157 shell: make blockbox
\r
160 chdir: "{{ cinder_data_dir }}/cinder/contrib/block-box"
\r
162 - name: start cinder-standalone service
\r
163 shell: docker-compose up -d
\r
166 chdir: "{{ cinder_data_dir }}/cinder/contrib/block-box"
\r
168 - name: wait for cinder service to start normally
\r