Skip to content

Instantly share code, notes, and snippets.

@chrrrles
Created September 29, 2015 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrrrles/696e9bba8f13ee90007d to your computer and use it in GitHub Desktop.
Save chrrrles/696e9bba8f13ee90007d to your computer and use it in GitHub Desktop.
---
- name: test float values with lvol
sudo: yes
remote_user: user
hosts: all
vars:
img: /tmp/lvol_test.img
tasks:
- name: create loop image
shell: dd if=/dev/zero of={{ img }} bs=1M count=100
- name: find loop device
shell: losetup -f
register: loop
- name: attach image to loop
command: losetup {{ loop.stdout }} {{ img }}
- name: create LVM fs partition
raw: (echo n; echo p; echo; echo; echo; echo t; echo 8e; echo w) | fdisk {{ loop.stdout }}
ignore_errors: yes
- name: create LVM physical volume
shell: pvcreate -f {{ loop.stdout }}
- name: delete test volume group
shell: vgremove -f test
ignore_errors: yes
- name: create volume group
lvg: vg=test pvs={{ loop.stdout }} force=yes pesize=2
- name: create logical volume with a float value and a unit
lvol: vg=test lv=test size=0.046G force=yes state=present
- name: find size of test volume
shell: lvdisplay test
register: lv
- name: Assert that LV Size is 48.00 MiB
assert:
that:
- "'LV Size 48.00 MiB' in lv.stdout"
- name: delete test volume
shell: lvremove -f test
- name: create logical volume with an integer value
lvol: vg=test lv=test size=82 force=yes state=present
- name: find size of test volume
shell: lvdisplay test
register: lv
- name: Assert that LV Size is 82.00 MiB
assert:
that:
- "'LV Size 82.00 MiB' in lv.stdout"
- name: delete test volume
shell: lvremove -f test
- name: create logical volume with an integer value and a unit
lvol: vg=test lv=test size=40M force=yes state=present
- name: find size of test volume
shell: lvdisplay test
register: lv
- name: Assert that LV Size is 40.00 MiB
assert:
that:
- "'LV Size 40.00 MiB' in lv.stdout"
- name: delete test volume
shell: lvremove -f test
- name: create logical volume with a percentage unit
lvol: vg=test lv=test size=98%FREE force=yes state=present
- name: find size of test volume
shell: lvdisplay test
register: lv
- name: Assert that LV Size is 96.00 MiB
assert:
that:
- "'LV Size 96.00 MiB' in lv.stdout"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment