summaryrefslogtreecommitdiffstats
path: root/deploy/adapters/ansible/roles/cinder-volume/tasks/main.yml
blob: 3700bcdde319410c682e52b5c09d0a9abe66990b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
---
- include_vars: "{{ ansible_os_family }}.yml"

- name: install cinder-volume and lvm2 packages
  action: "{{ ansible_pkg_mgr }} name={{ item }} state=present"
  with_items: packages | union(packages_noarch)

- name: generate cinder volume service list
  shell: echo {{ item }} >> /opt/service
  with_items: services | union(services_noarch)

- name: check if physical device exists
  stat: path={{ physical_device }}
  register: status

- name: replace physical_device if st is false
  local_action: copy src=loop.yml dest=/tmp/loop.yml
  when: status.stat.exists == False

- name: load loop.yml
  include_vars: /tmp/loop.yml
  when: status.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: losetup -f
  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 services