コード例 #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(
                    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()
コード例 #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(
                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()
コード例 #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(
                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()
コード例 #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(
                prefix=dict(required=True, type="raw"),
                rir=dict(required=False, type="raw"),
                date_added=dict(required=False, type="str"),
                description=dict(required=False, type="str"),
                tags=dict(required=False, type=list),
                custom_fields=dict(required=False, type=dict),
            ),
        ), ))

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

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

    netbox_aggregate = NetboxIpamModule(module, NB_AGGREGATES)
    netbox_aggregate.run()
コード例 #5
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()
コード例 #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(
                    device=dict(required=True, type="raw"),
                    virtual_machine=dict(required=False, type="raw"),
                    name=dict(required=True, type="str"),
                    port=dict(required=True, type="int"),
                    protocol=dict(required=True, type="raw"),
                    ipaddresses=dict(required=False, type="raw"),
                    description=dict(required=False, type="str"),
                    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_service = NetboxIpamModule(module, NB_SERVICES)
    netbox_service.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(
                circuit=dict(required=True, type="raw"),
                term_side=dict(required=True, choices=["A", "Z"]),
                site=dict(required=False, type="raw"),
                port_speed=dict(required=False, type="int"),
                upstream_speed=dict(required=False, type="int"),
                xconnect_id=dict(required=False, type="str"),
                pp_info=dict(required=False, type="str"),
                description=dict(required=False, type="str"),
            ),
        ), ))

    required_if = [
        ("state", "present", ["circuit", "term_side"]),
        ("state", "absent", ["circuit", "term_side"]),
    ]

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

    netbox_circuit_termination = NetboxCircuitsModule(module,
                                                      NB_CIRCUIT_TERMINATIONS)
    netbox_circuit_termination.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"),
                slug=dict(required=False, type="str"),
                site=dict(required=False, type="raw"),
            ),
        ), ))

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

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

    netbox_vlan_group = NetboxIpamModule(module, NB_VLAN_GROUPS)
    netbox_vlan_group.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", "new"]
        ),
        validate_certs=dict(type="bool", default=True),
    )
    required_if = [
        ("state", "present", ["address", "prefix"], True),
        ("state", "absent", ["address"]),
        ("state", "new", ["address", "prefix"], True),
    ]

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

    netbox_ip_address = NetboxIpamModule(module, NB_IP_ADDRESSES)
    netbox_ip_address.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(
                    name=dict(required=True, type="str"),
                    cluster_type=dict(required=False, type="raw"),
                    cluster_group=dict(required=False, type="raw"),
                    site=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
    )

    netbox_cluster = NetboxVirtualizationModule(module, NB_CLUSTERS)
    netbox_cluster.run()
コード例 #11
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()
コード例 #12
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", ["circuit", "term_side"]),
        ("state", "absent", ["circuit", "term_side"]),
    ]

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

    netbox_circuit_termination = NetboxCircuitsModule(module,
                                                      NB_CIRCUIT_TERMINATIONS)
    netbox_circuit_termination.run()
コード例 #13
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"),
                    rd=dict(required=False, type="str"),
                    tenant=dict(required=False, type="raw"),
                    enforce_unique=dict(required=False, type="bool"),
                    description=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_vrf = NetboxIpamModule(module, NB_VRFS)
    netbox_vrf.run()
コード例 #14
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()
コード例 #15
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()
コード例 #16
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(
                    family=dict(required=False, type="int"),
                    prefix=dict(required=False, type="raw"),
                    parent=dict(required=False, type="raw"),
                    prefix_length=dict(required=False, type="int"),
                    site=dict(required=False, type="str"),
                    vrf=dict(required=False, type="raw"),
                    tenant=dict(required=False, type="raw"),
                    vlan=dict(required=False, type="raw"),
                    # Will uncomment other status dict once slugs are the only option (Netbox 2.8)
                    status=dict(required=False, type="raw"),
                    # status=dict(
                    #    required=False,
                    #    type="str",
                    #    choices=["Active", "Container", "Deprecated", "Reserved"],
                    # ),
                    prefix_role=dict(required=False, type="raw"),
                    is_pool=dict(required=False, type="bool"),
                    description=dict(required=False, type="str"),
                    tags=dict(required=False, type=list),
                    custom_fields=dict(required=False, type=dict),
                ),
            ),
            first_available=dict(required=False, type="bool"),
        )
    )

    required_if = [
        ("state", "present", ["prefix", "parent"], True),
        ("state", "absent", ["prefix"]),
        ("first_available", "yes", ["parent"]),
    ]

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

    netbox_prefix = NetboxIpamModule(module, NB_PREFIXES)
    netbox_prefix.run()
コード例 #17
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(
                    cid=dict(required=True, type="str"),
                    provider=dict(required=False, type="raw"),
                    circuit_type=dict(required=False, type="raw"),
                    # 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",
                    #        "Provisioning",
                    #        "Deprovisioning",
                    #        "Decommissioned",
                    #    ],
                    # ),
                    tenant=dict(required=False, type="raw"),
                    install_date=dict(required=False, type="str"),
                    commit_rate=dict(required=False, type="int"),
                    description=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", ["cid"]), ("state", "absent", ["cid"])]

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

    netbox_circuit = NetboxCircuitsModule(module, NB_CIRCUITS)
    netbox_circuit.run()
コード例 #18
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()
コード例 #19
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()
コード例 #20
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(
                    site=dict(required=False, type="raw"),
                    vlan_group=dict(required=False, type="raw"),
                    vid=dict(required=False, type="int"),
                    name=dict(required=True, type="str"),
                    tenant=dict(required=False, type="raw"),
                    # 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", "Reserved", "Deprecated"],
                    # ),
                    vlan_role=dict(required=False, type="raw"),
                    description=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_vlan = NetboxIpamModule(module, NB_VLANS)
    netbox_vlan.run()
コード例 #21
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"),
                    site=dict(required=False, type="raw"),
                    cluster=dict(required=False, type="raw"),
                    virtual_machine_role=dict(required=False, type="raw"),
                    vcpus=dict(required=False, type="int"),
                    tenant=dict(required=False, type="raw"),
                    platform=dict(required=False, type="raw"),
                    primary_ip4=dict(required=False, type="raw"),
                    primary_ip6=dict(required=False, type="raw"),
                    memory=dict(required=False, type="int"),
                    disk=dict(required=False, type="int"),
                    rack=dict(required=False, type="raw"),
                    # Will uncomment other status dict once slugs are the only option (Netbox 2.8)
                    status=dict(required=False, type="raw"),
                    # status=dict(required=False, type="str", choices=["Active", "Offline", "Staged"]),
                    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_virtual_machine = NetboxVirtualizationModule(module, NB_VIRTUAL_MACHINES)
    netbox_virtual_machine.run()
コード例 #22
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()
コード例 #23
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"]),
        first_available=dict(type="bool", required=False, default=False),
        validate_certs=dict(type="bool", default=True),
    )
    required_if = [
        ("state", "present", ["prefix", "parent"], True),
        ("state", "absent", ["prefix"]),
        ("first_available", "yes", ["parent"]),
    ]

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

    netbox_prefix = NetboxIpamModule(module, NB_PREFIXES)
    netbox_prefix.run()
コード例 #24
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_circuit_type = NetboxCircuitsModule(module, NB_CIRCUIT_TYPES)
    netbox_circuit_type.run()
コード例 #25
0
def main():
    """
    Main entry point for module execution
    """
    argument_spec = NETBOX_ARG_SPEC
    # state choices present, absent, new
    argument_spec["state"] = dict(
        required=False, default="present", choices=["present", "absent", "new"]
    )
    argument_spec.update(
        dict(
            data=dict(
                type="dict",
                required=True,
                options=dict(
                    family=dict(required=False, type="int"),
                    address=dict(required=False, type="str"),
                    prefix=dict(required=False, type="raw"),
                    vrf=dict(required=False, type="raw"),
                    tenant=dict(required=False, type="raw"),
                    # Will uncomment other status dict once slugs are the only option (Netbox 2.8)
                    status=dict(required=False, type="raw"),
                    # status=dict(
                    #    required=False,
                    #    type="str",
                    #    choices=["Active", "Reserved", "Deprecated", "DHCP"],
                    # ),
                    role=dict(
                        required=False,
                        type="str",
                        choices=[
                            "Loopback",
                            "Secondary",
                            "Anycast",
                            "VIP",
                            "VRRP",
                            "HSRP",
                            "GLBP",
                            "CARP",
                        ],
                    ),
                    interface=dict(required=False, type="raw"),
                    description=dict(required=False, type="str"),
                    nat_inside=dict(required=False, type="raw"),
                    tags=dict(required=False, type=list),
                    custom_fields=dict(required=False, type=dict),
                ),
            ),
        )
    )

    required_if = [
        ("state", "present", ["address", "prefix"], True),
        ("state", "absent", ["address"]),
        ("state", "new", ["address", "prefix"], True),
    ]

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

    netbox_ip_address = NetboxIpamModule(module, NB_IP_ADDRESSES)
    netbox_ip_address.run()