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.
pull/8002/head
Prune 11 years ago
parent 14cf3c4d2a
commit 42966c22da

@ -95,10 +95,17 @@ def main():
else: else:
mkfs = module.get_bin_path('mkfs', required=True) mkfs = module.get_bin_path('mkfs', required=True)
cmd = None cmd = None
if fstype in ['ext2', 'ext3', 'ext4', 'ext4dev']:
force_flag="-F"
elif fstype in ['btrfs']:
force_flag="-f"
else:
force_flag=""
if opts is None: if opts is None:
cmd = "%s -t %s '%s'" % (mkfs, fstype, dev) cmd = "%s -t %s %s '%s'" % (mkfs, fstype, force_flag, dev)
else: else:
cmd = "%s -t %s %s '%s'" % (mkfs, fstype, opts, dev) cmd = "%s -t %s %s %s '%s'" % (mkfs, fstype, force_flag, opts, dev)
rc,_,err = module.run_command(cmd) rc,_,err = module.run_command(cmd)
if rc == 0: if rc == 0:
changed = True changed = True

Loading…
Cancel
Save