1 # Copyright (c) 2018 Huawei Technologies Co., Ltd. All Rights Reserved.
\r
3 # Licensed under the Apache License, Version 2.0 (the "License");
\r
4 # you may not use this file except in compliance with the License.
\r
5 # You may obtain a copy of the License at
\r
7 # http://www.apache.org/licenses/LICENSE-2.0
\r
9 # Unless required by applicable law or agreed to in writing, software
\r
10 # distributed under the License is distributed on an "AS IS" BASIS,
\r
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
12 # See the License for the specific language governing permissions and
\r
13 # limitations under the License.
\r
16 - name: install lvm2 ang tgt external package when lvm backend enabled
\r
23 - thin-provisioning-tools
\r
25 - name: configure lvm section in opensds global info if specify lvm backend
\r
27 cat >> opensds.conf <<OPENSDS_GLOABL_CONFIG_DOC
\r
30 name = {{ lvm_name }}
\r
31 description = {{ lvm_description }}
\r
32 driver_name = {{ lvm_driver_name }}
\r
33 config_path = {{ lvm_config_path }}
\r
35 chdir: "{{ opensds_config_dir }}"
\r
38 - name: copy opensds lvm backend file to lvm config path if specify lvm backend
\r
40 src: ../../../group_vars/lvm/lvm.yaml
\r
41 dest: "{{ lvm_config_path }}"
\r
43 - name: create directory to volume group file
\r
45 path: "{{ opensds_work_dir }}/volumegroups"
\r
49 - name: create volume group in thin mode
\r
52 function _create_lvm_volume_group {
\r
56 local backing_file={{ opensds_work_dir }}/volumegroups/${vg}.img
\r
57 if ! sudo vgs $vg; then
\r
58 # Only create if the file doesn't already exists
\r
59 [[ -f $backing_file ]] || truncate -s $size $backing_file
\r
61 vg_dev=`sudo losetup -f --show $backing_file`
\r
63 # Only create physical volume if it doesn't already exist
\r
64 if ! sudo pvs $vg_dev; then
\r
65 sudo pvcreate $vg_dev
\r
68 # Only create volume group if it doesn't already exist
\r
69 if ! sudo vgs $vg; then
\r
70 sudo vgcreate $vg $vg_dev
\r
74 modprobe dm_thin_pool
\r
75 _create_lvm_volume_group {{ opensds_volume_group }} 10G
\r
77 executable: /bin/bash
\r