From afb358af77ddc0e0e1cd5537b17f07ac498d5e5b Mon Sep 17 00:00:00 2001 From: Prune Date: Tue, 1 Jul 2014 15:09:39 +0200 Subject: [PATCH] added missing force flag on mkfs commandline even if the option ```force=yes``` is used in the playbook, it is not reflected in the mkfs command line. As force option is dependent of the fs type, a "if-then-else" case have been added. Also, some FS types does not have a force option. --- system/filesystem | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/system/filesystem b/system/filesystem index 46e798f6e81..064c0d0af86 100644 --- a/system/filesystem +++ b/system/filesystem @@ -95,10 +95,17 @@ def main(): else: mkfs = module.get_bin_path('mkfs', required=True) cmd = None - if opts is None: - cmd = "%s -t %s '%s'" % (mkfs, fstype, dev) + if fstype in ['ext2', 'ext3', 'ext4', 'ext4dev']: + force_flag="-F" + elif fstype in ['btrfs']: + force_flag="-f" else: - cmd = "%s -t %s %s '%s'" % (mkfs, fstype, opts, dev) + force_flag="" + + if opts is None: + cmd = "%s -t %s %s '%s'" % (mkfs, fstype, force_flag, dev) + else: + cmd = "%s -t %s %s %s '%s'" % (mkfs, fstype, force_flag, opts, dev) rc,_,err = module.run_command(cmd) if rc == 0: changed = True