Push zealand version of opensds ansible as base-code of Stor4NFV
[stor4nfv.git] / ci / ansible / roles / osdsdock / scenarios / cinder_standalone.yml
diff --git a/ci/ansible/roles/osdsdock/scenarios/cinder_standalone.yml b/ci/ansible/roles/osdsdock/scenarios/cinder_standalone.yml
new file mode 100644 (file)
index 0000000..4ad5cea
--- /dev/null
@@ -0,0 +1,141 @@
+---\r
+\r
+- name: install python-pip\r
+  apt:\r
+    name: python-pip\r
+\r
+- name: install lvm2\r
+  apt:\r
+    name: lvm2\r
+\r
+- name: install thin-provisioning-tools\r
+  apt:\r
+    name: thin-provisioning-tools\r
+\r
+- name: install docker-compose\r
+  pip:\r
+    name: docker-compose\r
+\r
+- name: create directory to save source code and volume group file\r
+  file:\r
+    path: "{{ cinder_data_dir }}"\r
+    state: directory\r
+    recurse: yes\r
+\r
+- name: create volume group in thin mode\r
+  shell:\r
+    _raw_params: |\r
+      function _create_lvm_volume_group {\r
+          local vg=$1\r
+          local size=$2\r
+\r
+          local backing_file={{ cinder_data_dir }}/${vg}.img\r
+          if ! sudo vgs $vg; then\r
+              # Only create if the file doesn't already exists\r
+              [[ -f $backing_file ]] || truncate -s $size $backing_file\r
+              local vg_dev\r
+              vg_dev=`sudo losetup -f --show $backing_file`\r
+\r
+              # Only create volume group if it doesn't already exist\r
+              if ! sudo vgs $vg; then\r
+                  sudo vgcreate $vg $vg_dev\r
+              fi\r
+          fi\r
+      }\r
+      modprobe dm_thin_pool\r
+      _create_lvm_volume_group {{ cinder_volume_group }} 10G\r
+  args:\r
+    executable: /bin/bash\r
+  become: true\r
+\r
+- name: check for python-cinderclient source code existed\r
+  stat:\r
+    path: "{{ cinder_data_dir }}/python-cinderclient"\r
+  ignore_errors: yes\r
+  register: cinderclient_existed\r
+\r
+- name: download python-cinderclient source code\r
+  git:\r
+    repo: https://github.com/openstack/python-cinderclient.git\r
+    dest: "{{ cinder_data_dir }}/python-cinderclient"\r
+  when:\r
+    - cinderclient_existed.stat.exists is undefined or cinderclient_existed.stat.exists == false\r
+\r
+# Tested successfully in this version `ab0185bfc6e8797a35a2274c2a5ee03afb03dd60`\r
+# git checkout -b ab0185bfc6e8797a35a2274c2a5ee03afb03dd60\r
+- name: pip install cinderclinet\r
+  shell: |\r
+    pip install -e .\r
+  become: true\r
+  args:\r
+    chdir: "{{ cinder_data_dir }}/python-cinderclient"\r
+\r
+- name: check for python-brick-cinderclient-ext source code existed\r
+  stat:\r
+    path: "{{ cinder_data_dir }}/python-brick-cinderclient-ext"\r
+  ignore_errors: yes\r
+  register: brick_existed\r
+\r
+- name: download python-brick-cinderclient-ext source code\r
+  git:\r
+    repo: https://github.com/openstack/python-brick-cinderclient-ext.git\r
+    dest: "{{ cinder_data_dir }}/python-brick-cinderclient-ext"\r
+  when:\r
+    - brick_existed.stat.exists is undefined or brick_existed.stat.exists == false\r
+\r
+# Tested successfully in this version `a281e67bf9c12521ea5433f86cec913854826a33`\r
+# git checkout -b a281e67bf9c12521ea5433f86cec913854826a33\r
+- name: pip install python-brick-cinderclient-ext\r
+  shell: |\r
+    pip install -e .\r
+  become: true\r
+  args:\r
+    chdir: "{{ cinder_data_dir }}/python-brick-cinderclient-ext"\r
+\r
+\r
+- name: check for cinder source code existed\r
+  stat:\r
+    path: "{{ cinder_data_dir }}/cinder"\r
+  ignore_errors: yes\r
+  register: cinder_existed\r
+\r
+- name: download cinder source code\r
+  git:\r
+    repo: https://github.com/openstack/cinder.git\r
+    dest: "{{ cinder_data_dir }}/cinder"\r
+  when:\r
+    - cinder_existed.stat.exists is undefined or cinder_existed.stat.exists == false\r
+\r
+# Tested successfully in this version `7bbc95344d3961d0bf059252723fa40b33d4b3fe`\r
+# git checkout -b 7bbc95344d3961d0bf059252723fa40b33d4b3fe\r
+- name: update blockbox configuration\r
+  shell: |\r
+    sed -i "s/PLATFORM ?= debian:stretch/PLATFORM ?= {{ cinder_container_platform }}/g" Makefile\r
+    sed -i "s/TAG ?= debian-cinder:latest/TAG ?= {{ cinder_image_tag }}:latest/g" Makefile\r
+\r
+    sed -i "s/image: debian-cinder/image: {{ cinder_image_tag }}/g" docker-compose.yml\r
+    sed -i "s/image: lvm-debian-cinder/image: {{ cinder_image_tag }}/g" docker-compose.yml\r
+\r
+    sed -i "s/volume_group = cinder-volumes /volume_group = {{ cinder_volume_group }}/g" etc/cinder.conf\r
+  become: true\r
+  args:\r
+    chdir: "{{ cinder_data_dir }}/cinder/contrib/block-box"\r
+\r
+- name: make blockbox\r
+  shell: make blockbox\r
+  become: true\r
+  args:\r
+    chdir: "{{ cinder_data_dir }}/cinder/contrib/block-box"\r
+\r
+- name: start cinder-standalone service\r
+  shell: docker-compose up -d\r
+  become: true\r
+  args:\r
+    chdir: "{{ cinder_data_dir }}/cinder/contrib/block-box"\r
+\r
+- name: wait for cinder service to start normally\r
+  wait_for:\r
+    host: 127.0.0.1\r
+    port: 8776\r
+    delay: 2\r
+    timeout: 120\r