allow device to be list for multidev fs (#20655)
* allow device to be list for multidev fs fixes #20551 * reverted command to string
This commit is contained in:
parent
541a51ddf7
commit
91b363ea9e
1 changed files with 9 additions and 7 deletions
|
@ -38,7 +38,7 @@ options:
|
||||||
required: true
|
required: true
|
||||||
dev:
|
dev:
|
||||||
description:
|
description:
|
||||||
- Target block device.
|
- Target block device. Starting in 2.3 it can also take a list of devices for file systems that allow this.
|
||||||
required: true
|
required: true
|
||||||
force:
|
force:
|
||||||
choices: [ "yes", "no" ]
|
choices: [ "yes", "no" ]
|
||||||
|
@ -73,6 +73,9 @@ EXAMPLES = '''
|
||||||
opts: -cc
|
opts: -cc
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
import os
|
||||||
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
def _get_dev_size(dev, module):
|
def _get_dev_size(dev, module):
|
||||||
""" Return size in bytes of device. Returns int """
|
""" Return size in bytes of device. Returns int """
|
||||||
blockdev_cmd = module.get_bin_path("blockdev", required=True)
|
blockdev_cmd = module.get_bin_path("blockdev", required=True)
|
||||||
|
@ -121,7 +124,7 @@ def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
fstype=dict(required=True, aliases=['type']),
|
fstype=dict(required=True, aliases=['type']),
|
||||||
dev=dict(required=True, aliases=['device']),
|
dev=dict(required=True, aliases=['device'], type='list'),
|
||||||
opts=dict(),
|
opts=dict(),
|
||||||
force=dict(type='bool', default='no'),
|
force=dict(type='bool', default='no'),
|
||||||
resizefs=dict(type='bool', default='no'),
|
resizefs=dict(type='bool', default='no'),
|
||||||
|
@ -200,12 +203,13 @@ def main():
|
||||||
growcmd = fs_cmd_map[fstype]['grow']
|
growcmd = fs_cmd_map[fstype]['grow']
|
||||||
fssize_cmd = fs_cmd_map[fstype]['fsinfo']
|
fssize_cmd = fs_cmd_map[fstype]['fsinfo']
|
||||||
|
|
||||||
if not os.path.exists(dev):
|
for device in dev:
|
||||||
module.fail_json(msg="Device %s not found."%dev)
|
if not os.path.exists(device):
|
||||||
|
module.fail_json(msg="Device %s not found." % device)
|
||||||
|
|
||||||
cmd = module.get_bin_path('blkid', required=True)
|
cmd = module.get_bin_path('blkid', required=True)
|
||||||
|
|
||||||
rc,raw_fs,err = module.run_command("%s -c /dev/null -o value -s TYPE %s" % (cmd, dev))
|
rc,raw_fs,err = module.run_command("%s -c /dev/null -o value -s TYPE %s" % (cmd, ' '.join(dev)))
|
||||||
fs = raw_fs.strip()
|
fs = raw_fs.strip()
|
||||||
|
|
||||||
if fs == fstype and resizefs == False and not force:
|
if fs == fstype and resizefs == False and not force:
|
||||||
|
@ -259,7 +263,5 @@ def main():
|
||||||
|
|
||||||
module.exit_json(changed=changed)
|
module.exit_json(changed=changed)
|
||||||
|
|
||||||
# import module snippets
|
|
||||||
from ansible.module_utils.basic import *
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in a new issue