summaryrefslogtreecommitdiffstats
path: root/deploy/adapters/ansible/roles/cinder-volume
diff options
context:
space:
mode:
Diffstat (limited to 'deploy/adapters/ansible/roles/cinder-volume')
-rw-r--r--deploy/adapters/ansible/roles/cinder-volume/files/loop.yml1
-rw-r--r--deploy/adapters/ansible/roles/cinder-volume/handlers/main.yml3
-rw-r--r--deploy/adapters/ansible/roles/cinder-volume/tasks/main.yml54
-rw-r--r--deploy/adapters/ansible/roles/cinder-volume/templates/cinder.conf62
-rw-r--r--deploy/adapters/ansible/roles/cinder-volume/vars/Debian.yml7
5 files changed, 127 insertions, 0 deletions
diff --git a/deploy/adapters/ansible/roles/cinder-volume/files/loop.yml b/deploy/adapters/ansible/roles/cinder-volume/files/loop.yml
new file mode 100644
index 00000000..e872652a
--- /dev/null
+++ b/deploy/adapters/ansible/roles/cinder-volume/files/loop.yml
@@ -0,0 +1 @@
+physical_device: /dev/loop0
diff --git a/deploy/adapters/ansible/roles/cinder-volume/handlers/main.yml b/deploy/adapters/ansible/roles/cinder-volume/handlers/main.yml
new file mode 100644
index 00000000..ad917ce5
--- /dev/null
+++ b/deploy/adapters/ansible/roles/cinder-volume/handlers/main.yml
@@ -0,0 +1,3 @@
+---
+- name: restart cinder-volume
+ service: name=cinder-volume state=restarted enabled=yes
diff --git a/deploy/adapters/ansible/roles/cinder-volume/tasks/main.yml b/deploy/adapters/ansible/roles/cinder-volume/tasks/main.yml
new file mode 100644
index 00000000..d727b66b
--- /dev/null
+++ b/deploy/adapters/ansible/roles/cinder-volume/tasks/main.yml
@@ -0,0 +1,54 @@
+---
+- include_vars: "{{ ansible_os_family }}.yml"
+
+- name: install cinder-volume and lvm2 packages
+ action: "{{ ansible_pkg_mgr }} name={{ item }} state=present force=yes"
+ with_items: packages
+
+- name: generate cinder volume service list
+ shell: echo {{ item }} >> /opt/service
+ with_items: services
+
+- 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
diff --git a/deploy/adapters/ansible/roles/cinder-volume/templates/cinder.conf b/deploy/adapters/ansible/roles/cinder-volume/templates/cinder.conf
new file mode 100644
index 00000000..aa3b8ccd
--- /dev/null
+++ b/deploy/adapters/ansible/roles/cinder-volume/templates/cinder.conf
@@ -0,0 +1,62 @@
+[DEFAULT]
+rootwrap_config = /etc/cinder/rootwrap.conf
+api_paste_confg = /etc/cinder/api-paste.ini
+iscsi_helper = tgtadm
+volume_name_template = volume-%s
+volume_group = cinder-volumes
+verbose = True
+auth_strategy = keystone
+state_path = /var/lib/cinder
+lock_path = /var/lock/cinder
+notification_driver=cinder.openstack.common.notifier.rpc_notifier
+volumes_dir = /var/lib/cinder/volumes
+
+log_file=/var/log/cinder/cinder.log
+
+control_exchange = cinder
+rpc_backend = rabbit
+rabbit_host = {{ rabbit_host }}
+rabbit_port = 5672
+rabbit_userid = {{ RABBIT_USER }}
+rabbit_password = {{ RABBIT_PASS }}
+my_ip = {{ storage_controller_host }}
+
+glance_host = {{ HA_VIP }}
+glance_port = 9292
+api_rate_limit = False
+storage_availability_zone = nova
+
+quota_volumes = 10
+quota_gigabytes=1000
+quota_driver=cinder.quota.DbQuotaDriver
+
+osapi_volume_listen = {{ storage_controller_host }}
+osapi_volume_listen_port = 8776
+
+db_backend = sqlalchemy
+volume_name_template = volume-%s
+snapshot_name_template = snapshot-%s
+
+max_gigabytes=10000
+volume_group=cinder-volumes
+
+volume_clear=zero
+volume_clear_size=10
+
+iscsi_ip_address={{ storage_controller_host }}
+iscsi_port=3260
+iscsi_helper=tgtadm
+
+volumes_dir=/var/lib/cinder/volumes
+
+volume_driver=cinder.volume.drivers.lvm.LVMISCSIDriver
+
+[keystone_authtoken]
+auth_uri = http://{{ HA_VIP }}:5000/v2.0
+identity_uri = http://{{ HA_VIP }}:35357
+admin_tenant_name = service
+admin_user = cinder
+admin_password = {{ CINDER_PASS }}
+
+[database]
+connection = mysql://cinder:{{ CINDER_DBPASS }}@{{ db_host }}/cinder
diff --git a/deploy/adapters/ansible/roles/cinder-volume/vars/Debian.yml b/deploy/adapters/ansible/roles/cinder-volume/vars/Debian.yml
new file mode 100644
index 00000000..e68868cd
--- /dev/null
+++ b/deploy/adapters/ansible/roles/cinder-volume/vars/Debian.yml
@@ -0,0 +1,7 @@
+---
+packages:
+ - cinder-volume
+ - lvm2
+
+services:
+ - cinder-volume