From 9d771f6eeaf74d2b3fe866e35cc56b02598e5d01 Mon Sep 17 00:00:00 2001 From: Pilou Date: Wed, 26 Jul 2017 14:47:12 +0200 Subject: [PATCH] filesystem: workaround bug in xfs_info, use xfs_growfs instead (#25703) xfs_info is a bash script located in /usr/sbin/ (/sbin is a symlink to /usr/sbin/) which calls xfs_growfs command. When neither /sbin nor /usr/sbin are in the PATH environment variable, filesystem module is able to call xfs_info because /sbin path is hardcoded in get_bin_path method, then xfs_growfs isn't found because neither /sbin nor /usr/sbin are in the PATH environment variable. "xfs_growfs -n" could be used directly instead of xfs_info, the man page states that: "xfs_info is equivalent to invoking xfs_growfs with the -n option". Fixes #24823. --- lib/ansible/modules/system/filesystem.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/ansible/modules/system/filesystem.py b/lib/ansible/modules/system/filesystem.py index 79816a1b9d..5fec91707a 100644 --- a/lib/ansible/modules/system/filesystem.py +++ b/lib/ansible/modules/system/filesystem.py @@ -96,17 +96,17 @@ def _get_fs_size(fssize_cmd, dev, module): break else: module.fail_json(msg="Failed to get block count and block size of %s with %s" % (dev, cmd), rc=rc, err=err ) - elif 'xfs_info' == fssize_cmd: + elif 'xfs_growfs' == fssize_cmd: # Get Block count and Block size - rc, size, err = module.run_command("%s %s" % (cmd, dev)) + rc, size, err = module.run_command([cmd, '-n', dev]) if rc == 0: for line in size.splitlines(): col = line.split('=') if col[0].strip() == 'data': if col[1].strip() != 'bsize': - module.fail_json(msg='Unexpected output format from xfs_info (could not locate "bsize")') + module.fail_json(msg='Unexpected output format from xfs_growfs (could not locate "bsize")') if col[2].split()[1] != 'blocks': - module.fail_json(msg='Unexpected output format from xfs_info (could not locate "blocks")') + module.fail_json(msg='Unexpected output format from xfs_growfs (could not locate "blocks")') block_size = int(col[2].split()[0]) block_count = int(col[3].split(',')[0]) break @@ -176,7 +176,7 @@ def main(): 'grow' : 'xfs_growfs', 'grow_flag' : None, 'force_flag' : '-f', - 'fsinfo': 'xfs_info', + 'fsinfo': 'xfs_growfs', }, 'btrfs' : { 'mkfs' : 'mkfs.btrfs',