mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-27 18:50:21 -07:00
filesystem: extend support for FreeBSD (#2902)
* extend support for FreeBSD * Check if FS exists with `fstyp` if `blkid` fails to find FS signature (fix a potential data loss) * Add support for FreeBSD special devices (character devices). * Add support for FreeBSD native fstype (UFS). * Update DOCUMENTATION accordingly. * add/update integration tests * Add tests for `fstype=ufs` on FreeBSD. * Run `remove_fs` tests (`state=absent`) on FreeBSD. * Run `overwrite_another_fs` tests on FreeBSD. * add a changelog fragment * fix indentation * restrict new tests to regular files * fix typo * fix searching of providersize (block count) * add '-y' option to growfs command * remove references to versions older than the collection itself * bump version adding new feats to 3.4.0 * reformat *collection* and *version added* for better DOCUMENTATION parsing * skip tests for FreeBSD < 12.2 * run tests for FreeBSD >= 12.2 * re-enable tests for FreeBSD < 12.2 and give it a try with group1 * util-linux not available on FreeBSD < 12.2
This commit is contained in:
parent
4ae392e5de
commit
9023d4dba1
10 changed files with 162 additions and 46 deletions
|
@ -1,5 +1,5 @@
|
|||
destructive
|
||||
shippable/posix/group3
|
||||
shippable/posix/group1
|
||||
skip/aix
|
||||
skip/osx
|
||||
skip/macos
|
||||
|
|
|
@ -23,3 +23,9 @@ tested_filesystems:
|
|||
f2fs: {fssize: '{{ f2fs_fssize|default(60) }}', grow: 'f2fs_version is version("1.10.0", ">=")'}
|
||||
lvm: {fssize: 20, grow: True}
|
||||
swap: {fssize: 10, grow: False} # grow not implemented
|
||||
ufs: {fssize: 10, grow: True}
|
||||
|
||||
|
||||
get_uuid_any: "blkid -c /dev/null -o value -s UUID {{ dev }}"
|
||||
get_uuid_ufs: "dumpfs {{ dev }} | awk -v sb=superblock -v id=id '$1 == sb && $4 == id {print $6$7}'"
|
||||
get_uuid_cmd: "{{ get_uuid_ufs if fstype == 'ufs' else get_uuid_any }}"
|
||||
|
|
|
@ -19,6 +19,17 @@
|
|||
ansible.builtin.set_fact:
|
||||
dev: "{{ loop_device_cmd.stdout }}"
|
||||
|
||||
- when: fstype == 'ufs'
|
||||
block:
|
||||
- name: 'Create a memory disk for UFS'
|
||||
ansible.builtin.command:
|
||||
cmd: 'mdconfig -a -f {{ dev }}'
|
||||
register: memory_disk_cmd
|
||||
|
||||
- name: 'Switch to memory disk target for further tasks'
|
||||
ansible.builtin.set_fact:
|
||||
dev: "/dev/{{ memory_disk_cmd.stdout }}"
|
||||
|
||||
- include_tasks: '{{ action }}.yml'
|
||||
|
||||
always:
|
||||
|
@ -28,10 +39,16 @@
|
|||
removes: '{{ dev }}'
|
||||
when: fstype == 'lvm'
|
||||
|
||||
- name: 'Clean correct device for LVM'
|
||||
- name: 'Detach memory disk used for UFS'
|
||||
ansible.builtin.command:
|
||||
cmd: 'mdconfig -d -u {{ dev }}'
|
||||
removes: '{{ dev }}'
|
||||
when: fstype == 'ufs'
|
||||
|
||||
- name: 'Clean correct device for LVM and UFS'
|
||||
ansible.builtin.set_fact:
|
||||
dev: '{{ image_file }}'
|
||||
when: fstype == 'lvm'
|
||||
when: fstype in ['lvm', 'ufs']
|
||||
|
||||
- name: 'Remove disk image file'
|
||||
ansible.builtin.file:
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
- 'fs_result is success'
|
||||
|
||||
- name: "Get UUID of created filesystem"
|
||||
ansible.builtin.command:
|
||||
cmd: 'blkid -c /dev/null -o value -s UUID {{ dev }}'
|
||||
ansible.builtin.shell:
|
||||
cmd: "{{ get_uuid_cmd }}"
|
||||
changed_when: false
|
||||
register: uuid
|
||||
|
||||
|
@ -24,8 +24,8 @@
|
|||
register: fs2_result
|
||||
|
||||
- name: "Get UUID of the filesystem"
|
||||
ansible.builtin.command:
|
||||
cmd: 'blkid -c /dev/null -o value -s UUID {{ dev }}'
|
||||
ansible.builtin.shell:
|
||||
cmd: "{{ get_uuid_cmd }}"
|
||||
changed_when: false
|
||||
register: uuid2
|
||||
|
||||
|
@ -44,8 +44,8 @@
|
|||
register: fs3_result
|
||||
|
||||
- name: "Get UUID of the new filesystem"
|
||||
ansible.builtin.command:
|
||||
cmd: 'blkid -c /dev/null -o value -s UUID {{ dev }}'
|
||||
ansible.builtin.shell:
|
||||
cmd: "{{ get_uuid_cmd }}"
|
||||
changed_when: false
|
||||
register: uuid3
|
||||
|
||||
|
@ -71,6 +71,11 @@
|
|||
cmd: 'losetup -c {{ dev }}'
|
||||
when: fstype == 'lvm'
|
||||
|
||||
- name: "Resize memory disk for UFS"
|
||||
ansible.builtin.command:
|
||||
cmd: 'mdconfig -r -u {{ dev }} -s {{ fssize | int + 1 }}M'
|
||||
when: fstype == 'ufs'
|
||||
|
||||
- name: "Expand filesystem"
|
||||
community.general.filesystem:
|
||||
dev: '{{ dev }}'
|
||||
|
@ -79,8 +84,8 @@
|
|||
register: fs4_result
|
||||
|
||||
- name: "Get UUID of the filesystem"
|
||||
ansible.builtin.command:
|
||||
cmd: 'blkid -c /dev/null -o value -s UUID {{ dev }}'
|
||||
ansible.builtin.shell:
|
||||
cmd: "{{ get_uuid_cmd }}"
|
||||
changed_when: false
|
||||
register: uuid4
|
||||
|
||||
|
|
10
tests/integration/targets/filesystem/tasks/freebsd_setup.yml
Normal file
10
tests/integration/targets/filesystem/tasks/freebsd_setup.yml
Normal file
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
- name: "Uninstall e2fsprogs"
|
||||
ansible.builtin.package:
|
||||
name: e2fsprogs
|
||||
state: absent
|
||||
|
||||
- name: "Install util-linux"
|
||||
ansible.builtin.package:
|
||||
name: util-linux
|
||||
state: present
|
|
@ -35,6 +35,10 @@
|
|||
# Available on FreeBSD but not on testbed (util-linux conflicts with e2fsprogs): wipefs, mkfs.minix
|
||||
- 'not (ansible_system == "FreeBSD" and item.1 in ["overwrite_another_fs", "remove_fs"])'
|
||||
|
||||
# Linux limited support
|
||||
# Not available: ufs (this is FreeBSD's native fs)
|
||||
- 'not (ansible_system == "Linux" and item.0.key == "ufs")'
|
||||
|
||||
# Other limitations and corner cases
|
||||
|
||||
# f2fs-tools and reiserfs-utils packages not available with RHEL/CentOS on CI
|
||||
|
@ -59,3 +63,24 @@
|
|||
item.0.key == "xfs" and ansible_python.version.major == 2)'
|
||||
|
||||
loop: "{{ query('dict', tested_filesystems)|product(['create_fs', 'overwrite_another_fs', 'remove_fs'])|list }}"
|
||||
|
||||
|
||||
# With FreeBSD extended support (util-linux is not available before 12.2)
|
||||
|
||||
- include_tasks: freebsd_setup.yml
|
||||
when:
|
||||
- 'ansible_system == "FreeBSD"'
|
||||
- 'ansible_distribution_version is version("12.2", ">=")'
|
||||
|
||||
- include_tasks: create_device.yml
|
||||
vars:
|
||||
image_file: '{{ remote_tmp_dir }}/img'
|
||||
fstype: '{{ item.0.key }}'
|
||||
fssize: '{{ item.0.value.fssize }}'
|
||||
grow: '{{ item.0.value.grow }}'
|
||||
action: '{{ item.1 }}'
|
||||
when:
|
||||
- 'ansible_system == "FreeBSD"'
|
||||
- 'ansible_distribution_version is version("12.2", ">=")'
|
||||
- 'item.0.key in ["xfs", "vfat"]'
|
||||
loop: "{{ query('dict', tested_filesystems)|product(['create_fs', 'overwrite_another_fs', 'remove_fs'])|list }}"
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
cmd: 'mkfs.minix {{ dev }}'
|
||||
|
||||
- name: 'Get UUID of the new filesystem'
|
||||
ansible.builtin.command:
|
||||
cmd: 'blkid -c /dev/null -o value -s UUID {{ dev }}'
|
||||
ansible.builtin.shell:
|
||||
cmd: "{{ get_uuid_cmd }}"
|
||||
changed_when: false
|
||||
register: uuid
|
||||
|
||||
|
@ -23,8 +23,8 @@
|
|||
ignore_errors: True
|
||||
|
||||
- name: 'Get UUID of the filesystem'
|
||||
ansible.builtin.command:
|
||||
cmd: 'blkid -c /dev/null -o value -s UUID {{ dev }}'
|
||||
ansible.builtin.shell:
|
||||
cmd: "{{ get_uuid_cmd }}"
|
||||
changed_when: false
|
||||
register: uuid2
|
||||
|
||||
|
@ -42,8 +42,8 @@
|
|||
register: fs_result2
|
||||
|
||||
- name: 'Get UUID of the new filesystem'
|
||||
ansible.builtin.command:
|
||||
cmd: 'blkid -c /dev/null -o value -s UUID {{ dev }}'
|
||||
ansible.builtin.shell:
|
||||
cmd: "{{ get_uuid_cmd }}"
|
||||
changed_when: false
|
||||
register: uuid3
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
fstype: '{{ fstype }}'
|
||||
|
||||
- name: "Get filesystem UUID with 'blkid'"
|
||||
ansible.builtin.command:
|
||||
cmd: 'blkid -c /dev/null -o value -s UUID {{ dev }}'
|
||||
ansible.builtin.shell:
|
||||
cmd: "{{ get_uuid_cmd }}"
|
||||
changed_when: false
|
||||
register: blkid_ref
|
||||
|
||||
|
@ -27,8 +27,8 @@
|
|||
check_mode: yes
|
||||
|
||||
- name: "Get filesystem UUID with 'blkid' (should remain the same)"
|
||||
ansible.builtin.command:
|
||||
cmd: 'blkid -c /dev/null -o value -s UUID {{ dev }}'
|
||||
ansible.builtin.shell:
|
||||
cmd: "{{ get_uuid_cmd }}"
|
||||
changed_when: false
|
||||
register: blkid
|
||||
|
||||
|
@ -46,8 +46,8 @@
|
|||
register: wipefs
|
||||
|
||||
- name: "Get filesystem UUID with 'blkid' (should be empty)"
|
||||
ansible.builtin.command:
|
||||
cmd: 'blkid -c /dev/null -o value -s UUID {{ dev }}'
|
||||
ansible.builtin.shell:
|
||||
cmd: "{{ get_uuid_cmd }}"
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
register: blkid
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue