Xicheng Chang 70360bca6a Changed ansible code structure.
Moved roles to the parent directory
so that different adapters don't have
duplicated roles in their respective
paths.

Change-Id: Ia71c473b33fed94276d4d0b4764b2f4ab2e988e0
2015-05-21 20:30:15 -07:00

52 lines
1.4 KiB
YAML

---
- name: install cinder-volume and lvm2 packages
apt: name={{ item }} state=present force=yes
with_items:
- cinder-volume
- lvm2
- name: check if physical device exists
stat: path={{ physical_device }}
register: st
- name: repace physical_device if st is false
local_action: copy src=loop.yml dest=/tmp/loop.yml
when: st.stat.exists == False
- name: load loop.yml
include_vars: /tmp/loop.yml
when: st.stat.exists == False
- name: check if cinder-volumes is mounted
shell: ls /mnt
register: cindervolumes
- name: get available partition size
shell: df / | awk '$3 ~ /[0-9]+/ { print $4 }'
register: partition_size
- name: if not mounted, mount it
shell: dd if=/dev/zero of=/mnt/cinder-volumes
bs=1 count=0 seek={{ partition_size.stdout }}
when: cindervolumes.stdout != 'cinder-volumes'
- name: get first lo device
shell: ls /dev/loop* | egrep 'loop[0-9]+'|sed -n 1p
register: first_lo
when: cindervolumes.stdout != 'cinder-volumes'
- name: do a losetup on /mnt/cinder-volumes
shell: losetup {{ first_lo.stdout }} /mnt/cinder-volumes
when: cindervolumes.stdout != 'cinder-volumes'
- name: create physical and group volumes
lvg: vg=cinder-volumes pvs={{ physical_device }}
vg_options=--force
- name: upload cinder-volume configuration
template: src=cinder.conf dest=/etc/cinder/cinder.conf
backup=yes
notify:
- restart cinder-volume
- restart tgt