Example #1
0
def main():
    argument_spec = ingate_argument_spec()
    module = AnsibleModule(argument_spec=argument_spec,
                           supports_check_mode=False)

    is_ingatesdk_installed(module)

    result = dict(changed=False)
    try:
        response = make_request(module)
        result.update(response[0])
    except ingatesdk.SdkError as e:
        module.fail_json(msg=to_native(e))
    module.exit_json(**result)
Example #2
0
def main():
    argument_spec = ingate_argument_spec(
        add=dict(type='bool'),
        delete=dict(type='bool'),
        get=dict(type='bool'),
        modify=dict(type='bool'),
        revert=dict(type='bool'),
        factory=dict(type='bool'),
        store=dict(type='bool'),
        no_response=dict(type='bool', default=False),
        return_rowid=dict(type='bool'),
        download=dict(type='bool'),
        store_download=dict(type='bool', default=False),
        path=dict(),
        filename=dict(),
        table=dict(),
        rowid=dict(type='int'),
        columns=dict(type='dict'),
    )

    mutually_exclusive = [('add', 'delete', 'get', 'modify', 'revert',
                           'factory', 'store', 'return_rowid', 'download')]
    required_one_of = [[
        'add', 'delete', 'get', 'modify', 'revert', 'factory', 'store',
        'return_rowid', 'download'
    ]]
    required_if = [('add', True, ['table', 'columns']),
                   ('delete', True, ['table']), ('get', True, ['table']),
                   ('modify', True, ['table', 'columns']),
                   ('return_rowid', True, ['table', 'columns'])]

    module = AnsibleModule(argument_spec=argument_spec,
                           mutually_exclusive=mutually_exclusive,
                           required_if=required_if,
                           required_one_of=required_one_of,
                           supports_check_mode=False)
    if not HAS_INGATESDK:
        module.fail_json(msg='The Ingate Python SDK module is required')

    result = dict(changed=False)
    try:
        changed, command, response = make_request(module)
        if response and command:
            result[command] = response
        result['changed'] = changed
    except ingatesdk.SdkError as e:
        module.fail_json(msg=str(e))
    module.exit_json(**result)