From 57c67f0c0826dfd4df244252e5d289b34c7c0721 Mon Sep 17 00:00:00 2001 From: Colin Nolan Date: Wed, 12 Apr 2017 10:42:03 +0100 Subject: [PATCH] Add checks to confirm that the output from `xfs_info` has the expected format. --- lib/ansible/modules/system/filesystem.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/ansible/modules/system/filesystem.py b/lib/ansible/modules/system/filesystem.py index 5ae9935914..79816a1b9d 100644 --- a/lib/ansible/modules/system/filesystem.py +++ b/lib/ansible/modules/system/filesystem.py @@ -103,6 +103,10 @@ def _get_fs_size(fssize_cmd, dev, module): 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")') + if col[2].split()[1] != 'blocks': + module.fail_json(msg='Unexpected output format from xfs_info (could not locate "blocks")') block_size = int(col[2].split()[0]) block_count = int(col[3].split(',')[0]) break