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