2 - name: install cinder-volume and lvm2 packages
3 apt: name={{ item }} state=present force=yes
8 - name: generate cinder volume service list
9 shell: echo {{ item }} >> /opt/service
13 - name: check if physical device exists
14 stat: path={{ physical_device }}
17 - name: repace physical_device if st is false
18 local_action: copy src=loop.yml dest=/tmp/loop.yml
19 when: st.stat.exists == False
22 include_vars: /tmp/loop.yml
23 when: st.stat.exists == False
25 - name: check if cinder-volumes is mounted
27 register: cindervolumes
29 - name: get available partition size
30 shell: df / | awk '$3 ~ /[0-9]+/ { print $4 }'
31 register: partition_size
33 - name: if not mounted, mount it
34 shell: dd if=/dev/zero of=/mnt/cinder-volumes
35 bs=1 count=0 seek={{ partition_size.stdout }}
36 when: cindervolumes.stdout != 'cinder-volumes'
38 - name: get first lo device
39 shell: ls /dev/loop* | egrep 'loop[0-9]+'|sed -n 1p
41 when: cindervolumes.stdout != 'cinder-volumes'
43 - name: do a losetup on /mnt/cinder-volumes
44 shell: losetup {{ first_lo.stdout }} /mnt/cinder-volumes
45 when: cindervolumes.stdout != 'cinder-volumes'
47 - name: create physical and group volumes
48 lvg: vg=cinder-volumes pvs={{ physical_device }}
51 - name: upload cinder-volume configuration
52 template: src=cinder.conf dest=/etc/cinder/cinder.conf
55 - restart cinder-volume