Update stor4nfv install scripts according to opensds aruba release
[stor4nfv.git] / ci / ansible / roles / osdsdock / scenarios / cinder_standalone.yml
1 # Copyright (c) 2018 Huawei Technologies Co., Ltd. All Rights Reserved.\r
2 #\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
6 #\r
7 #     http://www.apache.org/licenses/LICENSE-2.0\r
8 #\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
14 \r
15 ---\r
16 - name: install python-pip, lvm2, thin-provisioning-tools and docker-compose\r
17   apt:\r
18     name: "{{ item }}"\r
19     state: present\r
20   with_items:\r
21     - python-pip\r
22     - lvm2\r
23     - thin-provisioning-tools\r
24     - docker-compose\r
25 \r
26 - name: configure cinder section in opensds global info if specify cinder backend\r
27   shell: |\r
28     cat >> opensds.conf <<OPENSDS_GLOABL_CONFIG_DOC\r
29 \r
30     [cinder]\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
35   args:\r
36     chdir: "{{ opensds_config_dir }}"\r
37   ignore_errors: yes\r
38 \r
39 - name: copy opensds cinder backend file to cinder config path if specify cinder backend\r
40   copy:\r
41     src: ../../../group_vars/cinder/cinder.yaml\r
42     dest: "{{ cinder_config_path }}"\r
43 \r
44 - name: create directory to save source code and volume group file\r
45   file:\r
46     path: "{{ cinder_data_dir }}"\r
47     state: directory\r
48     recurse: yes\r
49 \r
50 - name: create volume group in thin mode\r
51   shell:\r
52     _raw_params: |\r
53       function _create_lvm_volume_group {\r
54           local vg=$1\r
55           local size=$2\r
56 \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
61               local vg_dev\r
62               vg_dev=`sudo losetup -f --show $backing_file`\r
63 \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
67               fi\r
68 \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
72               fi\r
73           fi\r
74       }\r
75       modprobe dm_thin_pool\r
76       _create_lvm_volume_group {{ cinder_volume_group }} 10G\r
77   args:\r
78     executable: /bin/bash\r
79   become: true\r
80 \r
81 - name: check for python-cinderclient source code existed\r
82   stat:\r
83     path: "{{ cinder_data_dir }}/python-cinderclient"\r
84   ignore_errors: yes\r
85   register: cinderclient_existed\r
86 \r
87 - name: download python-cinderclient source code\r
88   git:\r
89     repo: https://github.com/openstack/python-cinderclient.git\r
90     dest: "{{ cinder_data_dir }}/python-cinderclient"\r
91   when:\r
92     - cinderclient_existed.stat.exists is undefined or cinderclient_existed.stat.exists == false\r
93 \r
94 # Tested successfully in this version `ab0185bfc6e8797a35a2274c2a5ee03afb03dd60`\r
95 # git checkout -b ab0185bfc6e8797a35a2274c2a5ee03afb03dd60\r
96 - name: pip install cinderclinet\r
97   shell: |\r
98     pip install -e .\r
99   become: true\r
100   args:\r
101     chdir: "{{ cinder_data_dir }}/python-cinderclient"\r
102 \r
103 - name: check for python-brick-cinderclient-ext source code existed\r
104   stat:\r
105     path: "{{ cinder_data_dir }}/python-brick-cinderclient-ext"\r
106   ignore_errors: yes\r
107   register: brick_existed\r
108 \r
109 - name: download python-brick-cinderclient-ext source code\r
110   git:\r
111     repo: https://github.com/openstack/python-brick-cinderclient-ext.git\r
112     dest: "{{ cinder_data_dir }}/python-brick-cinderclient-ext"\r
113   when:\r
114     - brick_existed.stat.exists is undefined or brick_existed.stat.exists == false\r
115 \r
116 # Tested successfully in this version `a281e67bf9c12521ea5433f86cec913854826a33`\r
117 # git checkout -b a281e67bf9c12521ea5433f86cec913854826a33\r
118 - name: pip install python-brick-cinderclient-ext\r
119   shell: |\r
120     pip install -e .\r
121   become: true\r
122   args:\r
123     chdir: "{{ cinder_data_dir }}/python-brick-cinderclient-ext"\r
124 \r
125 \r
126 - name: check for cinder source code existed\r
127   stat:\r
128     path: "{{ cinder_data_dir }}/cinder"\r
129   ignore_errors: yes\r
130   register: cinder_existed\r
131 \r
132 - name: download cinder source code\r
133   git:\r
134     repo: https://github.com/openstack/cinder.git\r
135     dest: "{{ cinder_data_dir }}/cinder"\r
136   when:\r
137     - cinder_existed.stat.exists is undefined or cinder_existed.stat.exists == false\r
138 \r
139 # Tested successfully in this version `7bbc95344d3961d0bf059252723fa40b33d4b3fe`\r
140 # git checkout -b 7bbc95344d3961d0bf059252723fa40b33d4b3fe\r
141 - name: update blockbox configuration\r
142   shell: |\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
145 \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
148 \r
149     sed -i "s/3306:3306/3307:3306/g" docker-compose.yml\r
150 \r
151     sed -i "s/volume_group = cinder-volumes /volume_group = {{ cinder_volume_group }}/g" etc/cinder.conf\r
152   become: true\r
153   args:\r
154     chdir: "{{ cinder_data_dir }}/cinder/contrib/block-box"\r
155 \r
156 - name: make blockbox\r
157   shell: make blockbox\r
158   become: true\r
159   args:\r
160     chdir: "{{ cinder_data_dir }}/cinder/contrib/block-box"\r
161 \r
162 - name: start cinder-standalone service\r
163   shell: docker-compose up -d\r
164   become: true\r
165   args:\r
166     chdir: "{{ cinder_data_dir }}/cinder/contrib/block-box"\r
167 \r
168 - name: wait for cinder service to start normally\r
169   wait_for:\r
170     host: 127.0.0.1\r
171     port: 8776\r
172     delay: 15\r
173     timeout: 120\r