mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 22:00:22 -07:00
Initial commit
This commit is contained in:
commit
aebc1b03fd
4861 changed files with 812621 additions and 0 deletions
4
tests/integration/targets/filesystem/aliases
Normal file
4
tests/integration/targets/filesystem/aliases
Normal file
|
@ -0,0 +1,4 @@
|
|||
destructive
|
||||
shippable/posix/group3
|
||||
skip/aix
|
||||
skip/osx
|
22
tests/integration/targets/filesystem/defaults/main.yml
Normal file
22
tests/integration/targets/filesystem/defaults/main.yml
Normal file
|
@ -0,0 +1,22 @@
|
|||
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: 20, grow: False} # grow requires a mounted filesystem
|
||||
btrfs: {fssize: 150, 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}
|
2
tests/integration/targets/filesystem/meta/main.yml
Normal file
2
tests/integration/targets/filesystem/meta/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
dependencies:
|
||||
- setup_remote_tmp_dir
|
32
tests/integration/targets/filesystem/tasks/create_device.yml
Normal file
32
tests/integration/targets/filesystem/tasks/create_device.yml
Normal file
|
@ -0,0 +1,32 @@
|
|||
- 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'
|
||||
|
||||
- name: 'Clean correct device for LVM'
|
||||
set_fact:
|
||||
dev: '{{ image_file }}'
|
||||
when: fstype == 'lvm'
|
||||
|
||||
- file:
|
||||
name: '{{ image_file }}'
|
||||
state: absent
|
82
tests/integration/targets/filesystem/tasks/create_fs.yml
Normal file
82
tests/integration/targets/filesystem/tasks/create_fs.yml
Normal file
|
@ -0,0 +1,82 @@
|
|||
- name: filesystem creation
|
||||
filesystem:
|
||||
dev: '{{ dev }}'
|
||||
fstype: '{{ fstype }}'
|
||||
register: fs_result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'fs_result is changed'
|
||||
- 'fs_result is success'
|
||||
|
||||
- command: 'blkid -c /dev/null -o value -s UUID {{ dev }}'
|
||||
register: uuid
|
||||
|
||||
- name: "Check that filesystem isn't created if force isn't used"
|
||||
filesystem:
|
||||
dev: '{{ dev }}'
|
||||
fstype: '{{ fstype }}'
|
||||
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=1 >> {{ image_file }}'
|
||||
|
||||
- when: fstype == 'lvm'
|
||||
block:
|
||||
- name: Resize loop device for LVM
|
||||
command: losetup -c {{ 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'
|
44
tests/integration/targets/filesystem/tasks/main.yml
Normal file
44
tests/integration/targets/filesystem/tasks/main.yml
Normal file
|
@ -0,0 +1,44 @@
|
|||
- debug:
|
||||
msg: '{{ role_name }}'
|
||||
- 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:
|
||||
- 'not (item.0.key == "btrfs" and ansible_system == "FreeBSD")' # btrfs not available on FreeBSD
|
||||
# On Ubuntu trusty, blkid is unable to identify filesystem smaller than 256Mo, see
|
||||
# https://www.kernel.org/pub/linux/utils/util-linux/v2.21/v2.21-ChangeLog
|
||||
# https://anonscm.debian.org/cgit/collab-maint/pkg-util-linux.git/commit/?id=04f7020eadf31efc731558df92daa0a1c336c46c
|
||||
- 'not (item.0.key == "btrfs" and (ansible_distribution == "Ubuntu" and ansible_distribution_release == "trusty"))'
|
||||
- 'not (item.0.key == "btrfs" and (ansible_facts.os_family == "RedHat" and ansible_facts.distribution_major_version is version("8", ">=")))'
|
||||
- 'not (item.0.key == "lvm" and ansible_system == "FreeBSD")' # LVM not available on FreeBSD
|
||||
- 'not (item.0.key == "lvm" and ansible_virtualization_type == "docker")' # Tests use losetup which can not be used inside unprivileged container
|
||||
- 'not (item.0.key == "ocfs2" and ansible_os_family != "Debian")' # ocfs2 only available on Debian based distributions
|
||||
- 'not (item.0.key == "f2fs" and ansible_system == "FreeBSD")'
|
||||
# f2fs-tools package not available with RHEL/CentOS
|
||||
- 'not (item.0.key == "f2fs" and ansible_distribution in ["CentOS", "RedHat"])'
|
||||
# On Ubuntu trusty, blkid (2.20.1) is unable to identify F2FS filesystem. blkid handles F2FS since v2.23, see:
|
||||
# https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v2.23/v2.23-ReleaseNotes
|
||||
- 'not (item.0.key == "f2fs" and ansible_distribution == "Ubuntu" and ansible_distribution_version is version("14.04", "<="))'
|
||||
- 'not (item.1 == "overwrite_another_fs" and ansible_system == "FreeBSD")'
|
||||
|
||||
# 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 (item.0.key == "xfs" and ansible_os_family == "Suse" and ansible_python.version.major == 2 and ansible_distribution_major_version|int != 42)'
|
||||
loop: "{{ query('dict', tested_filesystems)|product(['create_fs', 'overwrite_another_fs'])|list }}"
|
|
@ -0,0 +1,39 @@
|
|||
- name: 'Recreate "disk" file'
|
||||
command: 'dd if=/dev/zero of={{ image_file }} bs=1M count={{ fssize }}'
|
||||
|
||||
- name: 'Create a swap filesystem'
|
||||
command: 'mkswap {{ dev }}'
|
||||
|
||||
- command: 'blkid -c /dev/null -o value -s UUID {{ dev }}'
|
||||
register: uuid
|
||||
|
||||
- name: "Check that an existing filesystem (not handled by this module) isn't overwritten when force isn't used"
|
||||
filesystem:
|
||||
dev: '{{ dev }}'
|
||||
fstype: '{{ fstype }}'
|
||||
register: fs_result
|
||||
ignore_errors: True
|
||||
|
||||
- command: 'blkid -c /dev/null -o value -s UUID {{ dev }}'
|
||||
register: uuid2
|
||||
|
||||
- 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"
|
||||
filesystem:
|
||||
dev: '{{ dev }}'
|
||||
fstype: '{{ fstype }}'
|
||||
force: yes
|
||||
register: fs_result2
|
||||
|
||||
- command: 'blkid -c /dev/null -o value -s UUID {{ dev }}'
|
||||
register: uuid3
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'fs_result2 is successful'
|
||||
- 'fs_result2 is changed'
|
||||
- 'uuid2.stdout != uuid3.stdout'
|
96
tests/integration/targets/filesystem/tasks/setup.yml
Normal file
96
tests/integration/targets/filesystem/tasks/setup.yml
Normal file
|
@ -0,0 +1,96 @@
|
|||
- name: install filesystem tools
|
||||
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)
|
||||
with_items:
|
||||
- e2fsprogs
|
||||
- xfsprogs
|
||||
|
||||
- block:
|
||||
- name: install btrfs progs
|
||||
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', '>='))
|
||||
|
||||
- name: install btrfs progs (Ubuntu <= 16.04)
|
||||
package:
|
||||
name: btrfs-tools
|
||||
state: present
|
||||
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('16.04', '<=')
|
||||
|
||||
- name: install btrfs progs (OpenSuse)
|
||||
package:
|
||||
name: '{{ item }}'
|
||||
state: present
|
||||
when: ansible_os_family == 'Suse'
|
||||
with_items:
|
||||
- python{{ ansible_python.version.major }}-xml
|
||||
- btrfsprogs
|
||||
|
||||
- name: install ocfs2 (Debian)
|
||||
package:
|
||||
name: ocfs2-tools
|
||||
state: present
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
- 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
|
||||
package:
|
||||
name: f2fs-tools
|
||||
state: present
|
||||
|
||||
- name: fetch f2fs version
|
||||
command: mkfs.f2fs /dev/null
|
||||
ignore_errors: yes
|
||||
register: mkfs_f2fs
|
||||
|
||||
- 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)
|
||||
package:
|
||||
name: '{{ item }}'
|
||||
with_items:
|
||||
- dosfstools
|
||||
- lvm2
|
||||
when: ansible_system == 'Linux'
|
||||
|
||||
- block:
|
||||
- name: install fatresize
|
||||
package:
|
||||
name: fatresize
|
||||
state: present
|
||||
- command: fatresize --help
|
||||
register: fatresize
|
||||
- set_fact:
|
||||
fatresize_version: '{{ fatresize.stdout_lines[0] | regex_search("[0-9]+\.[0-9]+\.[0-9]+") }}'
|
||||
when:
|
||||
- ansible_system == 'Linux'
|
||||
- ansible_os_family != 'Suse'
|
||||
- ansible_os_family != 'RedHat' or (ansible_distribution == 'CentOS' and ansible_distribution_version is version('7.0', '=='))
|
||||
|
||||
- command: mke2fs -V
|
||||
register: mke2fs
|
||||
|
||||
- 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})?") }}'
|
||||
|
||||
- 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,3 @@
|
|||
---
|
||||
ocfs2_fssize: 108
|
||||
f2fs_fssize: 116
|
2
tests/integration/targets/filesystem/vars/default.yml
Normal file
2
tests/integration/targets/filesystem/vars/default.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
ocfs2_fssize: 20
|
Loading…
Add table
Add a link
Reference in a new issue