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.yml74
-rw-r--r--ci/ansible/roles/osdsdock/scenarios/cinder.yml29
-rw-r--r--ci/ansible/roles/osdsdock/scenarios/cinder_standalone.yml58
-rw-r--r--ci/ansible/roles/osdsdock/scenarios/lvm.yml82
-rw-r--r--ci/ansible/roles/osdsdock/tasks/main.yml20
5 files changed, 209 insertions, 54 deletions
diff --git a/ci/ansible/roles/osdsdock/scenarios/ceph.yml b/ci/ansible/roles/osdsdock/scenarios/ceph.yml
index b844a29..f5ea8ef 100644
--- a/ci/ansible/roles/osdsdock/scenarios/ceph.yml
+++ b/ci/ansible/roles/osdsdock/scenarios/ceph.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: install ceph-common external package when ceph backend enabled
apt:
@@ -5,9 +19,21 @@
state: present
with_items:
- ceph-common
- when: enabled_backend == "ceph"
-- name: copy opensds ceph backend file if specify ceph backend
+- 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 }}"
@@ -22,6 +48,7 @@
git:
repo: https://github.com/ceph/ceph-ansible.git
dest: /opt/ceph-ansible
+ version: stable-3.0
when:
- cephansibleexisted.stat.exists is undefined or cephansibleexisted.stat.exists == false
@@ -35,43 +62,44 @@
src: ../../../group_vars/ceph/all.yml
dest: /opt/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: /opt/ceph-ansible/group_vars/osds.yml
-
- name: copy site.yml.sample to site.yml in ceph-ansible
copy:
src: /opt/ceph-ansible/site.yml.sample
dest: /opt/ceph-ansible/site.yml
-- name: ping all hosts
- shell: ansible all -m ping -i ceph.hosts
- become: true
- args:
- chdir: /opt/ceph-ansible
-
-- name: run ceph-ansible playbook
- shell: ansible-playbook site.yml -i ceph.hosts | tee /var/log/ceph_ansible.log
+- 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: /opt/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 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
+- 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 specified pools and initialize them with default pool size.
+- 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
with_items: "{{ ceph_pools }}"
- when: service_ceph_mon_status.rc == 0 # and service_ceph_osd_status.rc == 0
+ 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 6136f25..97ebe9d 100644
--- a/ci/ansible/roles/osdsdock/scenarios/cinder.yml
+++ b/ci/ansible/roles/osdsdock/scenarios/cinder.yml
@@ -1,5 +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: copy opensds cinder backend file if specify cinder backend
+- 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 49f4063..b62d2d1 100644
--- a/ci/ansible/roles/osdsdock/scenarios/cinder_standalone.yml
+++ b/ci/ansible/roles/osdsdock/scenarios/cinder_standalone.yml
@@ -1,21 +1,42 @@
----
-- name: install python-pip
- apt:
- name: python-pip
-
-- name: install lvm2
- apt:
- name: lvm2
+# 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 thin-provisioning-tools
+---
+- name: install python-pip, lvm2, thin-provisioning-tools and docker-compose
apt:
- name: thin-provisioning-tools
+ 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 docker-compose
- pip:
- name: docker-compose
+ [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 if specify cinder backend
+- 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 }}"
@@ -40,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
@@ -120,6 +146,8 @@
sed -i "s/image: 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
args:
@@ -141,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 743fe3b..a93f1e4 100644
--- a/ci/ansible/roles/osdsdock/scenarios/lvm.yml
+++ b/ci/ansible/roles/osdsdock/scenarios/lvm.yml
@@ -1,20 +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
+
+ [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
-- name: copy opensds lvm backend file if specify lvm backend
+- 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 and initialize it
- lvg:
- vg: "{{ vg_name }}"
- pvs: "{{ pv_devices }}"
- 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 215cf00..8b18c8d 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
@@ -28,15 +42,15 @@
ps aux | grep osdsdock | grep -v grep && break
done
args:
- chdir: "{{ opensds_dir }}"
+ chdir: "{{ opensds_work_dir }}"
when: container_enabled == false
- name: run osdsdock containerized service
- docker:
+ docker_container:
name: osdsdock
image: opensdsio/opensds-dock:latest
state: started
- net: host
+ network_mode: host
privileged: true
volumes:
- "/etc/opensds/:/etc/opensds"