2021-05-18 06:46:45 +02:00
|
|
|
---
|
|
|
|
- name: "Create filesystem"
|
|
|
|
community.general.filesystem:
|
2020-03-09 10:11:07 +01:00
|
|
|
dev: '{{ dev }}'
|
|
|
|
fstype: '{{ fstype }}'
|
|
|
|
register: fs_result
|
|
|
|
|
2021-05-18 06:46:45 +02:00
|
|
|
- name: "Assert that results are as expected"
|
|
|
|
ansible.builtin.assert:
|
2020-03-09 10:11:07 +01:00
|
|
|
that:
|
|
|
|
- 'fs_result is changed'
|
|
|
|
- 'fs_result is success'
|
|
|
|
|
2021-05-18 06:46:45 +02:00
|
|
|
- name: "Get UUID of created filesystem"
|
2021-07-10 16:37:31 +02:00
|
|
|
ansible.builtin.shell:
|
|
|
|
cmd: "{{ get_uuid_cmd }}"
|
2021-05-18 06:46:45 +02:00
|
|
|
changed_when: false
|
2020-03-09 10:11:07 +01:00
|
|
|
register: uuid
|
|
|
|
|
|
|
|
- name: "Check that filesystem isn't created if force isn't used"
|
2021-05-18 06:46:45 +02:00
|
|
|
community.general.filesystem:
|
2020-03-09 10:11:07 +01:00
|
|
|
dev: '{{ dev }}'
|
|
|
|
fstype: '{{ fstype }}'
|
|
|
|
register: fs2_result
|
|
|
|
|
2021-05-18 06:46:45 +02:00
|
|
|
- name: "Get UUID of the filesystem"
|
2021-07-10 16:37:31 +02:00
|
|
|
ansible.builtin.shell:
|
|
|
|
cmd: "{{ get_uuid_cmd }}"
|
2021-05-18 06:46:45 +02:00
|
|
|
changed_when: false
|
2020-03-09 10:11:07 +01:00
|
|
|
register: uuid2
|
|
|
|
|
2021-05-18 06:46:45 +02:00
|
|
|
- name: "Assert that filesystem UUID is not changed"
|
|
|
|
ansible.builtin.assert:
|
2020-03-09 10:11:07 +01:00
|
|
|
that:
|
2021-05-18 06:46:45 +02:00
|
|
|
- 'fs2_result is not changed'
|
2020-03-09 10:11:07 +01:00
|
|
|
- 'fs2_result is success'
|
|
|
|
- 'uuid.stdout == uuid2.stdout'
|
|
|
|
|
2021-05-18 06:46:45 +02:00
|
|
|
- name: "Check that filesystem is recreated if force is used"
|
|
|
|
community.general.filesystem:
|
2020-03-09 10:11:07 +01:00
|
|
|
dev: '{{ dev }}'
|
|
|
|
fstype: '{{ fstype }}'
|
|
|
|
force: yes
|
|
|
|
register: fs3_result
|
|
|
|
|
2021-05-18 06:46:45 +02:00
|
|
|
- name: "Get UUID of the new filesystem"
|
2021-07-10 16:37:31 +02:00
|
|
|
ansible.builtin.shell:
|
|
|
|
cmd: "{{ get_uuid_cmd }}"
|
2021-05-18 06:46:45 +02:00
|
|
|
changed_when: false
|
2020-03-09 10:11:07 +01:00
|
|
|
register: uuid3
|
|
|
|
|
2021-05-18 06:46:45 +02:00
|
|
|
- name: "Assert that filesystem UUID is changed"
|
|
|
|
# libblkid gets no UUID at all for this fstype on FreeBSD
|
|
|
|
when: not (ansible_system == 'FreeBSD' and fstype == 'reiserfs')
|
|
|
|
ansible.builtin.assert:
|
2020-03-09 10:11:07 +01:00
|
|
|
that:
|
|
|
|
- 'fs3_result is changed'
|
|
|
|
- 'fs3_result is success'
|
|
|
|
- 'uuid.stdout != uuid3.stdout'
|
|
|
|
|
|
|
|
|
2021-02-03 07:54:04 +01:00
|
|
|
- when: 'grow|bool and (fstype != "vfat" or resize_vfat)'
|
2020-03-09 10:11:07 +01:00
|
|
|
block:
|
2021-05-18 06:46:45 +02:00
|
|
|
- name: "Increase fake device"
|
|
|
|
community.general.filesize:
|
|
|
|
path: '{{ image_file }}'
|
|
|
|
size: '{{ fssize | int + 1 }}M'
|
|
|
|
|
|
|
|
- name: "Resize loop device for LVM"
|
|
|
|
ansible.builtin.command:
|
|
|
|
cmd: 'losetup -c {{ dev }}'
|
2021-02-03 07:54:04 +01:00
|
|
|
when: fstype == 'lvm'
|
2020-03-09 10:11:07 +01:00
|
|
|
|
2021-07-10 16:37:31 +02:00
|
|
|
- name: "Resize memory disk for UFS"
|
|
|
|
ansible.builtin.command:
|
|
|
|
cmd: 'mdconfig -r -u {{ dev }} -s {{ fssize | int + 1 }}M'
|
|
|
|
when: fstype == 'ufs'
|
|
|
|
|
2021-05-18 06:46:45 +02:00
|
|
|
- name: "Expand filesystem"
|
|
|
|
community.general.filesystem:
|
2021-02-03 07:54:04 +01:00
|
|
|
dev: '{{ dev }}'
|
|
|
|
fstype: '{{ fstype }}'
|
|
|
|
resizefs: yes
|
|
|
|
register: fs4_result
|
|
|
|
|
2021-05-18 06:46:45 +02:00
|
|
|
- name: "Get UUID of the filesystem"
|
2021-07-10 16:37:31 +02:00
|
|
|
ansible.builtin.shell:
|
|
|
|
cmd: "{{ get_uuid_cmd }}"
|
2021-05-18 06:46:45 +02:00
|
|
|
changed_when: false
|
2021-02-03 07:54:04 +01:00
|
|
|
register: uuid4
|
|
|
|
|
2021-05-18 06:46:45 +02:00
|
|
|
- name: "Assert that filesystem UUID is not changed"
|
|
|
|
ansible.builtin.assert:
|
2021-02-03 07:54:04 +01:00
|
|
|
that:
|
|
|
|
- 'fs4_result is changed'
|
|
|
|
- 'fs4_result is success'
|
|
|
|
- 'uuid3.stdout == uuid4.stdout' # unchanged
|
|
|
|
|
|
|
|
- when:
|
|
|
|
- (grow | bool and (fstype != "vfat" or resize_vfat)) or
|
|
|
|
(fstype == "xfs" and ansible_system == "Linux" and
|
|
|
|
ansible_distribution not in ["CentOS", "Ubuntu"])
|
2020-03-09 10:11:07 +01:00
|
|
|
block:
|
2021-05-18 06:46:45 +02:00
|
|
|
- name: "Check that resizefs does nothing if device size is not changed"
|
|
|
|
community.general.filesystem:
|
2021-02-03 07:54:04 +01:00
|
|
|
dev: '{{ dev }}'
|
|
|
|
fstype: '{{ fstype }}'
|
|
|
|
resizefs: yes
|
|
|
|
register: fs5_result
|
|
|
|
|
2021-05-18 06:46:45 +02:00
|
|
|
- name: "Assert that the state did not change"
|
|
|
|
ansible.builtin.assert:
|
2021-02-03 07:54:04 +01:00
|
|
|
that:
|
|
|
|
- 'fs5_result is not changed'
|
|
|
|
- 'fs5_result is succeeded'
|