From 3115ffa4e8994e2e68dd3df61cd4e00232f55b75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Ole=C5=9B?= Date: Thu, 3 Sep 2015 10:51:41 +0000 Subject: [PATCH 1/4] Remove creating cinder volume from bootstrap --- bootstrap/playbooks/build-main.yml | 1 - bootstrap/playbooks/tasks/cinder.yml | 15 --------------- slave_cinder.yml | 14 -------------- 3 files changed, 30 deletions(-) delete mode 100644 bootstrap/playbooks/tasks/cinder.yml delete mode 100644 slave_cinder.yml diff --git a/bootstrap/playbooks/build-main.yml b/bootstrap/playbooks/build-main.yml index 1e8d524d..479d6494 100644 --- a/bootstrap/playbooks/build-main.yml +++ b/bootstrap/playbooks/build-main.yml @@ -8,5 +8,4 @@ - include: tasks/puppet.yml - include: tasks/docker.yml #- include: celery.yml tags=['master'] celery_dir=/var/run/celery - - include: tasks/cinder.yml - include: tasks/cloud_archive.yml diff --git a/bootstrap/playbooks/tasks/cinder.yml b/bootstrap/playbooks/tasks/cinder.yml deleted file mode 100644 index f34b1438..00000000 --- a/bootstrap/playbooks/tasks/cinder.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- - -- apt: name=lvm2 state=present -- command: sudo truncate -s 10G /root/cinder.img creates=/root/cinder.img -- shell: sudo losetup -a|grep cinder - register: loop_created - ignore_errors: True -- command: sudo losetup /dev/loop0 /root/cinder.img - when: loop_created|failed -# retries: 5 -# delay: 1 -- lvg: vg=cinder-volumes pvs=/dev/loop0 - when: loop_created|failed -# retries: 5 -# delay: 1 diff --git a/slave_cinder.yml b/slave_cinder.yml deleted file mode 100644 index aafb61d8..00000000 --- a/slave_cinder.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- - -- hosts: all - sudo: yes - tasks: - - apt: name=lvm2 state=present - - command: sudo truncate -s 10G /root/cinder.img creates=/root/cinder.img - - shell: sudo losetup -a|grep cinder - register: loop_created - ignore_errors: True - - command: sudo losetup /dev/loop0 /root/cinder.img - when: loop_created|failed - - lvg: vg=cinder-volumes pvs=/dev/loop0 - when: loop_created|failed From 6989f9fd70687653d26c6d503d220578a1c09161 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Ole=C5=9B?= Date: Thu, 3 Sep 2015 10:52:22 +0000 Subject: [PATCH 2/4] Volum Group resource --- resources/volume_group/actions/run.yaml | 20 ++++++++++++++++++ resources/volume_group/meta.yaml | 27 +++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 resources/volume_group/actions/run.yaml create mode 100644 resources/volume_group/meta.yaml diff --git a/resources/volume_group/actions/run.yaml b/resources/volume_group/actions/run.yaml new file mode 100644 index 00000000..a96ea373 --- /dev/null +++ b/resources/volume_group/actions/run.yaml @@ -0,0 +1,20 @@ +- hosts: [{{ ip }}] + sudo: yes + tasks: + # install dependencies + - apt: name=lvm2 state=present + # preapara file + - command: truncate -s 10G {{path}} creates={{path}} + # check if loop for file is already created + - shell: losetup -a|grep {{path}} + register: loop_created + ignore_errors: True + # if loop is not created, create it + - command: losetup -f {{path}} + when: loop_created|failed + # get loop, for example /dev/loop0 + - shell: losetup -a|grep '{{path}}'|awk -F':' '{print $1}' + register: loop_device + - name: create Volume Group on loop device + lvg: vg={{volume_name}} pvs={% raw %}{{item}}{% endraw %} state=present + with_items: loop_device.stdout_lines diff --git a/resources/volume_group/meta.yaml b/resources/volume_group/meta.yaml new file mode 100644 index 00000000..d9725073 --- /dev/null +++ b/resources/volume_group/meta.yaml @@ -0,0 +1,27 @@ +id: volume_group +handler: ansible +version: 1.0.0 +input: + volume_name: + schema: str! + value: + path: + schema: str! + value: + + # not used, for now all VGs are file based + type: + schema: str! + value: 'file' + + ip: + schema: str! + value: + ssh_key: + schema: str! + value: + ssh_user: + schema: str! + value: + +tags: [resource/volume_group] From 87caa5bc5f8a318fb09ddfdad6ba577d1195b2e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Ole=C5=9B?= Date: Thu, 3 Sep 2015 10:55:41 +0000 Subject: [PATCH 3/4] Use comments as tasks names --- resources/volume_group/actions/run.yaml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/resources/volume_group/actions/run.yaml b/resources/volume_group/actions/run.yaml index a96ea373..3efd56e3 100644 --- a/resources/volume_group/actions/run.yaml +++ b/resources/volume_group/actions/run.yaml @@ -1,19 +1,19 @@ - hosts: [{{ ip }}] sudo: yes tasks: - # install dependencies - - apt: name=lvm2 state=present - # preapara file - - command: truncate -s 10G {{path}} creates={{path}} - # check if loop for file is already created - - shell: losetup -a|grep {{path}} + - name: install dependencies + apt: name=lvm2 state=present + - name: preapara file + command: truncate -s 10G {{path}} creates={{path}} + - name: check if loop for file is already created + shell: losetup -a|grep {{path}} register: loop_created ignore_errors: True - # if loop is not created, create it - - command: losetup -f {{path}} + - name: if loop is not created, create it + command: losetup -f {{path}} when: loop_created|failed - # get loop, for example /dev/loop0 - - shell: losetup -a|grep '{{path}}'|awk -F':' '{print $1}' + - name: find loop device + shell: losetup -a|grep '{{path}}'|awk -F':' '{print $1}' register: loop_device - name: create Volume Group on loop device lvg: vg={{volume_name}} pvs={% raw %}{{item}}{% endraw %} state=present From 2becead51fd167455f8f8ed591b10ccc5c396b20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Ole=C5=9B?= Date: Thu, 3 Sep 2015 11:22:26 +0000 Subject: [PATCH 4/4] Add remove action for Volum Group resource --- resources/volume_group/actions/remove.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 resources/volume_group/actions/remove.yaml diff --git a/resources/volume_group/actions/remove.yaml b/resources/volume_group/actions/remove.yaml new file mode 100644 index 00000000..60e65206 --- /dev/null +++ b/resources/volume_group/actions/remove.yaml @@ -0,0 +1,14 @@ +- hosts: [{{ ip }}] + sudo: yes + tasks: + - name: remove VG + lvg: vg={{name}} state=absent force=yes + - name: find loop device + shell: losetup -a|grep "/root/cinder.img"|awk -F':' '{print $1}' + register: loop_device + - name: if loop device exists, delete it + command: sudo losetup -d {% raw %}{{item}}{% endraw %} + when: loop_device|success + with_items: loop_device.stdout_lines + +