Push zealand version of opensds ansible as base-code of Stor4NFV
[stor4nfv.git] / ci / ansible / roles / osdsdock / scenarios / cinder_standalone.yml
1 ---\r
2 \r
3 - name: install python-pip\r
4   apt:\r
5     name: python-pip\r
6 \r
7 - name: install lvm2\r
8   apt:\r
9     name: lvm2\r
10 \r
11 - name: install thin-provisioning-tools\r
12   apt:\r
13     name: thin-provisioning-tools\r
14 \r
15 - name: install docker-compose\r
16   pip:\r
17     name: docker-compose\r
18 \r
19 - name: create directory to save source code and volume group file\r
20   file:\r
21     path: "{{ cinder_data_dir }}"\r
22     state: directory\r
23     recurse: yes\r
24 \r
25 - name: create volume group in thin mode\r
26   shell:\r
27     _raw_params: |\r
28       function _create_lvm_volume_group {\r
29           local vg=$1\r
30           local size=$2\r
31 \r
32           local backing_file={{ cinder_data_dir }}/${vg}.img\r
33           if ! sudo vgs $vg; then\r
34               # Only create if the file doesn't already exists\r
35               [[ -f $backing_file ]] || truncate -s $size $backing_file\r
36               local vg_dev\r
37               vg_dev=`sudo losetup -f --show $backing_file`\r
38 \r
39               # Only create volume group if it doesn't already exist\r
40               if ! sudo vgs $vg; then\r
41                   sudo vgcreate $vg $vg_dev\r
42               fi\r
43           fi\r
44       }\r
45       modprobe dm_thin_pool\r
46       _create_lvm_volume_group {{ cinder_volume_group }} 10G\r
47   args:\r
48     executable: /bin/bash\r
49   become: true\r
50 \r
51 - name: check for python-cinderclient source code existed\r
52   stat:\r
53     path: "{{ cinder_data_dir }}/python-cinderclient"\r
54   ignore_errors: yes\r
55   register: cinderclient_existed\r
56 \r
57 - name: download python-cinderclient source code\r
58   git:\r
59     repo: https://github.com/openstack/python-cinderclient.git\r
60     dest: "{{ cinder_data_dir }}/python-cinderclient"\r
61   when:\r
62     - cinderclient_existed.stat.exists is undefined or cinderclient_existed.stat.exists == false\r
63 \r
64 # Tested successfully in this version `ab0185bfc6e8797a35a2274c2a5ee03afb03dd60`\r
65 # git checkout -b ab0185bfc6e8797a35a2274c2a5ee03afb03dd60\r
66 - name: pip install cinderclinet\r
67   shell: |\r
68     pip install -e .\r
69   become: true\r
70   args:\r
71     chdir: "{{ cinder_data_dir }}/python-cinderclient"\r
72 \r
73 - name: check for python-brick-cinderclient-ext source code existed\r
74   stat:\r
75     path: "{{ cinder_data_dir }}/python-brick-cinderclient-ext"\r
76   ignore_errors: yes\r
77   register: brick_existed\r
78 \r
79 - name: download python-brick-cinderclient-ext source code\r
80   git:\r
81     repo: https://github.com/openstack/python-brick-cinderclient-ext.git\r
82     dest: "{{ cinder_data_dir }}/python-brick-cinderclient-ext"\r
83   when:\r
84     - brick_existed.stat.exists is undefined or brick_existed.stat.exists == false\r
85 \r
86 # Tested successfully in this version `a281e67bf9c12521ea5433f86cec913854826a33`\r
87 # git checkout -b a281e67bf9c12521ea5433f86cec913854826a33\r
88 - name: pip install python-brick-cinderclient-ext\r
89   shell: |\r
90     pip install -e .\r
91   become: true\r
92   args:\r
93     chdir: "{{ cinder_data_dir }}/python-brick-cinderclient-ext"\r
94 \r
95 \r
96 - name: check for cinder source code existed\r
97   stat:\r
98     path: "{{ cinder_data_dir }}/cinder"\r
99   ignore_errors: yes\r
100   register: cinder_existed\r
101 \r
102 - name: download cinder source code\r
103   git:\r
104     repo: https://github.com/openstack/cinder.git\r
105     dest: "{{ cinder_data_dir }}/cinder"\r
106   when:\r
107     - cinder_existed.stat.exists is undefined or cinder_existed.stat.exists == false\r
108 \r
109 # Tested successfully in this version `7bbc95344d3961d0bf059252723fa40b33d4b3fe`\r
110 # git checkout -b 7bbc95344d3961d0bf059252723fa40b33d4b3fe\r
111 - name: update blockbox configuration\r
112   shell: |\r
113     sed -i "s/PLATFORM ?= debian:stretch/PLATFORM ?= {{ cinder_container_platform }}/g" Makefile\r
114     sed -i "s/TAG ?= debian-cinder:latest/TAG ?= {{ cinder_image_tag }}:latest/g" Makefile\r
115 \r
116     sed -i "s/image: debian-cinder/image: {{ cinder_image_tag }}/g" docker-compose.yml\r
117     sed -i "s/image: lvm-debian-cinder/image: {{ cinder_image_tag }}/g" docker-compose.yml\r
118 \r
119     sed -i "s/volume_group = cinder-volumes /volume_group = {{ cinder_volume_group }}/g" etc/cinder.conf\r
120   become: true\r
121   args:\r
122     chdir: "{{ cinder_data_dir }}/cinder/contrib/block-box"\r
123 \r
124 - name: make blockbox\r
125   shell: make blockbox\r
126   become: true\r
127   args:\r
128     chdir: "{{ cinder_data_dir }}/cinder/contrib/block-box"\r
129 \r
130 - name: start cinder-standalone service\r
131   shell: docker-compose up -d\r
132   become: true\r
133   args:\r
134     chdir: "{{ cinder_data_dir }}/cinder/contrib/block-box"\r
135 \r
136 - name: wait for cinder service to start normally\r
137   wait_for:\r
138     host: 127.0.0.1\r
139     port: 8776\r
140     delay: 2\r
141     timeout: 120\r