mirror of https://github.com/ansible/ansible.git
filesystem tests: enable LVM
Co-authored-by: Pierre-Louis Bonicoli <pierre-louis.bonicoli@libregerbil.fr>pull/46690/head
parent
42730cffc4
commit
e016af3cc6
@ -0,0 +1,27 @@
|
|||||||
|
- name: 'Create a "disk" file'
|
||||||
|
command: 'dd if=/dev/zero of={{ image_file }} bs=1M count={{ fssize }}'
|
||||||
|
|
||||||
|
- vars:
|
||||||
|
dev: '{{ image_file }}'
|
||||||
|
block:
|
||||||
|
- when: fstype == 'lvm'
|
||||||
|
block:
|
||||||
|
- name: 'Create a loop device for LVM'
|
||||||
|
command: 'losetup --show -f {{ dev }}'
|
||||||
|
register: loop_device_cmd
|
||||||
|
|
||||||
|
- set_fact:
|
||||||
|
dev: "{{ loop_device_cmd.stdout }}"
|
||||||
|
|
||||||
|
- include_tasks: '{{ action }}.yml'
|
||||||
|
|
||||||
|
always:
|
||||||
|
- name: 'Detach loop device used for LVM'
|
||||||
|
command: 'losetup -d {{ dev }}'
|
||||||
|
args:
|
||||||
|
removes: '{{ dev }}'
|
||||||
|
when: fstype == 'lvm'
|
||||||
|
|
||||||
|
- file:
|
||||||
|
name: '{{ image_file }}'
|
||||||
|
state: absent
|
@ -1,89 +1,77 @@
|
|||||||
- block:
|
- name: filesystem creation
|
||||||
- name: 'Create a "disk" file'
|
filesystem:
|
||||||
command: 'dd if=/dev/zero of={{ dev }} bs=1M count={{ fssize }}'
|
dev: '{{ dev }}'
|
||||||
|
fstype: '{{ fstype }}'
|
||||||
- name: filesystem creation
|
register: fs_result
|
||||||
filesystem:
|
|
||||||
dev: '{{ dev }}'
|
- assert:
|
||||||
fstype: '{{ fstype }}'
|
that:
|
||||||
register: fs_result
|
- 'fs_result is changed'
|
||||||
|
- 'fs_result is success'
|
||||||
- assert:
|
|
||||||
that:
|
- command: 'blkid -c /dev/null -o value -s UUID {{ dev }}'
|
||||||
- 'fs_result is changed'
|
register: uuid
|
||||||
- 'fs_result is success'
|
|
||||||
|
- name: "Check that filesystem isn't created if force isn't used"
|
||||||
- command: 'blkid -c /dev/null -o value -s UUID {{ dev }}'
|
filesystem:
|
||||||
register: uuid
|
dev: '{{ dev }}'
|
||||||
|
fstype: '{{ fstype }}'
|
||||||
- name: "Check that filesystem isn't created if force isn't used"
|
register: fs2_result
|
||||||
|
|
||||||
|
- command: 'blkid -c /dev/null -o value -s UUID {{ dev }}'
|
||||||
|
register: uuid2
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- 'not (fs2_result is changed)'
|
||||||
|
- 'fs2_result is success'
|
||||||
|
- 'uuid.stdout == uuid2.stdout'
|
||||||
|
|
||||||
|
- name: Check that filesystem is recreated if force is used
|
||||||
|
filesystem:
|
||||||
|
dev: '{{ dev }}'
|
||||||
|
fstype: '{{ fstype }}'
|
||||||
|
force: yes
|
||||||
|
register: fs3_result
|
||||||
|
|
||||||
|
- command: 'blkid -c /dev/null -o value -s UUID {{ dev }}'
|
||||||
|
register: uuid3
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- 'fs3_result is changed'
|
||||||
|
- 'fs3_result is success'
|
||||||
|
- 'uuid.stdout != uuid3.stdout'
|
||||||
|
|
||||||
|
- name: increase fake device
|
||||||
|
shell: 'dd if=/dev/zero bs=1M count=20 >> {{ image_file }}'
|
||||||
|
|
||||||
|
- when: 'grow|bool and (fstype != "vfat" or resize_vfat)'
|
||||||
|
block:
|
||||||
|
- name: Expand filesystem
|
||||||
filesystem:
|
filesystem:
|
||||||
dev: '{{ dev }}'
|
dev: '{{ dev }}'
|
||||||
fstype: '{{ fstype }}'
|
fstype: '{{ fstype }}'
|
||||||
register: fs2_result
|
resizefs: yes
|
||||||
|
register: fs4_result
|
||||||
|
|
||||||
- command: 'blkid -c /dev/null -o value -s UUID {{ dev }}'
|
- command: 'blkid -c /dev/null -o value -s UUID {{ dev }}'
|
||||||
register: uuid2
|
register: uuid4
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- 'not (fs2_result is changed)'
|
- 'fs4_result is changed'
|
||||||
- 'fs2_result is success'
|
- 'fs4_result is success'
|
||||||
- 'uuid.stdout == uuid2.stdout'
|
- 'uuid3.stdout == uuid4.stdout' # unchanged
|
||||||
|
|
||||||
- name: Check that filesystem is recreated if force is used
|
- name: Try to expand filesystem again
|
||||||
filesystem:
|
filesystem:
|
||||||
dev: '{{ dev }}'
|
dev: '{{ dev }}'
|
||||||
fstype: '{{ fstype }}'
|
fstype: '{{ fstype }}'
|
||||||
force: yes
|
resizefs: yes
|
||||||
register: fs3_result
|
register: fs5_result
|
||||||
|
|
||||||
- command: 'blkid -c /dev/null -o value -s UUID {{ dev }}'
|
|
||||||
register: uuid3
|
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- 'fs3_result is changed'
|
- 'not (fs5_result is changed)'
|
||||||
- 'fs3_result is success'
|
- 'fs5_result is successful'
|
||||||
- 'uuid.stdout != uuid3.stdout'
|
|
||||||
|
|
||||||
- name: increase fake device
|
|
||||||
shell: 'dd if=/dev/zero bs=1M count=20 >> {{ dev }}'
|
|
||||||
|
|
||||||
- when: 'grow|bool and (fstype != "vfat" or resize_vfat)'
|
|
||||||
block:
|
|
||||||
- name: Expand filesystem
|
|
||||||
filesystem:
|
|
||||||
dev: '{{ dev }}'
|
|
||||||
fstype: '{{ fstype }}'
|
|
||||||
resizefs: yes
|
|
||||||
register: fs4_result
|
|
||||||
|
|
||||||
- command: 'blkid -c /dev/null -o value -s UUID {{ dev }}'
|
|
||||||
register: uuid4
|
|
||||||
|
|
||||||
- assert:
|
|
||||||
that:
|
|
||||||
- 'fs4_result is changed'
|
|
||||||
- 'fs4_result is success'
|
|
||||||
- 'uuid3.stdout == uuid4.stdout' # unchanged
|
|
||||||
|
|
||||||
- name: Try to expand filesystem again
|
|
||||||
filesystem:
|
|
||||||
dev: '{{ dev }}'
|
|
||||||
fstype: '{{ fstype }}'
|
|
||||||
resizefs: yes
|
|
||||||
register: fs5_result
|
|
||||||
|
|
||||||
- assert:
|
|
||||||
that:
|
|
||||||
- 'not (fs5_result is changed)'
|
|
||||||
- 'fs5_result is successful'
|
|
||||||
|
|
||||||
- import_tasks: overwrite_another_fs.yml
|
|
||||||
when: ansible_system != 'FreeBSD'
|
|
||||||
|
|
||||||
always:
|
|
||||||
- file:
|
|
||||||
name: '{{ dev }}'
|
|
||||||
state: absent
|
|
||||||
|
Loading…
Reference in New Issue