V1
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
azp/posix/1
|
||||
destructive
|
||||
skip/aix
|
||||
skip/osx
|
||||
skip/macos
|
||||
@@ -0,0 +1,35 @@
|
||||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
tested_filesystems:
|
||||
# key: fstype
|
||||
# fssize: size (Mo)
|
||||
# grow: True if resizefs is supported
|
||||
# Other minimal sizes:
|
||||
# - XFS: 20Mo
|
||||
# - Btrfs: 150Mo (50Mo when "--metadata single" is used and 100Mb when on newer Fedora versions)
|
||||
# - f2fs:
|
||||
# - 1.2.0 requires at leat 116Mo
|
||||
# - 1.7.0 requires at least 30Mo
|
||||
# - 1.10.0 requires at least 38Mo
|
||||
# - resizefs asserts when initial fs is smaller than 60Mo and seems to require 1.10.0
|
||||
ext4: {fssize: 10, grow: True}
|
||||
ext4dev: {fssize: 10, grow: True}
|
||||
ext3: {fssize: 10, grow: True}
|
||||
ext2: {fssize: 10, grow: True}
|
||||
xfs: {fssize: 300, grow: False} # grow requires a mounted filesystem
|
||||
btrfs: {fssize: 150, grow: False} # grow requires a mounted filesystem
|
||||
reiserfs: {fssize: 33, grow: False} # grow not implemented
|
||||
vfat: {fssize: 20, grow: True}
|
||||
ocfs2: {fssize: '{{ ocfs2_fssize }}', grow: False} # grow not implemented
|
||||
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 }}"
|
||||
@@ -0,0 +1,8 @@
|
||||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
dependencies:
|
||||
- setup_pkg_mgr
|
||||
- setup_remote_tmp_dir_outside_tmp
|
||||
@@ -0,0 +1,60 @@
|
||||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
- name: 'Create a "disk" file'
|
||||
community.general.filesize:
|
||||
path: '{{ image_file }}'
|
||||
size: '{{ fssize }}M'
|
||||
force: true
|
||||
|
||||
- vars:
|
||||
dev: '{{ image_file }}'
|
||||
block:
|
||||
- when: fstype == 'lvm'
|
||||
block:
|
||||
- name: 'Create a loop device for LVM'
|
||||
ansible.builtin.command:
|
||||
cmd: 'losetup --show -f {{ dev }}'
|
||||
register: loop_device_cmd
|
||||
|
||||
- name: 'Switch to loop device target for further tasks'
|
||||
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:
|
||||
- name: 'Detach loop device used for LVM'
|
||||
ansible.builtin.command:
|
||||
cmd: 'losetup -d {{ dev }}'
|
||||
removes: '{{ dev }}'
|
||||
when: fstype == '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 in ['lvm', 'ufs']
|
||||
|
||||
- name: 'Remove disk image file'
|
||||
ansible.builtin.file:
|
||||
name: '{{ image_file }}'
|
||||
state: absent
|
||||
@@ -0,0 +1,119 @@
|
||||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
- name: "Create filesystem ({{ fstype }})"
|
||||
community.general.filesystem:
|
||||
dev: '{{ dev }}'
|
||||
fstype: '{{ fstype }}'
|
||||
register: fs_result
|
||||
|
||||
- name: "Assert that results are as expected"
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- 'fs_result is changed'
|
||||
- 'fs_result is success'
|
||||
|
||||
- name: "Get UUID of created filesystem"
|
||||
ansible.builtin.shell:
|
||||
cmd: "{{ get_uuid_cmd }}"
|
||||
changed_when: false
|
||||
register: uuid
|
||||
|
||||
- name: "Check that filesystem isn't created if force isn't used"
|
||||
community.general.filesystem:
|
||||
dev: '{{ dev }}'
|
||||
fstype: '{{ fstype }}'
|
||||
register: fs2_result
|
||||
|
||||
- name: "Get UUID of the filesystem"
|
||||
ansible.builtin.shell:
|
||||
cmd: "{{ get_uuid_cmd }}"
|
||||
changed_when: false
|
||||
register: uuid2
|
||||
|
||||
- name: "Assert that filesystem UUID is not changed"
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- 'fs2_result is not changed'
|
||||
- 'fs2_result is success'
|
||||
- 'uuid.stdout == uuid2.stdout'
|
||||
|
||||
- name: "Check that filesystem is recreated if force is used"
|
||||
community.general.filesystem:
|
||||
dev: '{{ dev }}'
|
||||
fstype: '{{ fstype }}'
|
||||
force: yes
|
||||
register: fs3_result
|
||||
|
||||
- name: "Get UUID of the new filesystem"
|
||||
ansible.builtin.shell:
|
||||
cmd: "{{ get_uuid_cmd }}"
|
||||
changed_when: false
|
||||
register: uuid3
|
||||
|
||||
- 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:
|
||||
that:
|
||||
- 'fs3_result is changed'
|
||||
- 'fs3_result is success'
|
||||
- 'uuid.stdout != uuid3.stdout'
|
||||
|
||||
|
||||
- when: 'grow|bool and (fstype != "vfat" or resize_vfat)'
|
||||
block:
|
||||
- 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 }}'
|
||||
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 }}'
|
||||
fstype: '{{ fstype }}'
|
||||
resizefs: yes
|
||||
register: fs4_result
|
||||
|
||||
- name: "Get UUID of the filesystem"
|
||||
ansible.builtin.shell:
|
||||
cmd: "{{ get_uuid_cmd }}"
|
||||
changed_when: false
|
||||
register: uuid4
|
||||
|
||||
- name: "Assert that filesystem UUID is not changed"
|
||||
ansible.builtin.assert:
|
||||
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"])
|
||||
block:
|
||||
- name: "Check that resizefs does nothing if device size is not changed"
|
||||
community.general.filesystem:
|
||||
dev: '{{ dev }}'
|
||||
fstype: '{{ fstype }}'
|
||||
resizefs: yes
|
||||
register: fs5_result
|
||||
|
||||
- name: "Assert that the state did not change"
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- 'fs5_result is not changed'
|
||||
- 'fs5_result is succeeded'
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
- name: "Uninstall e2fsprogs"
|
||||
ansible.builtin.package:
|
||||
name: e2fsprogs
|
||||
state: absent
|
||||
|
||||
- name: "Install util-linux"
|
||||
ansible.builtin.package:
|
||||
name: util-linux
|
||||
state: present
|
||||
@@ -0,0 +1,107 @@
|
||||
---
|
||||
####################################################################
|
||||
# WARNING: These are designed specifically for Ansible tests #
|
||||
# and should not be used as examples of how to write Ansible roles #
|
||||
####################################################################
|
||||
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
- ansible.builtin.debug:
|
||||
msg: '{{ role_name }}'
|
||||
- ansible.builtin.debug:
|
||||
msg: '{{ role_path|basename }}'
|
||||
- import_tasks: setup.yml
|
||||
|
||||
- include_vars: "{{ lookup('first_found', search) }}"
|
||||
vars:
|
||||
search:
|
||||
files:
|
||||
- '{{ ansible_distribution }}-{{ ansible_distribution_version }}.yml'
|
||||
- 'default.yml'
|
||||
paths:
|
||||
- '../vars/'
|
||||
|
||||
- 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:
|
||||
# FreeBSD limited support
|
||||
# Not available: btrfs, lvm, f2fs, ocfs2
|
||||
# All BSD systems use swap fs, but only Linux needs mkswap
|
||||
# Supported: ext2/3/4 (e2fsprogs), xfs (xfsprogs), reiserfs (progsreiserfs), vfat
|
||||
- 'not (ansible_system == "FreeBSD" and item.0.key in ["btrfs", "f2fs", "swap", "lvm", "ocfs2"])'
|
||||
# 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
|
||||
- 'not (ansible_distribution in ["CentOS", "RedHat"] and item.0.key in ["f2fs", "reiserfs"])'
|
||||
- 'not (ansible_os_family == "RedHat" and ansible_distribution_major_version is version("8", ">=") and
|
||||
item.0.key == "btrfs")'
|
||||
# reiserfs-utils package not available with Fedora 35 on CI
|
||||
- 'not (ansible_distribution == "Fedora" and (ansible_facts.distribution_major_version | int >= 35) and
|
||||
item.0.key == "reiserfs")'
|
||||
# reiserfs packages apparently not available with Alpine
|
||||
- 'not (ansible_distribution == "Alpine" and item.0.key == "reiserfs")'
|
||||
# ocfs2 only available on Debian based distributions
|
||||
- 'not (item.0.key == "ocfs2" and ansible_os_family != "Debian")'
|
||||
# Tests use losetup which can not be used inside unprivileged container
|
||||
- 'not (item.0.key == "lvm" and ansible_virtualization_type in ["docker", "container", "containerd"])'
|
||||
# vfat resizing fails on Debian (but not Ubuntu)
|
||||
- 'not (item.0.key == "vfat" and ansible_distribution == "Debian")' # TODO: figure out why it fails, fix it!
|
||||
# vfat resizing fails on ArchLinux
|
||||
- 'not (item.0.key == "vfat" and ansible_distribution == "Archlinux")' # TODO: figure out why it fails, fix it!
|
||||
# vfat resizing fails on Ubuntu 22.04
|
||||
- 'not (item.0.key == "vfat" and ansible_distribution == "Ubuntu" and (ansible_facts.distribution_major_version | int == 22))'
|
||||
# TODO: figure out why it fails, fix it!
|
||||
# btrfs-progs cannot be installed on ArchLinux
|
||||
- 'not (item.0.key == "btrfs" and ansible_distribution == "Archlinux")' # TODO: figure out why it fails, fix it!
|
||||
|
||||
# On CentOS 6 shippable containers, wipefs seems unable to remove vfat signatures
|
||||
- 'not (ansible_distribution == "CentOS" and ansible_distribution_version is version("7.0", "<") and
|
||||
item.1 == "remove_fs" and item.0.key == "vfat")'
|
||||
# On same systems, mkfs.minix (unhandled by the module) can't find the device/file
|
||||
- 'not (ansible_distribution == "CentOS" and ansible_distribution_version is version("7.0", "<") and
|
||||
item.1 == "overwrite_another_fs")'
|
||||
|
||||
# The xfsprogs package on newer versions of OpenSUSE (15+) require Python 3, we skip this on our Python 2 container
|
||||
# OpenSUSE 42.3 Python2 and the other py3 containers are not affected so we will continue to run that
|
||||
- 'not (ansible_os_family == "Suse" and ansible_distribution_major_version|int != 42 and
|
||||
item.0.key == "xfs" and ansible_python.version.major == 2)'
|
||||
|
||||
# TODO: something seems to be broken on Alpine
|
||||
- 'not (ansible_distribution == "Alpine")'
|
||||
|
||||
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 }}"
|
||||
@@ -0,0 +1,59 @@
|
||||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
- name: 'Recreate "disk" file'
|
||||
community.general.filesize:
|
||||
path: '{{ image_file }}'
|
||||
size: '{{ fssize }}M'
|
||||
force: true
|
||||
|
||||
- name: 'Create a minix filesystem'
|
||||
ansible.builtin.command:
|
||||
cmd: 'mkfs.minix {{ dev }}'
|
||||
|
||||
- name: 'Get UUID of the new filesystem'
|
||||
ansible.builtin.shell:
|
||||
cmd: "{{ get_uuid_cmd }}"
|
||||
changed_when: false
|
||||
register: uuid
|
||||
|
||||
- name: "Check that an existing filesystem (not handled by this module) isn't overwritten when force isn't used"
|
||||
community.general.filesystem:
|
||||
dev: '{{ dev }}'
|
||||
fstype: '{{ fstype }}'
|
||||
register: fs_result
|
||||
ignore_errors: True
|
||||
|
||||
- name: 'Get UUID of the filesystem'
|
||||
ansible.builtin.shell:
|
||||
cmd: "{{ get_uuid_cmd }}"
|
||||
changed_when: false
|
||||
register: uuid2
|
||||
|
||||
- name: 'Assert that module failed and filesystem UUID is not changed'
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- 'fs_result is failed'
|
||||
- 'uuid.stdout == uuid2.stdout'
|
||||
|
||||
- name: "Check that an existing filesystem (not handled by this module) is overwritten when force is used"
|
||||
community.general.filesystem:
|
||||
dev: '{{ dev }}'
|
||||
fstype: '{{ fstype }}'
|
||||
force: yes
|
||||
register: fs_result2
|
||||
|
||||
- name: 'Get UUID of the new filesystem'
|
||||
ansible.builtin.shell:
|
||||
cmd: "{{ get_uuid_cmd }}"
|
||||
changed_when: false
|
||||
register: uuid3
|
||||
|
||||
- name: 'Assert that module succeeded and filesystem UUID is changed'
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- 'fs_result2 is success'
|
||||
- 'fs_result2 is changed'
|
||||
- 'uuid2.stdout != uuid3.stdout'
|
||||
@@ -0,0 +1,102 @@
|
||||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
# We assume 'create_fs' tests have passed.
|
||||
|
||||
- name: "Create filesystem"
|
||||
community.general.filesystem:
|
||||
dev: '{{ dev }}'
|
||||
fstype: '{{ fstype }}'
|
||||
|
||||
- name: "Get filesystem UUID with 'blkid'"
|
||||
ansible.builtin.shell:
|
||||
cmd: "{{ get_uuid_cmd }}"
|
||||
changed_when: false
|
||||
register: blkid_ref
|
||||
|
||||
- name: "Assert that a filesystem exists on top of the device"
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- blkid_ref.stdout | length > 0
|
||||
|
||||
|
||||
# Test check_mode first
|
||||
- name: "Remove filesystem (check mode)"
|
||||
community.general.filesystem:
|
||||
dev: '{{ dev }}'
|
||||
state: absent
|
||||
register: wipefs
|
||||
check_mode: yes
|
||||
|
||||
- name: "Get filesystem UUID with 'blkid' (should remain the same)"
|
||||
ansible.builtin.shell:
|
||||
cmd: "{{ get_uuid_cmd }}"
|
||||
changed_when: false
|
||||
register: blkid
|
||||
|
||||
- name: "Assert that the state changed but the filesystem still exists"
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- wipefs is changed
|
||||
- blkid.stdout == blkid_ref.stdout
|
||||
|
||||
# Do it
|
||||
- name: "Remove filesystem"
|
||||
community.general.filesystem:
|
||||
dev: '{{ dev }}'
|
||||
state: absent
|
||||
register: wipefs
|
||||
|
||||
- name: "Get filesystem UUID with 'blkid' (should be empty)"
|
||||
ansible.builtin.shell:
|
||||
cmd: "{{ get_uuid_cmd }}"
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
register: blkid
|
||||
|
||||
- name: "Assert that the state changed and the device has no filesystem"
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- wipefs is changed
|
||||
- blkid.stdout | length == 0
|
||||
- blkid.rc == 2
|
||||
|
||||
# Do it again
|
||||
- name: "Remove filesystem (idempotency)"
|
||||
community.general.filesystem:
|
||||
dev: '{{ dev }}'
|
||||
state: absent
|
||||
register: wipefs
|
||||
|
||||
- name: "Assert that the state did not change"
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- wipefs is not changed
|
||||
|
||||
# and again
|
||||
- name: "Remove filesystem (idempotency, check mode)"
|
||||
community.general.filesystem:
|
||||
dev: '{{ dev }}'
|
||||
state: absent
|
||||
register: wipefs
|
||||
check_mode: yes
|
||||
|
||||
- name: "Assert that the state did not change"
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- wipefs is not changed
|
||||
|
||||
|
||||
# By the way, test removal of a filesystem on unexistent device
|
||||
- name: "Remove filesystem (unexistent device)"
|
||||
community.general.filesystem:
|
||||
dev: '/dev/unexistent_device'
|
||||
state: absent
|
||||
register: wipefs
|
||||
|
||||
- name: "Assert that the state did not change"
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- wipefs is not changed
|
||||
@@ -0,0 +1,154 @@
|
||||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
# By installing e2fsprogs on FreeBSD, we get a usable blkid command, but this
|
||||
# package conflicts with util-linux, that provides blkid too, but also wipefs
|
||||
# (required for filesystem state=absent).
|
||||
- name: "Install filesystem tools"
|
||||
ansible.builtin.package:
|
||||
name: '{{ item }}'
|
||||
state: present
|
||||
# xfsprogs on OpenSUSE requires Python 3, skip this for our newer Py2 OpenSUSE builds
|
||||
when: not (item == 'xfsprogs' and ansible_os_family == 'Suse' and ansible_python.version.major == 2 and ansible_distribution_major_version|int != 42)
|
||||
loop:
|
||||
- e2fsprogs
|
||||
- xfsprogs
|
||||
|
||||
- name: "Install btrfs progs"
|
||||
ansible.builtin.package:
|
||||
name: btrfs-progs
|
||||
state: present
|
||||
when:
|
||||
- ansible_os_family != 'Suse'
|
||||
- not (ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('16.04', '<='))
|
||||
- ansible_system != "FreeBSD"
|
||||
- not (ansible_facts.os_family == "RedHat" and ansible_facts.distribution_major_version is version('8', '>='))
|
||||
- ansible_os_family != 'Archlinux' # TODO
|
||||
|
||||
- name: "Install btrfs tools (Ubuntu <= 16.04)"
|
||||
ansible.builtin.package:
|
||||
name: btrfs-tools
|
||||
state: present
|
||||
when:
|
||||
- ansible_distribution == 'Ubuntu'
|
||||
- ansible_distribution_version is version('16.04', '<=')
|
||||
|
||||
- name: "Install btrfs progs (OpenSuse)"
|
||||
ansible.builtin.package:
|
||||
name:
|
||||
- python{{ ansible_python.version.major }}-xml
|
||||
- btrfsprogs
|
||||
state: present
|
||||
when: ansible_os_family == 'Suse'
|
||||
|
||||
- name: "Install reiserfs utils (Fedora)"
|
||||
ansible.builtin.package:
|
||||
name: reiserfs-utils
|
||||
state: present
|
||||
when:
|
||||
- ansible_distribution == 'Fedora' and (ansible_facts.distribution_major_version | int < 35)
|
||||
|
||||
- name: "Install reiserfs and util-linux-systemd (for findmnt) (OpenSuse)"
|
||||
ansible.builtin.package:
|
||||
name:
|
||||
- reiserfs
|
||||
- util-linux-systemd
|
||||
state: present
|
||||
when:
|
||||
- ansible_os_family == 'Suse'
|
||||
|
||||
- name: "Install reiserfs progs (Debian and more)"
|
||||
ansible.builtin.package:
|
||||
name: reiserfsprogs
|
||||
state: present
|
||||
when:
|
||||
- ansible_system == 'Linux'
|
||||
- ansible_os_family not in ['Suse', 'RedHat', 'Alpine']
|
||||
|
||||
- name: "Install reiserfs progs (FreeBSD)"
|
||||
ansible.builtin.package:
|
||||
name: progsreiserfs
|
||||
state: present
|
||||
when:
|
||||
- ansible_system == 'FreeBSD'
|
||||
|
||||
- name: "Install ocfs2 (Debian)"
|
||||
ansible.builtin.package:
|
||||
name: ocfs2-tools
|
||||
state: present
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
- name: "Install f2fs tools and get version"
|
||||
when:
|
||||
- ansible_os_family != 'RedHat' or ansible_distribution == 'Fedora'
|
||||
- ansible_distribution != 'Ubuntu' or ansible_distribution_version is version('16.04', '>=')
|
||||
- ansible_system != "FreeBSD"
|
||||
block:
|
||||
- name: "Install f2fs tools"
|
||||
ansible.builtin.package:
|
||||
name: f2fs-tools
|
||||
state: present
|
||||
|
||||
- name: "Fetch f2fs version"
|
||||
ansible.builtin.command:
|
||||
cmd: mkfs.f2fs /dev/null
|
||||
changed_when: false
|
||||
ignore_errors: true
|
||||
register: mkfs_f2fs
|
||||
|
||||
- name: "Record f2fs_version"
|
||||
ansible.builtin.set_fact:
|
||||
f2fs_version: '{{ mkfs_f2fs.stdout
|
||||
| regex_search("F2FS-tools: mkfs.f2fs Ver:.*")
|
||||
| regex_replace("F2FS-tools: mkfs.f2fs Ver: ([0-9.]+) .*", "\1") }}'
|
||||
|
||||
- name: "Install dosfstools and lvm2 (Linux)"
|
||||
ansible.builtin.package:
|
||||
name:
|
||||
- dosfstools
|
||||
- lvm2
|
||||
when: ansible_system == 'Linux'
|
||||
|
||||
- name: "Install fatresize and get version"
|
||||
when:
|
||||
- ansible_system == 'Linux'
|
||||
- ansible_os_family != 'Suse'
|
||||
- ansible_os_family != 'RedHat' or (ansible_distribution == 'CentOS' and ansible_distribution_version is version('7.0', '=='))
|
||||
- ansible_os_family != 'Alpine'
|
||||
block:
|
||||
- name: "Install fatresize"
|
||||
ansible.builtin.package:
|
||||
name: fatresize
|
||||
state: present
|
||||
|
||||
- name: "Fetch fatresize version"
|
||||
ansible.builtin.command:
|
||||
cmd: fatresize --help
|
||||
changed_when: false
|
||||
register: fatresize
|
||||
|
||||
- name: "Record fatresize_version"
|
||||
ansible.builtin.set_fact:
|
||||
fatresize_version: '{{ fatresize.stdout_lines[0] | regex_search("[0-9]+\.[0-9]+\.[0-9]+") }}'
|
||||
|
||||
- name: "Fetch e2fsprogs version"
|
||||
ansible.builtin.command:
|
||||
cmd: mke2fs -V
|
||||
changed_when: false
|
||||
register: mke2fs
|
||||
|
||||
- name: "Record e2fsprogs_version"
|
||||
ansible.builtin.set_fact:
|
||||
# mke2fs 1.43.6 (29-Aug-2017)
|
||||
e2fsprogs_version: '{{ mke2fs.stderr_lines[0] | regex_search("[0-9]{1,2}\.[0-9]{1,2}(\.[0-9]{1,2})?") }}'
|
||||
|
||||
- name: "Set version-related facts to skip further tasks"
|
||||
ansible.builtin.set_fact:
|
||||
# http://e2fsprogs.sourceforge.net/e2fsprogs-release.html#1.43
|
||||
# Mke2fs no longer complains if the user tries to create a file system
|
||||
# using the entire block device.
|
||||
force_creation: "{{ e2fsprogs_version is version('1.43', '<') }}"
|
||||
# Earlier versions have a segfault bug
|
||||
resize_vfat: "{{ fatresize_version|default('0.0') is version('1.0.4', '>=') }}"
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
ocfs2_fssize: 108
|
||||
f2fs_fssize: 116
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
ocfs2_fssize: 20
|
||||
Reference in New Issue
Block a user