1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/tests/integration/targets/filesystem/tasks/reset_fs_uuid.yml
Laszlo Szomor 5d9eb8be95
filesystem: add UUID change feature (#6680)
* filesystem: add UUID change feature

* Add changelog fragment for 6680

* Do not test XFS filesystem UUID reset on FreeBSD

FreeBSD error: xfs_admin: only 'rewrite' supported on V5 fs

* Apply suggestions from code review #1

Co-authored-by: Felix Fontein <felix@fontein.de>

* Set filesystem UUID on FS creation

* Fix tests - switch to ansible.builtion.to_uuid

* Fix tests - Refactor to avoid FS remove tasks

* Fail if uuid option not yet supported for fstype

* Set resizefs and uuid options mutually exclusive

* Apply suggestions from code review no 2.

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
2023-06-19 08:59:34 +02:00

59 lines
1.8 KiB
YAML

---
# 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
# Skip UUID reset tests for FreeBSD due to "xfs_admin: only 'rewrite' supported on V5 fs"
- when:
- new_uuid | default(False)
- not (ansible_system == "FreeBSD" and fstype == "xfs")
block:
- name: "Create filesystem ({{ fstype }})"
community.general.filesystem:
dev: '{{ dev }}'
fstype: '{{ fstype }}'
register: fs_result
- name: "Get UUID of created filesystem"
ansible.builtin.shell:
cmd: "{{ get_uuid_cmd }}"
changed_when: false
register: uuid
- name: "Reset filesystem ({{ fstype }}) UUID"
community.general.filesystem:
dev: '{{ dev }}'
fstype: '{{ fstype }}'
uuid: "{{ new_uuid }}"
register: fs_resetuuid_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 changed"
ansible.builtin.assert:
that:
- 'fs_resetuuid_result is changed'
- 'fs_resetuuid_result is success'
- 'uuid.stdout != uuid2.stdout'
- 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: "Reset filesystem ({{ fstype }}) UUID and resizefs"
ignore_errors: true
community.general.filesystem:
dev: '{{ dev }}'
fstype: '{{ fstype }}'
uuid: "{{ new_uuid }}"
resizefs: true
register: fs_resetuuid_and_resizefs_result
- name: "Assert that filesystem UUID reset and resizefs failed"
ansible.builtin.assert:
that: fs_resetuuid_and_resizefs_result is failed