Skip to content

Instantly share code, notes, and snippets.

@juliedavila
Last active August 29, 2015 14:22
Show Gist options
  • Save juliedavila/21879d69ecfd7a5f902b to your computer and use it in GitHub Desktop.
Save juliedavila/21879d69ecfd7a5f902b to your computer and use it in GitHub Desktop.
BMS Module
#!/usr/bin/python
import os
from stat import *
def exec_bms_action(module, bms_home, bms_options, overrides, bms_module, command, command_opts):
cmd_str = '%s bms' % bms_home
cmd = [cmd_str]
if bms_options:
cmd.extend([bms_options])
if overrides:
cmd.extend([overrides])
if bms_module:
cmd.extend([bms_module])
cmd.extend([command])
if command_opts:
cmd.extend([command_opts])
return module.run_command(cmd, check_rc=True)
def main():
module = AnsibleModule(
argument_spec = dict(
bms_home=dict(required=True, type='str'),
bms_options=dict(required=False, type='str'),
overrides=dict(required=False, type='str'),
bms_module=dict(required=False, type='str'),
command=dict(required=True, type='str'),
command_opts=dict(required=False, type='str')
)
)
bms_home = module.params['bms_home']
bms_options = module.params['bms_options']
overrides = module.params['overrides']
bms_module = module.params['bms_module']
command = module.params['command']
command_opts = module.params['command_opts']
rc, stdout, stderr = exec_bms_action(module, bms_home, bms_options, overrides, bms_module, command, command_opts)
module.exit_json(changed=True, rc=rc, stdout=stdout, stderr=stderr)
# import module snippets
from ansible.module_utils.basic import *
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment