예제 #1
0
def main():
    """
    Main entry point for module execution
    """
    argument_spec = NETBOX_ARG_SPEC
    argument_spec.update(
        dict(data=dict(
            type="dict",
            required=True,
            options=dict(
                manufacturer=dict(required=False, type="raw"),
                model=dict(required=False, type="raw"),
                slug=dict(required=True, type="str"),
                part_number=dict(required=False, type="str"),
                u_height=dict(required=False, type="int"),
                is_full_depth=dict(required=False, type="bool"),
                subdevice_role=dict(
                    required=False,
                    choices=["Parent", "parent", "Child", "child"]),
                comments=dict(required=False, type="str"),
                tags=dict(required=False, type=list),
                custom_fields=dict(required=False, type=dict),
            ),
        ), ))

    required_if = [("state", "present", ["slug"]),
                   ("state", "absent", ["slug"])]

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

    netbox_device_type = NetboxDcimModule(module, NB_DEVICE_TYPES)
    netbox_device_type.run()
예제 #2
0
def main():
    """
    Main entry point for module execution
    """
    argument_spec = NETBOX_ARG_SPEC
    argument_spec.update(
        dict(
            data=dict(
                type="dict",
                required=True,
                options=dict(
                    name=dict(required=True, type="str"),
                    slug=dict(required=False, type="str"),
                ),
            ),
        )
    )

    required_if = [("state", "present", ["name"]), ("state", "absent", ["name"])]

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

    netbox_manufacturer = NetboxDcimModule(module, NB_MANUFACTURERS)
    netbox_manufacturer.run()
예제 #3
0
def main():
    """
    Main entry point for module execution
    """
    argument_spec = NETBOX_ARG_SPEC
    argument_spec.update(
        dict(data=dict(
            type="dict",
            required=True,
            options=dict(
                name=dict(required=True, type="str"),
                color=dict(required=False, type="str"),
                slug=dict(required=False, type="str"),
                vm_role=dict(required=False, type="bool"),
            ),
        ), ))

    required_if = [("state", "present", ["name"]),
                   ("state", "absent", ["name"])]

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

    netbox_device_role = NetboxDcimModule(module, NB_DEVICE_ROLES)
    netbox_device_role.run()
예제 #4
0
def main():
    """
    Main entry point for module execution
    """
    argument_spec = NETBOX_ARG_SPEC
    argument_spec.update(
        dict(data=dict(
            type="dict",
            required=True,
            options=dict(
                device=dict(required=False, type="raw"),
                name=dict(required=True, type="str"),
                description=dict(required=False, type="str"),
                installed_device=dict(required=False, type="raw"),
                tags=dict(required=False, type=list),
            ),
        ), ))

    required_if = [("state", "present", ["name"]),
                   ("state", "absent", ["name"])]

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

    netbox_device_bay = NetboxDcimModule(module, NB_DEVICE_BAYS)
    netbox_device_bay.run()
def main():
    """
    Main entry point for module execution
    """
    argument_spec = NETBOX_ARG_SPEC
    argument_spec.update(
        dict(data=dict(
            type="dict",
            required=True,
            options=dict(
                device=dict(required=False, type="raw"),
                name=dict(required=True, type="str"),
                manufacturer=dict(required=False, type="raw"),
                part_id=dict(required=False, type="str"),
                serial=dict(required=False, type="str"),
                asset_tag=dict(required=False, type="str"),
                description=dict(required=False, type="str"),
                tags=dict(required=False, type=list),
            ),
        ), ))

    required_if = [
        ("state", "present", ["device", "name"]),
        ("state", "absent", ["device", "name"]),
    ]

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

    netbox_inventory_item = NetboxDcimModule(module, NB_INVENTORY_ITEMS)
    netbox_inventory_item.run()
예제 #6
0
def main():
    """
    Main entry point for module execution
    """
    argument_spec = NETBOX_ARG_SPEC
    argument_spec.update(
        dict(
            data=dict(
                type="dict",
                required=True,
                options=dict(
                    name=dict(required=True, type="str"),
                    device_type=dict(required=False, type="raw"),
                    device_role=dict(required=False, type="raw"),
                    tenant=dict(required=False, type="raw"),
                    platform=dict(required=False, type="raw"),
                    serial=dict(required=False, type="str"),
                    asset_tag=dict(required=False, type="str"),
                    site=dict(required=False, type="raw"),
                    rack=dict(required=False, type="raw"),
                    position=dict(required=False, type="int"),
                    face=dict(
                        required=False,
                        type="str",
                        choices=["Front", "front", "Rear", "rear"],
                    ),
                    # Will uncomment other status dict once slugs are the only option (Netbox 2.8)
                    status=dict(required=False, type="raw"),
                    # status=dict(
                    #    required=False,
                    #    choices=[
                    #        "Active",
                    #        "Offline",
                    #        "Planned",
                    #        "Staged",
                    #        "Failed",
                    #        "Inventory",
                    #    ],
                    # ),
                    primary_ip4=dict(required=False, type="raw"),
                    primary_ip6=dict(required=False, type="raw"),
                    cluster=dict(required=False, type="raw"),
                    comments=dict(required=False, type="str"),
                    tags=dict(required=False, type=list),
                    custom_fields=dict(required=False, type=dict),
                ),
            ), ))

    required_if = [("state", "present", ["name"]),
                   ("state", "absent", ["name"])]

    module = NetboxAnsibleModule(argument_spec=argument_spec,
                                 supports_check_mode=True,
                                 required_if=required_if)
    if module.params["data"]["name"] == "":
        module.params["data"]["name"] = str(uuid.uuid4())

    netbox_device = NetboxDcimModule(module, NB_DEVICES)
    netbox_device.run()
예제 #7
0
def main():
    """
    Main entry point for module execution
    """
    argument_spec = NETBOX_ARG_SPEC
    argument_spec.update(
        dict(
            data=dict(
                type="dict",
                required=True,
                options=dict(
                    id=dict(required=False, type="int"),
                    termination_a_type=dict(required=False, type="str"),
                    termination_a_name=dict(required=True,
                                            type="str"),  # device name
                    termination_a_port=dict(required=True,
                                            type="str"),  # device port
                    termination_b_type=dict(required=False, type="str"),
                    termination_b_name=dict(required=True,
                                            type="str"),  # device name
                    termination_b_port=dict(required=True,
                                            type="str"),  # device port
                    type=dict(required=False, type="int"),
                    status=dict(required=False, type="bool"),
                    label=dict(required=False, type="str"),
                    color=dict(required=False, type="str"),
                    length=dict(required=False, type="int"),
                    length_unit=dict(required=False, type="raw"),
                ),
            ), ))

    required_if = [
        (
            "state",
            "present",
            [
                "termination_a_name",
                "termination_a_port",
                "termination_b_name",
                "termination_b_port",
            ],
        ),
        ("state", "absent", ["id"]),
    ]

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

    netbox_cable = NetboxDcimModule(module, NB_CABLES)
    netbox_cable.run()
예제 #8
0
def main():
    """
    Main entry point for module execution
    """
    argument_spec = NETBOX_ARG_SPEC
    argument_spec.update(
        dict(
            data=dict(
                type="dict",
                required=True,
                options=dict(
                    name=dict(required=True, type="str"),
                    # Will uncomment other status dict once slugs are the only option (Netbox 2.8)
                    status=dict(required=False, type="raw"),
                    # status=dict(
                    #    required=False, choices=["Active", "Planned", "Retired"],
                    # ),
                    region=dict(required=False, type="raw"),
                    tenant=dict(required=False, type="raw"),
                    vlan_role=dict(required=False, type="raw"),
                    facility=dict(required=False, type="str"),
                    asn=dict(required=False, type="int"),
                    time_zone=dict(required=False, type="str"),
                    description=dict(required=False, type="str"),
                    physical_address=dict(required=False, type="str"),
                    shipping_address=dict(required=False, type="str"),
                    latitude=dict(required=False, type="float"),
                    longitude=dict(required=False, type="float"),
                    contact_name=dict(required=False, type="str"),
                    contact_phone=dict(required=False, type="str"),
                    contact_email=dict(required=False, type="str"),
                    comments=dict(required=False, type="str"),
                    tags=dict(required=False, type=list),
                    custom_fields=dict(required=False, type=dict),
                ),
            ),
        )
    )

    required_if = [("state", "present", ["name"]), ("state", "absent", ["name"])]

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

    netbox_site = NetboxDcimModule(module, NB_SITES)
    netbox_site.run()
예제 #9
0
def main():
    """
    Main entry point for module execution
    """
    argument_spec = dict(
        netbox_url=dict(type="str", required=True),
        netbox_token=dict(type="str", required=True, no_log=True),
        data=dict(type="dict", required=True),
        state=dict(required=False, default="present", choices=["present", "absent"]),
        validate_certs=dict(type="bool", default=True),
    )
    required_if = [("state", "present", ["name"]), ("state", "absent", ["name"])]

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

    netbox_device = NetboxDcimModule(module, NB_DEVICES)
    netbox_device.run()
예제 #10
0
def main():
    """
    Main entry point for module execution
    """
    argument_spec = NETBOX_ARG_SPEC
    argument_spec.update(
        dict(data=dict(
            type="dict",
            required=True,
            options=dict(
                device=dict(required=False, type="raw"),
                name=dict(required=True, type="str"),
                form_factor=dict(required=False, type="raw"),
                enabled=dict(required=False, type="bool"),
                lag=dict(required=False, type="raw"),
                mtu=dict(required=False, type="int"),
                mac_address=dict(required=False, type="str"),
                mgmt_only=dict(required=False, type="bool"),
                description=dict(required=False, type="str"),
                mode=dict(
                    required=False,
                    choices=["Access", "Tagged", "Tagged All"],
                ),
                untagged_vlan=dict(required=False, type="raw"),
                tagged_vlans=dict(required=False, type="raw"),
                tags=dict(required=False, type=list),
            ),
        ), ))

    required_if = [
        ("state", "present", ["device", "name"]),
        ("state", "absent", ["device", "name"]),
    ]

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

    netbox_device_interface = NetboxDcimModule(module, NB_INTERFACES)
    netbox_device_interface.run()