Add linux module parameters for the modprobe module

This commit is contained in:
Julien DAUPHANT 2014-03-05 16:42:52 +01:00
parent b5e487f2d9
commit daa7416323

View file

@ -34,11 +34,18 @@ options:
choices: [ present, absent ] choices: [ present, absent ]
description: description:
- Whether the module should be present or absent. - Whether the module should be present or absent.
params:
required: false
default: ""
description:
- Modules parameters.
''' '''
EXAMPLES = ''' EXAMPLES = '''
# Add the 802.1q module # Add the 802.1q module
- modprobe: name=8021q state=present - modprobe: name=8021q state=present
# Add the dummy module
- modprobe: name=dummy state=present params="numdummies=2"
''' '''
def main(): def main():
@ -46,6 +53,7 @@ def main():
argument_spec={ argument_spec={
'name': {'required': True}, 'name': {'required': True},
'state': {'default': 'present', 'choices': ['present', 'absent']}, 'state': {'default': 'present', 'choices': ['present', 'absent']},
'params': {'default': ''},
}, },
supports_check_mode=True, supports_check_mode=True,
) )
@ -54,6 +62,7 @@ def main():
'failed': False, 'failed': False,
'name': module.params['name'], 'name': module.params['name'],
'state': module.params['state'], 'state': module.params['state'],
'params': module.params['params'],
} }
# Check if module is present # Check if module is present
@ -81,7 +90,7 @@ def main():
# Add/remove module as needed # Add/remove module as needed
if args['state'] == 'present': if args['state'] == 'present':
if not present: if not present:
rc, _, err = module.run_command(['modprobe', args['name']]) rc, _, err = module.run_command(['modprobe', args['name'], args['params']])
if rc != 0: if rc != 0:
module.fail_json(msg=err, **args) module.fail_json(msg=err, **args)
args['changed'] = True args['changed'] = True