Example #1
0
def main():
    """main entry point for module execution"""
    argument_spec = dict(
        dest=dict(choices=DEST_GROUP),
        name=dict(),
        facility=dict(),
        remote_server=dict(),
        use_vrf=dict(),
        dest_level=dict(type="int", aliases=["level"]),
        facility_level=dict(type="int"),
        interface=dict(),
        facility_link_status=dict(choices=[
            "link-down-notif",
            "link-down-error",
            "link-up-notif",
            "link-up-error",
        ], ),
        event=dict(choices=[
            "link-enable",
            "link-default",
            "trunk-enable",
            "trunk-default",
        ], ),
        interface_message=dict(choices=["add-interface-description"]),
        file_size=dict(type="int"),
        timestamp=dict(choices=["microseconds", "milliseconds", "seconds"]),
        state=dict(default="present", choices=["present", "absent"]),
        aggregate=dict(type="list", elements="dict"),
        purge=dict(default=False, type="bool"),
    )

    argument_spec.update(nxos_argument_spec)

    required_if = [
        ("dest", "logfile", ["name"]),
        ("dest", "server", ["remote_server"]),
    ]

    module = AnsibleModule(
        argument_spec=argument_spec,
        required_if=required_if,
        supports_check_mode=True,
    )

    warnings = list()

    result = {"changed": False}
    if warnings:
        result["warnings"] = warnings

    want = map_params_to_obj(module)
    merged_wants = merge_wants(read_module_context(module), want)
    have = map_config_to_obj(module)

    commands = map_obj_to_commands(module, (want, have))
    result["commands"] = commands

    if commands:
        if not module.check_mode:
            load_config(module, commands)
        result["changed"] = True

    save_module_context(module, merged_wants)

    if module.params.get("purge"):
        pcommands = map_obj_to_commands(module,
                                        (outliers(have, merged_wants), have))
        if pcommands:
            if not module.check_mode:
                load_config(module, pcommands)
            result["changed"] = True
        result["commands"] += pcommands

    module.exit_json(**result)
Example #2
0
def main():
    """ main entry point for module execution
    """
    argument_spec = dict(
        dest=dict(choices=DEST_GROUP),
        name=dict(),
        facility=dict(),
        remote_server=dict(),
        use_vrf=dict(),
        dest_level=dict(type='int', aliases=['level']),
        facility_level=dict(type='int'),
        interface=dict(),
        facility_link_status=dict(choices=[
            'link-down-notif', 'link-down-error', 'link-up-notif',
            'link-up-error'
        ]),
        event=dict(choices=[
            'link-enable', 'link-default', 'trunk-enable', 'trunk-default'
        ]),
        interface_message=dict(choices=['add-interface-description']),
        file_size=dict(type='int'),
        timestamp=dict(choices=['microseconds', 'milliseconds', 'seconds']),
        state=dict(default='present', choices=['present', 'absent']),
        aggregate=dict(type='list'),
        purge=dict(default=False, type='bool'),
    )

    argument_spec.update(nxos_argument_spec)

    required_if = [('dest', 'logfile', ['name']),
                   ('dest', 'server', ['remote_server'])]

    module = AnsibleModule(argument_spec=argument_spec,
                           required_if=required_if,
                           supports_check_mode=True)

    warnings = list()

    result = {'changed': False}
    if warnings:
        result['warnings'] = warnings

    want = map_params_to_obj(module)
    merged_wants = merge_wants(read_module_context(module), want)
    have = map_config_to_obj(module)

    commands = map_obj_to_commands(module, (want, have))
    result['commands'] = commands

    if commands:
        if not module.check_mode:
            load_config(module, commands)
        result['changed'] = True

    save_module_context(module, merged_wants)

    if module.params.get('purge'):
        pcommands = map_obj_to_commands(module,
                                        (outliers(have, merged_wants), have))
        if pcommands:
            if not module.check_mode:
                load_config(module, pcommands)
            result['changed'] = True
        result['commands'] += pcommands

    module.exit_json(**result)