mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-11 08:34:21 -07:00
[PR #6680/5d9eb8be backport][stable-7] filesystem: add UUID change feature (#6731)
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>
(cherry picked from commit 5d9eb8be95
)
Co-authored-by: Laszlo Szomor <laszomor@gmail.com>
This commit is contained in:
parent
920046beaf
commit
5d29270e23
7 changed files with 249 additions and 22 deletions
59
tests/integration/targets/filesystem/tasks/reset_fs_uuid.yml
Normal file
59
tests/integration/targets/filesystem/tasks/reset_fs_uuid.yml
Normal file
|
@ -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
|
||||
|
||||
# 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
|
Loading…
Add table
Add a link
Reference in a new issue