From 64df7bc3bc70d49153409436b411fb327691a4d5 Mon Sep 17 00:00:00 2001 From: leonwang Date: Wed, 10 Jan 2018 03:44:46 +0000 Subject: Push zealand version of opensds ansible as base-code of Stor4NFV As we discussed on last meeting, the installer script of stor4nfv will be based on opensds ansible, so in this patch I download the first release (zealand) of opensds code and push the ansible script into stor4nfv repo so that we don't need to modify opensds code. Please be free to ask if you have any question. Change-Id: I7b50729977b195fa64e8d9a09f415d9f3329d71f Signed-off-by: leonwang --- ci/ansible/roles/osdsdock/scenarios/ceph.yml | 69 ++++++++++ ci/ansible/roles/osdsdock/scenarios/cinder.yml | 1 + .../roles/osdsdock/scenarios/cinder_standalone.yml | 141 +++++++++++++++++++++ ci/ansible/roles/osdsdock/scenarios/lvm.yml | 22 ++++ ci/ansible/roles/osdsdock/tasks/main.yml | 31 +++++ 5 files changed, 264 insertions(+) create mode 100644 ci/ansible/roles/osdsdock/scenarios/ceph.yml create mode 100644 ci/ansible/roles/osdsdock/scenarios/cinder.yml create mode 100644 ci/ansible/roles/osdsdock/scenarios/cinder_standalone.yml create mode 100644 ci/ansible/roles/osdsdock/scenarios/lvm.yml create mode 100644 ci/ansible/roles/osdsdock/tasks/main.yml (limited to 'ci/ansible/roles/osdsdock') diff --git a/ci/ansible/roles/osdsdock/scenarios/ceph.yml b/ci/ansible/roles/osdsdock/scenarios/ceph.yml new file mode 100644 index 0000000..2f6348e --- /dev/null +++ b/ci/ansible/roles/osdsdock/scenarios/ceph.yml @@ -0,0 +1,69 @@ +--- +- name: install ceph-common external package when ceph backend enabled + apt: + name: ceph-common + when: enabled_backend == "ceph" + +- name: check for ceph-ansible source code existed + stat: + path: /tmp/ceph-ansible + ignore_errors: yes + register: cephansibleexisted + +- name: download ceph-ansible source code + git: + repo: https://github.com/ceph/ceph-ansible.git + dest: /tmp/ceph-ansible + when: + - cephansibleexisted.stat.exists is undefined or cephansibleexisted.stat.exists == false + +- name: copy ceph inventory host into ceph-ansible directory + copy: + src: ../../../group_vars/ceph/ceph.hosts + dest: /tmp/ceph-ansible/ceph.hosts + +- name: copy ceph all.yml file into ceph-ansible group_vars directory + copy: + src: ../../../group_vars/ceph/all.yml + dest: /tmp/ceph-ansible/group_vars/all.yml + +- name: copy ceph osds.yml file into ceph-ansible group_vars directory + copy: + src: ../../../group_vars/ceph/osds.yml + dest: /tmp/ceph-ansible/group_vars/osds.yml + +- name: copy site.yml.sample to site.yml in ceph-ansible + copy: + src: /tmp/ceph-ansible/site.yml.sample + dest: /tmp/ceph-ansible/site.yml + +- name: ping all hosts + shell: ansible all -m ping -i ceph.hosts + become: true + args: + chdir: /tmp/ceph-ansible + +- name: run ceph-ansible playbook + shell: ansible-playbook site.yml -i ceph.hosts + become: true + args: + chdir: /tmp/ceph-ansible + +- name: Check if ceph osd is running + shell: ps aux | grep ceph-osd | grep -v grep + ignore_errors: false + changed_when: false + register: service_ceph_osd_status + +- name: Check if ceph mon is running + shell: ps aux | grep ceph-mon | grep -v grep + ignore_errors: false + changed_when: false + register: service_ceph_mon_status + +- name: Create a pool and initialize it. + shell: ceph osd pool create {{ ceph_pool_name }} 100 && ceph osd pool set {{ ceph_pool_name }} size 1 + ignore_errors: yes + changed_when: false + register: ceph_init_pool + when: service_ceph_mon_status.rc == 0 and service_ceph_osd_status.rc == 0 \ No newline at end of file diff --git a/ci/ansible/roles/osdsdock/scenarios/cinder.yml b/ci/ansible/roles/osdsdock/scenarios/cinder.yml new file mode 100644 index 0000000..7313caa --- /dev/null +++ b/ci/ansible/roles/osdsdock/scenarios/cinder.yml @@ -0,0 +1 @@ +--- diff --git a/ci/ansible/roles/osdsdock/scenarios/cinder_standalone.yml b/ci/ansible/roles/osdsdock/scenarios/cinder_standalone.yml new file mode 100644 index 0000000..4ad5cea --- /dev/null +++ b/ci/ansible/roles/osdsdock/scenarios/cinder_standalone.yml @@ -0,0 +1,141 @@ +--- + +- name: install python-pip + apt: + name: python-pip + +- name: install lvm2 + apt: + name: lvm2 + +- name: install thin-provisioning-tools + apt: + name: thin-provisioning-tools + +- name: install docker-compose + pip: + name: docker-compose + +- name: create directory to save source code and volume group file + file: + path: "{{ cinder_data_dir }}" + state: directory + recurse: yes + +- name: create volume group in thin mode + shell: + _raw_params: | + function _create_lvm_volume_group { + local vg=$1 + local size=$2 + + local backing_file={{ cinder_data_dir }}/${vg}.img + if ! sudo vgs $vg; then + # Only create if the file doesn't already exists + [[ -f $backing_file ]] || truncate -s $size $backing_file + local vg_dev + vg_dev=`sudo losetup -f --show $backing_file` + + # Only create volume group if it doesn't already exist + if ! sudo vgs $vg; then + sudo vgcreate $vg $vg_dev + fi + fi + } + modprobe dm_thin_pool + _create_lvm_volume_group {{ cinder_volume_group }} 10G + args: + executable: /bin/bash + become: true + +- name: check for python-cinderclient source code existed + stat: + path: "{{ cinder_data_dir }}/python-cinderclient" + ignore_errors: yes + register: cinderclient_existed + +- name: download python-cinderclient source code + git: + repo: https://github.com/openstack/python-cinderclient.git + dest: "{{ cinder_data_dir }}/python-cinderclient" + when: + - cinderclient_existed.stat.exists is undefined or cinderclient_existed.stat.exists == false + +# Tested successfully in this version `ab0185bfc6e8797a35a2274c2a5ee03afb03dd60` +# git checkout -b ab0185bfc6e8797a35a2274c2a5ee03afb03dd60 +- name: pip install cinderclinet + shell: | + pip install -e . + become: true + args: + chdir: "{{ cinder_data_dir }}/python-cinderclient" + +- name: check for python-brick-cinderclient-ext source code existed + stat: + path: "{{ cinder_data_dir }}/python-brick-cinderclient-ext" + ignore_errors: yes + register: brick_existed + +- name: download python-brick-cinderclient-ext source code + git: + repo: https://github.com/openstack/python-brick-cinderclient-ext.git + dest: "{{ cinder_data_dir }}/python-brick-cinderclient-ext" + when: + - brick_existed.stat.exists is undefined or brick_existed.stat.exists == false + +# Tested successfully in this version `a281e67bf9c12521ea5433f86cec913854826a33` +# git checkout -b a281e67bf9c12521ea5433f86cec913854826a33 +- name: pip install python-brick-cinderclient-ext + shell: | + pip install -e . + become: true + args: + chdir: "{{ cinder_data_dir }}/python-brick-cinderclient-ext" + + +- name: check for cinder source code existed + stat: + path: "{{ cinder_data_dir }}/cinder" + ignore_errors: yes + register: cinder_existed + +- name: download cinder source code + git: + repo: https://github.com/openstack/cinder.git + dest: "{{ cinder_data_dir }}/cinder" + when: + - cinder_existed.stat.exists is undefined or cinder_existed.stat.exists == false + +# Tested successfully in this version `7bbc95344d3961d0bf059252723fa40b33d4b3fe` +# git checkout -b 7bbc95344d3961d0bf059252723fa40b33d4b3fe +- name: update blockbox configuration + shell: | + sed -i "s/PLATFORM ?= debian:stretch/PLATFORM ?= {{ cinder_container_platform }}/g" Makefile + sed -i "s/TAG ?= debian-cinder:latest/TAG ?= {{ cinder_image_tag }}:latest/g" Makefile + + sed -i "s/image: debian-cinder/image: {{ cinder_image_tag }}/g" docker-compose.yml + sed -i "s/image: lvm-debian-cinder/image: {{ cinder_image_tag }}/g" docker-compose.yml + + sed -i "s/volume_group = cinder-volumes /volume_group = {{ cinder_volume_group }}/g" etc/cinder.conf + become: true + args: + chdir: "{{ cinder_data_dir }}/cinder/contrib/block-box" + +- name: make blockbox + shell: make blockbox + become: true + args: + chdir: "{{ cinder_data_dir }}/cinder/contrib/block-box" + +- name: start cinder-standalone service + shell: docker-compose up -d + become: true + args: + chdir: "{{ cinder_data_dir }}/cinder/contrib/block-box" + +- name: wait for cinder service to start normally + wait_for: + host: 127.0.0.1 + port: 8776 + delay: 2 + timeout: 120 diff --git a/ci/ansible/roles/osdsdock/scenarios/lvm.yml b/ci/ansible/roles/osdsdock/scenarios/lvm.yml new file mode 100644 index 0000000..d1d7b36 --- /dev/null +++ b/ci/ansible/roles/osdsdock/scenarios/lvm.yml @@ -0,0 +1,22 @@ +--- +- name: install lvm2 external package when lvm backend enabled + apt: + name: lvm2 + +- name: check if physical volume existed + shell: pvdisplay {{ pv_device }} + ignore_errors: yes + register: pv_existed + +- name: create a physical volume + shell: pvcreate {{ pv_device }} + when: pv_existed is undefined or pv_existed.rc != 0 + +- name: check if volume group existed + shell: vgdisplay {{ vg_name }} + ignore_errors: yes + register: vg_existed + +- name: create a volume group + shell: vgcreate {{ vg_name }} {{ pv_device }} + when: vg_existed is undefined or vg_existed.rc != 0 diff --git a/ci/ansible/roles/osdsdock/tasks/main.yml b/ci/ansible/roles/osdsdock/tasks/main.yml new file mode 100644 index 0000000..2462905 --- /dev/null +++ b/ci/ansible/roles/osdsdock/tasks/main.yml @@ -0,0 +1,31 @@ +--- +- name: include scenarios/lvm.yml + include: scenarios/lvm.yml + when: enabled_backend == "lvm" + +- name: include scenarios/ceph.yml + include: scenarios/ceph.yml + when: enabled_backend == "ceph" + +- name: include scenarios/cinder.yml + include: scenarios/cinder.yml + when: enabled_backend == "cinder" and use_cinder_standalone == false + +- name: include scenarios/cinder_standalone.yml + include: scenarios/cinder_standalone.yml + when: enabled_backend == "cinder" and use_cinder_standalone == true + +- name: run osdsdock daemon service + shell: + cmd: | + i=0 + while + i="$((i+1))" + [ "$i" -lt 4 ] + do + nohup bin/osdsdock &>/dev/null & + sleep 5 + ps aux | grep osdsdock | grep -v grep && break + done + args: + chdir: "{{ opensds_build_dir }}/out" -- cgit 1.2.3-korg