From 73b6b98ed9703b56188717c9d42de9ca6f4d482e Mon Sep 17 00:00:00 2001 From: Mike Date: Sun, 17 Mar 2024 17:29:15 +0100 Subject: [PATCH] Aix filesystem crfs issue (#8052) * crfs issue in aix_filesystem.py Change the crfs logic and fields, since empty options and order seem to be an issue. this quick fix seems to solve it * Create aix_filesystem-crfs-issue.yml changelog fragment * fix fix typo * Update changelogs/fragments/aix_filesystem-crfs-issue.yml Co-authored-by: Felix Fontein * Refactored based on feeback and testing Refactored the changes i did based on the comments and testing. Also changed the attribute default values because they were causing errors * blank line whitespaces * fix default --------- Co-authored-by: Felix Fontein --- .../fragments/aix_filesystem-crfs-issue.yml | 3 ++ plugins/modules/aix_filesystem.py | 54 +++++++++++++++++-- 2 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/aix_filesystem-crfs-issue.yml diff --git a/changelogs/fragments/aix_filesystem-crfs-issue.yml b/changelogs/fragments/aix_filesystem-crfs-issue.yml new file mode 100644 index 0000000000..6b3ddfb0d6 --- /dev/null +++ b/changelogs/fragments/aix_filesystem-crfs-issue.yml @@ -0,0 +1,3 @@ +--- +bugfixes: + - aix_filesystem - fix issue with empty list items in crfs logic and option order (https://github.com/ansible-collections/community.general/pull/8052). diff --git a/plugins/modules/aix_filesystem.py b/plugins/modules/aix_filesystem.py index d0d6ccb444..6abf6317f2 100644 --- a/plugins/modules/aix_filesystem.py +++ b/plugins/modules/aix_filesystem.py @@ -38,8 +38,8 @@ options: type: list elements: str default: - - agblksize='4096' - - isnapshot='no' + - agblksize=4096 + - isnapshot=no auto_mount: description: - File system is automatically mounted at system restart. @@ -365,7 +365,53 @@ def create_fs( # Creates a LVM file system. crfs_cmd = module.get_bin_path('crfs', True) if not module.check_mode: - cmd = [crfs_cmd, "-v", fs_type, "-m", filesystem, vg, device, mount_group, auto_mount, account_subsystem, "-p", permissions, size, "-a", attributes] + cmd = [crfs_cmd] + + cmd.append("-v") + cmd.append(fs_type) + + if vg: + (flag, value) = vg.split() + cmd.append(flag) + cmd.append(value) + + if device: + (flag, value) = device.split() + cmd.append(flag) + cmd.append(value) + + cmd.append("-m") + cmd.append(filesystem) + + if mount_group: + (flag, value) = mount_group.split() + cmd.append(flag) + cmd.append(value) + + if auto_mount: + (flag, value) = auto_mount.split() + cmd.append(flag) + cmd.append(value) + + if account_subsystem: + (flag, value) = account_subsystem.split() + cmd.append(flag) + cmd.append(value) + + cmd.append("-p") + cmd.append(permissions) + + if size: + (flag, value) = size.split() + cmd.append(flag) + cmd.append(value) + + if attributes: + splitted_attributes = attributes.split() + cmd.append("-a") + for value in splitted_attributes: + cmd.append(value) + rc, crfs_out, err = module.run_command(cmd) if rc == 10: @@ -461,7 +507,7 @@ def main(): module = AnsibleModule( argument_spec=dict( account_subsystem=dict(type='bool', default=False), - attributes=dict(type='list', elements='str', default=["agblksize='4096'", "isnapshot='no'"]), + attributes=dict(type='list', elements='str', default=["agblksize=4096", "isnapshot=no"]), auto_mount=dict(type='bool', default=True), device=dict(type='str'), filesystem=dict(type='str', required=True),