2 # Copyright 2015, Rackspace US, Inc.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
16 - name: Create sparse Cinder file
17 command: "truncate -s {{ bootstrap_host_loopback_cinder_size }}G /openstack/cinder.img"
19 creates: /openstack/cinder.img
20 register: cinder_create
24 - name: Get a loopback device for cinder file
26 when: cinder_create | changed
27 register: cinder_losetup
31 - name: Create the loopback device
32 command: "losetup {{ cinder_losetup.stdout }} /openstack/cinder.img"
33 when: cinder_create | changed
35 - cinder-device-create
37 - name: Ensure that rc.local exists
39 path: "{{ rc_local }}"
45 # As the cinder loopback is an LVM VG, it needs to be mounted differently
46 # to the other loopback files. It requires the use of rc.local to attach
47 # the loopback device on boot so that the VG becomes available immediately
48 # after the boot process completes.
49 - name: Create loopback devices at boot time
51 dest: "{{ rc_local }}"
52 line: "losetup $(losetup -f) /openstack/cinder.img"
53 insertbefore: "{{ rc_local_insert_before }}"
57 - name: Make LVM physical volume on the cinder device
59 when: cinder_create | changed
61 - "pvcreate {{ cinder_losetup.stdout }}"
66 - name: Add cinder-volumes volume group
69 pvs: "{{ cinder_losetup.stdout }}"
70 when: cinder_create | changed