summaryrefslogtreecommitdiffstats
path: root/ci/ansible/roles/osdsdock
diff options
context:
space:
mode:
Diffstat (limited to 'ci/ansible/roles/osdsdock')
-rw-r--r--ci/ansible/roles/osdsdock/scenarios/ceph.yml102
-rw-r--r--ci/ansible/roles/osdsdock/scenarios/cinder.yml31
-rw-r--r--ci/ansible/roles/osdsdock/scenarios/cinder_standalone.yml62
-rw-r--r--ci/ansible/roles/osdsdock/scenarios/lvm.yml86
-rw-r--r--ci/ansible/roles/osdsdock/tasks/main.yml35
5 files changed, 254 insertions, 62 deletions
diff --git a/ci/ansible/roles/osdsdock/scenarios/ceph.yml b/ci/ansible/roles/osdsdock/scenarios/ceph.yml
index 2f6348e..16aca67 100644
--- a/ci/ansible/roles/osdsdock/scenarios/ceph.yml
+++ b/ci/ansible/roles/osdsdock/scenarios/ceph.yml
@@ -1,69 +1,111 @@
+# Copyright (c) 2018 Huawei Technologies Co., Ltd. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
---
- name: install ceph-common external package when ceph backend enabled
apt:
- name: ceph-common
- when: enabled_backend == "ceph"
+ name: "{{ item }}"
+ state: present
+ with_items:
+ - ceph-common
+
+- name: install notario package with pip when ceph backend enabled
+ pip:
+ name: "{{ item }}"
+ with_items:
+ - notario
+
+- name: configure ceph section in opensds global info if specify ceph backend
+ shell: |
+ cat >> opensds.conf <<OPENSDS_GLOABL_CONFIG_DOC
+
+ [ceph]
+ name = {{ ceph_name }}
+ description = {{ ceph_description }}
+ driver_name = {{ ceph_driver_name }}
+ config_path = {{ ceph_config_path }}
+ args:
+ chdir: "{{ opensds_config_dir }}"
+ ignore_errors: yes
+
+- name: copy opensds ceph backend file to ceph config file if specify ceph backend
+ copy:
+ src: ../../../group_vars/ceph/ceph.yaml
+ dest: "{{ ceph_config_path }}"
- name: check for ceph-ansible source code existed
stat:
- path: /tmp/ceph-ansible
+ path: /opt/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
+ dest: /opt/ceph-ansible
+ version: stable-3.0
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
+ dest: /opt/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
+ dest: /opt/ceph-ansible/group_vars/all.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
+ src: /opt/ceph-ansible/site.yml.sample
+ dest: /opt/ceph-ansible/site.yml
-- name: run ceph-ansible playbook
- shell: ansible-playbook site.yml -i ceph.hosts
+- name: ping all hosts and run ceph-ansible playbook
+ shell: "{{ item }}"
become: true
+ with_items:
+ - ansible all -m ping -i ceph.hosts
+ - ansible-playbook site.yml -i ceph.hosts | tee /var/log/ceph_ansible.log
args:
- chdir: /tmp/ceph-ansible
+ chdir: /opt/ceph-ansible
-- name: Check if ceph osd is running
+- name: check if ceph osd is running
shell: ps aux | grep ceph-osd | grep -v grep
- ignore_errors: false
+ ignore_errors: true
changed_when: false
register: service_ceph_osd_status
-- name: Check if ceph mon is running
+- name: check if ceph mon is running
shell: ps aux | grep ceph-mon | grep -v grep
- ignore_errors: false
+ ignore_errors: true
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
+- name: configure profile and disable some features in ceph for kernel compatible.
+ shell: "{{ item }}"
+ become: true
+ ignore_errors: yes
+ with_items:
+ - ceph osd crush tunables hammer
+ - grep -q "^rbd default features" /etc/ceph/ceph.conf || sed -i '/\[global\]/arbd default features = 1' /etc/ceph/ceph.conf
+ when: service_ceph_mon_status.rc == 0 and service_ceph_osd_status.rc == 0
+
+- name: create specified pools and initialize them with default pool size.
+ shell: ceph osd pool create {{ item }} 100 && ceph osd pool set {{ item }} 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
+ with_items: "{{ ceph_pools }}"
+ when: service_ceph_mon_status.rc == 0 and service_ceph_osd_status.rc == 0
diff --git a/ci/ansible/roles/osdsdock/scenarios/cinder.yml b/ci/ansible/roles/osdsdock/scenarios/cinder.yml
index 7313caa..97ebe9d 100644
--- a/ci/ansible/roles/osdsdock/scenarios/cinder.yml
+++ b/ci/ansible/roles/osdsdock/scenarios/cinder.yml
@@ -1 +1,32 @@
+# Copyright (c) 2018 Huawei Technologies Co., Ltd. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
---
+- name: configure cinder section in opensds global info if specify cinder backend
+ shell: |
+ cat >> opensds.conf <<OPENSDS_GLOABL_CONFIG_DOC
+
+ [cinder]
+ name = {{ cinder_name }}
+ description = {{ cinder_description }}
+ driver_name = {{ cinder_driver_name }}
+ config_path = {{ cinder_config_path }}
+ args:
+ chdir: "{{ opensds_config_dir }}"
+ ignore_errors: yes
+
+- name: copy opensds cinder backend file to cinder config path if specify cinder backend
+ copy:
+ src: ../../../group_vars/cinder/cinder.yaml
+ dest: "{{ cinder_config_path }}"
diff --git a/ci/ansible/roles/osdsdock/scenarios/cinder_standalone.yml b/ci/ansible/roles/osdsdock/scenarios/cinder_standalone.yml
index 4ad5cea..b62d2d1 100644
--- a/ci/ansible/roles/osdsdock/scenarios/cinder_standalone.yml
+++ b/ci/ansible/roles/osdsdock/scenarios/cinder_standalone.yml
@@ -1,20 +1,45 @@
----
-
-- name: install python-pip
- apt:
- name: python-pip
+# Copyright (c) 2018 Huawei Technologies Co., Ltd. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
-- name: install lvm2
+---
+- name: install python-pip, lvm2, thin-provisioning-tools and docker-compose
apt:
- name: lvm2
+ name: "{{ item }}"
+ state: present
+ with_items:
+ - python-pip
+ - lvm2
+ - thin-provisioning-tools
+ - docker-compose
+
+- name: configure cinder section in opensds global info if specify cinder backend
+ shell: |
+ cat >> opensds.conf <<OPENSDS_GLOABL_CONFIG_DOC
-- name: install thin-provisioning-tools
- apt:
- name: thin-provisioning-tools
+ [cinder]
+ name = {{ cinder_name }}
+ description = {{ cinder_description }}
+ driver_name = {{ cinder_driver_name }}
+ config_path = {{ cinder_config_path }}
+ args:
+ chdir: "{{ opensds_config_dir }}"
+ ignore_errors: yes
-- name: install docker-compose
- pip:
- name: docker-compose
+- name: copy opensds cinder backend file to cinder config path if specify cinder backend
+ copy:
+ src: ../../../group_vars/cinder/cinder.yaml
+ dest: "{{ cinder_config_path }}"
- name: create directory to save source code and volume group file
file:
@@ -36,6 +61,11 @@
local vg_dev
vg_dev=`sudo losetup -f --show $backing_file`
+ # Only create physical volume if it doesn't already exist
+ if ! sudo pvs $vg_dev; then
+ sudo pvcreate $vg_dev
+ fi
+
# Only create volume group if it doesn't already exist
if ! sudo vgs $vg; then
sudo vgcreate $vg $vg_dev
@@ -114,7 +144,9 @@
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/image: lvm-debian-cinder/image: lvm-{{ cinder_image_tag }}/g" docker-compose.yml
+
+ sed -i "s/3306:3306/3307:3306/g" docker-compose.yml
sed -i "s/volume_group = cinder-volumes /volume_group = {{ cinder_volume_group }}/g" etc/cinder.conf
become: true
@@ -137,5 +169,5 @@
wait_for:
host: 127.0.0.1
port: 8776
- delay: 2
+ delay: 15
timeout: 120
diff --git a/ci/ansible/roles/osdsdock/scenarios/lvm.yml b/ci/ansible/roles/osdsdock/scenarios/lvm.yml
index d1d7b36..a93f1e4 100644
--- a/ci/ansible/roles/osdsdock/scenarios/lvm.yml
+++ b/ci/ansible/roles/osdsdock/scenarios/lvm.yml
@@ -1,22 +1,78 @@
+# Copyright (c) 2018 Huawei Technologies Co., Ltd. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
---
-- name: install lvm2 external package when lvm backend enabled
+- name: install lvm2 ang tgt external package when lvm backend enabled
apt:
- name: lvm2
+ name: "{{ item }}"
+ state: present
+ with_items:
+ - lvm2
+ - tgt
+ - thin-provisioning-tools
+
+- name: configure lvm section in opensds global info if specify lvm backend
+ shell: |
+ cat >> opensds.conf <<OPENSDS_GLOABL_CONFIG_DOC
-- name: check if physical volume existed
- shell: pvdisplay {{ pv_device }}
+ [lvm]
+ name = {{ lvm_name }}
+ description = {{ lvm_description }}
+ driver_name = {{ lvm_driver_name }}
+ config_path = {{ lvm_config_path }}
+ args:
+ chdir: "{{ opensds_config_dir }}"
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: copy opensds lvm backend file to lvm config path if specify lvm backend
+ copy:
+ src: ../../../group_vars/lvm/lvm.yaml
+ dest: "{{ lvm_config_path }}"
-- name: check if volume group existed
- shell: vgdisplay {{ vg_name }}
- ignore_errors: yes
- register: vg_existed
+- name: create directory to volume group file
+ file:
+ path: "{{ opensds_work_dir }}/volumegroups"
+ 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={{ opensds_work_dir }}/volumegroups/${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 physical volume if it doesn't already exist
+ if ! sudo pvs $vg_dev; then
+ sudo pvcreate $vg_dev
+ fi
-- name: create a volume group
- shell: vgcreate {{ vg_name }} {{ pv_device }}
- when: vg_existed is undefined or vg_existed.rc != 0
+ # 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 {{ opensds_volume_group }} 10G
+ args:
+ executable: /bin/bash
+ become: true
diff --git a/ci/ansible/roles/osdsdock/tasks/main.yml b/ci/ansible/roles/osdsdock/tasks/main.yml
index 2462905..dc803b5 100644
--- a/ci/ansible/roles/osdsdock/tasks/main.yml
+++ b/ci/ansible/roles/osdsdock/tasks/main.yml
@@ -1,3 +1,17 @@
+# Copyright (c) 2018 Huawei Technologies Co., Ltd. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
---
- name: include scenarios/lvm.yml
include: scenarios/lvm.yml
@@ -23,9 +37,26 @@
i="$((i+1))"
[ "$i" -lt 4 ]
do
- nohup bin/osdsdock &>/dev/null &
+ nohup bin/osdsdock > osdsdock.out 2> osdsdock.err < /dev/null &
sleep 5
ps aux | grep osdsdock | grep -v grep && break
done
args:
- chdir: "{{ opensds_build_dir }}/out"
+ chdir: "{{ opensds_work_dir }}"
+ when: install_from != "container"
+
+- name: run osdsdock containerized service
+ docker_container:
+ name: osdsdock
+ image: "{{ dock_docker_image }}"
+ state: started
+ network_mode: host
+ privileged: true
+ volumes:
+ - "/etc/opensds:/etc/opensds"
+ - "/etc/ceph:/etc/ceph"
+ - "/dev/:/dev/"
+ - "/run/:/run/:shared"
+ - "/etc/localtime:/etc/localtime:ro"
+ - "/lib/modules:/lib/modules:ro"
+ when: install_from == "container"