2021-04-19 07:04:29 +02:00
|
|
|
|
---
|
2022-08-05 14:03:38 +02:00
|
|
|
|
# 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
|
|
|
|
|
|
2021-04-19 07:04:29 +02:00
|
|
|
|
# Test module with sparse files
|
|
|
|
|
|
|
|
|
|
- name: Create a huge sparse file of 4TB (check mode)
|
|
|
|
|
community.general.filesize:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
|
|
|
|
size: 4TB
|
2023-02-16 06:42:27 +01:00
|
|
|
|
sparse: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_test_sparse_01
|
2023-02-16 06:42:27 +01:00
|
|
|
|
check_mode: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
|
|
|
|
|
- name: Stat the file (should not exist)
|
|
|
|
|
ansible.builtin.stat:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
2023-02-16 06:42:27 +01:00
|
|
|
|
get_checksum: false
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_stat_sparse_01
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Create a huge sparse file of 4TB
|
|
|
|
|
community.general.filesize:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
|
|
|
|
size: 4TB
|
2023-02-16 06:42:27 +01:00
|
|
|
|
sparse: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_test_sparse_02
|
|
|
|
|
|
|
|
|
|
- name: Stat the resulting file (should exist now)
|
|
|
|
|
ansible.builtin.stat:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
2023-02-16 06:42:27 +01:00
|
|
|
|
get_checksum: false
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_stat_sparse_02
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Create a huge sparse file of 4TB (4000GB) (check mode, idempotency)
|
|
|
|
|
community.general.filesize:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
|
|
|
|
size: 4000GB
|
2023-02-16 06:42:27 +01:00
|
|
|
|
sparse: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_test_sparse_03
|
2023-02-16 06:42:27 +01:00
|
|
|
|
check_mode: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
|
|
|
|
|
- name: Create a huge sparse file of 4TB (4000GB) (idempotency)
|
|
|
|
|
community.general.filesize:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
|
|
|
|
size: 4000GB
|
2023-02-16 06:42:27 +01:00
|
|
|
|
sparse: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_test_sparse_04
|
|
|
|
|
|
|
|
|
|
- name: Create a huge sparse file of 4TB (4000000 × 1MB) (check mode, idempotency)
|
|
|
|
|
community.general.filesize:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
|
|
|
|
size: 4000000
|
|
|
|
|
blocksize: 1MB
|
2023-02-16 06:42:27 +01:00
|
|
|
|
sparse: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_test_sparse_05
|
2023-02-16 06:42:27 +01:00
|
|
|
|
check_mode: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
|
|
|
|
|
- name: Create a huge sparse file of 4TB (4000000 × 1MB) (idempotency)
|
|
|
|
|
community.general.filesize:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
|
|
|
|
size: 4000000
|
|
|
|
|
blocksize: 1MB
|
2023-02-16 06:42:27 +01:00
|
|
|
|
sparse: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_test_sparse_06
|
|
|
|
|
|
|
|
|
|
- name: Stat the file again (should remain the same)
|
|
|
|
|
ansible.builtin.stat:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
2023-02-16 06:42:27 +01:00
|
|
|
|
get_checksum: false
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_stat_sparse_06
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Assert that results are as expected
|
|
|
|
|
ansible.builtin.assert:
|
|
|
|
|
that:
|
|
|
|
|
- filesize_test_sparse_01 is changed
|
|
|
|
|
- filesize_test_sparse_02 is changed
|
|
|
|
|
- filesize_test_sparse_03 is not changed
|
|
|
|
|
- filesize_test_sparse_04 is not changed
|
|
|
|
|
- filesize_test_sparse_05 is not changed
|
|
|
|
|
- filesize_test_sparse_06 is not changed
|
|
|
|
|
|
|
|
|
|
- filesize_test_sparse_02.cmd == filesize_test_sparse_01.cmd
|
|
|
|
|
- filesize_test_sparse_03.cmd is undefined
|
|
|
|
|
- filesize_test_sparse_04.cmd is undefined
|
|
|
|
|
- filesize_test_sparse_05.cmd is undefined
|
|
|
|
|
- filesize_test_sparse_06.cmd is undefined
|
|
|
|
|
|
|
|
|
|
- filesize_test_sparse_01.filesize.bytes == 4*1000**4
|
|
|
|
|
- filesize_test_sparse_02.filesize.bytes == 4*1000**4
|
|
|
|
|
- filesize_test_sparse_03.filesize.bytes == 4*1000**4
|
|
|
|
|
- filesize_test_sparse_04.filesize.bytes == 4*1000**4
|
|
|
|
|
- filesize_test_sparse_05.filesize.bytes == 4*1000**4
|
|
|
|
|
- filesize_test_sparse_06.filesize.bytes == 4*1000**4
|
|
|
|
|
|
|
|
|
|
- filesize_test_sparse_01.size_diff == 4*1000**4
|
|
|
|
|
- filesize_test_sparse_02.size_diff == 4*1000**4
|
|
|
|
|
- filesize_test_sparse_03.size_diff == 0
|
|
|
|
|
- filesize_test_sparse_04.size_diff == 0
|
|
|
|
|
- filesize_test_sparse_05.size_diff == 0
|
|
|
|
|
- filesize_test_sparse_06.size_diff == 0
|
|
|
|
|
|
|
|
|
|
- filesize_test_sparse_01.state is undefined
|
|
|
|
|
- filesize_test_sparse_02.state in ["file"]
|
|
|
|
|
- filesize_test_sparse_01.size is undefined
|
|
|
|
|
- filesize_test_sparse_02.size == 4*1000**4
|
|
|
|
|
- filesize_test_sparse_03.size == 4*1000**4
|
|
|
|
|
- filesize_test_sparse_04.size == 4*1000**4
|
|
|
|
|
- filesize_test_sparse_05.size == 4*1000**4
|
|
|
|
|
- filesize_test_sparse_06.size == 4*1000**4
|
|
|
|
|
|
|
|
|
|
- not filesize_stat_sparse_01.stat.exists
|
|
|
|
|
- filesize_stat_sparse_02.stat.exists
|
|
|
|
|
- filesize_stat_sparse_02.stat.isreg
|
|
|
|
|
- filesize_stat_sparse_02.stat.size == 4*1000**4
|
|
|
|
|
- filesize_stat_sparse_06.stat.size == 4*1000**4
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Change sparse file size to 4TiB (check mode)
|
|
|
|
|
community.general.filesize:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
|
|
|
|
size: 4TiB
|
2023-02-16 06:42:27 +01:00
|
|
|
|
sparse: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_test_sparse_11
|
2023-02-16 06:42:27 +01:00
|
|
|
|
check_mode: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
|
|
|
|
|
- name: Stat the file again (should remain the same)
|
|
|
|
|
ansible.builtin.stat:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
2023-02-16 06:42:27 +01:00
|
|
|
|
get_checksum: false
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_stat_sparse_11
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Change sparse file size to 4TiB
|
|
|
|
|
community.general.filesize:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
|
|
|
|
size: 4TiB
|
2023-02-16 06:42:27 +01:00
|
|
|
|
sparse: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_test_sparse_12
|
|
|
|
|
|
|
|
|
|
- name: Stat the file again (should have grown)
|
|
|
|
|
ansible.builtin.stat:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
2023-02-16 06:42:27 +01:00
|
|
|
|
get_checksum: false
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_stat_sparse_12
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Change sparse file size to 4TiB (4096GiB) (check mode, idempotency)
|
|
|
|
|
community.general.filesize:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
|
|
|
|
size: 4096GiB
|
2023-02-16 06:42:27 +01:00
|
|
|
|
sparse: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_test_sparse_13
|
2023-02-16 06:42:27 +01:00
|
|
|
|
check_mode: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
|
|
|
|
|
- name: Change sparse file size to 4TiB (4096GiB) (idempotency)
|
|
|
|
|
community.general.filesize:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
|
|
|
|
size: 4096GiB
|
2023-02-16 06:42:27 +01:00
|
|
|
|
sparse: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_test_sparse_14
|
|
|
|
|
|
|
|
|
|
- name: Stat the file again (should remain the same)
|
|
|
|
|
ansible.builtin.stat:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
2023-02-16 06:42:27 +01:00
|
|
|
|
get_checksum: false
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_stat_sparse_14
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Assert that results are as expected
|
|
|
|
|
ansible.builtin.assert:
|
|
|
|
|
that:
|
|
|
|
|
- filesize_test_sparse_11 is changed
|
|
|
|
|
- filesize_test_sparse_12 is changed
|
|
|
|
|
- filesize_test_sparse_13 is not changed
|
|
|
|
|
- filesize_test_sparse_14 is not changed
|
|
|
|
|
|
|
|
|
|
- filesize_test_sparse_12.cmd == filesize_test_sparse_11.cmd
|
|
|
|
|
- filesize_test_sparse_13.cmd is undefined
|
|
|
|
|
- filesize_test_sparse_14.cmd is undefined
|
|
|
|
|
|
|
|
|
|
- filesize_test_sparse_11.size_diff == 398046511104
|
|
|
|
|
- filesize_test_sparse_12.size_diff == 398046511104
|
|
|
|
|
- filesize_test_sparse_13.size_diff == 0
|
|
|
|
|
- filesize_test_sparse_14.size_diff == 0
|
|
|
|
|
|
|
|
|
|
- filesize_test_sparse_11.size == 4000000000000
|
|
|
|
|
- filesize_test_sparse_12.size == 4398046511104
|
|
|
|
|
- filesize_test_sparse_13.size == 4398046511104
|
|
|
|
|
- filesize_test_sparse_14.size == 4398046511104
|
|
|
|
|
|
|
|
|
|
- filesize_stat_sparse_11.stat.size == 4000000000000
|
|
|
|
|
- filesize_stat_sparse_12.stat.size == 4398046511104
|
|
|
|
|
- filesize_stat_sparse_14.stat.size == 4398046511104
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Change sparse file size to 4.321TB (check mode)
|
|
|
|
|
community.general.filesize:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
|
|
|
|
size: 4.321TB
|
2023-02-16 06:42:27 +01:00
|
|
|
|
sparse: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_test_sparse_21
|
2023-02-16 06:42:27 +01:00
|
|
|
|
check_mode: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
|
|
|
|
|
- name: Stat the file again (should remain the same)
|
|
|
|
|
ansible.builtin.stat:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
2023-02-16 06:42:27 +01:00
|
|
|
|
get_checksum: false
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_stat_sparse_21
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Change sparse file size to 4.321TB
|
|
|
|
|
community.general.filesize:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
|
|
|
|
size: 4.321TB
|
2023-02-16 06:42:27 +01:00
|
|
|
|
sparse: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_test_sparse_22
|
|
|
|
|
|
|
|
|
|
- name: Stat the file again (should have been reduced)
|
|
|
|
|
ansible.builtin.stat:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
2023-02-16 06:42:27 +01:00
|
|
|
|
get_checksum: false
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_stat_sparse_22
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Change sparse file size to 4321×1GB (check mode, idempotency)
|
|
|
|
|
community.general.filesize:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
|
|
|
|
size: 4321
|
|
|
|
|
blocksize: 1GB
|
2023-02-16 06:42:27 +01:00
|
|
|
|
sparse: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_test_sparse_23
|
2023-02-16 06:42:27 +01:00
|
|
|
|
check_mode: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
|
|
|
|
|
- name: Change sparse file size to 4321×1GB (idempotency)
|
|
|
|
|
community.general.filesize:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
|
|
|
|
size: 4321
|
|
|
|
|
blocksize: 1GB
|
2023-02-16 06:42:27 +01:00
|
|
|
|
sparse: true
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_test_sparse_24
|
|
|
|
|
|
|
|
|
|
- name: Stat the file again (should remain the same)
|
|
|
|
|
ansible.builtin.stat:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
2023-02-16 06:42:27 +01:00
|
|
|
|
get_checksum: false
|
2021-04-19 07:04:29 +02:00
|
|
|
|
register: filesize_stat_sparse_24
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Assert that results are as expected
|
|
|
|
|
ansible.builtin.assert:
|
|
|
|
|
that:
|
|
|
|
|
- filesize_test_sparse_21 is changed
|
|
|
|
|
- filesize_test_sparse_22 is changed
|
|
|
|
|
- filesize_test_sparse_23 is not changed
|
|
|
|
|
- filesize_test_sparse_24 is not changed
|
|
|
|
|
|
|
|
|
|
- filesize_test_sparse_22.cmd == filesize_test_sparse_21.cmd
|
|
|
|
|
- filesize_test_sparse_23.cmd is undefined
|
|
|
|
|
- filesize_test_sparse_24.cmd is undefined
|
|
|
|
|
|
|
|
|
|
- filesize_test_sparse_21.size_diff == 4321*1000**3 - 4*1024**4
|
|
|
|
|
- filesize_test_sparse_22.size_diff == 4321*1000**3 - 4*1024**4
|
|
|
|
|
- filesize_test_sparse_23.size_diff == 0
|
|
|
|
|
- filesize_test_sparse_24.size_diff == 0
|
|
|
|
|
|
|
|
|
|
- filesize_test_sparse_21.size == 4398046511104
|
|
|
|
|
- filesize_test_sparse_22.size == 4321000000000
|
|
|
|
|
- filesize_test_sparse_23.size == 4321000000000
|
|
|
|
|
- filesize_test_sparse_24.size == 4321000000000
|
|
|
|
|
|
|
|
|
|
- filesize_stat_sparse_21.stat.size == 4398046511104
|
|
|
|
|
- filesize_stat_sparse_22.stat.size == 4321000000000
|
|
|
|
|
- filesize_stat_sparse_24.stat.size == 4321000000000
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Remove test file
|
|
|
|
|
ansible.builtin.file:
|
|
|
|
|
path: "{{ filesize_testfile }}"
|
|
|
|
|
state: absent
|