networktocode.nautobot.device_interface (5.1.1) — module

Creates or removes interfaces on devices from Nautobot

| "added in version" 1.0.0 of networktocode.nautobot"

Authors: Mikhail Yohman (@FragmentedPacket)

Install collection

Install with ansible-galaxy collection install networktocode.nautobot:==5.1.1


Add to requirements.yml

  collections:
    - name: networktocode.nautobot
      version: 5.1.1

Description

Creates or removes interfaces from Nautobot


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Test Nautobot interface module"
  connection: local
  hosts: localhost
  gather_facts: False
  tasks:
    - name: Create interface within Nautobot with only required information
      networktocode.nautobot.device_interface:
        url: http://nautobot.local
        token: thisIsMyToken
        device: test100
        name: GigabitEthernet1
        state: present
    - name: Delete interface within nautobot
      networktocode.nautobot.device_interface:
        url: http://nautobot.local
        token: thisIsMyToken
        device: test100
        name: GigabitEthernet1
        state: absent
    - name: Create LAG with several specified options
      networktocode.nautobot.device_interface:
        url: http://nautobot.local
        token: thisIsMyToken
        device: test100
        name: port-channel1
        type: Link Aggregation Group (LAG)
        mtu: 1600
        mgmt_only: false
        mode: Access
        state: present
    - name: Create interface and assign it to parent LAG
      networktocode.nautobot.device_interface:
        url: http://nautobot.local
        token: thisIsMyToken
        device: test100
        name: GigabitEthernet1
        enabled: false
        type: 1000Base-t (1GE)
        lag:
          name: port-channel1
        mtu: 1600
        mgmt_only: false
        mode: Access
        state: present
    - name: Create interface as a trunk port
      networktocode.nautobot.device_interface:
        url: http://nautobot.local
        token: thisIsMyToken
        device: test100
        name: GigabitEthernet25
        enabled: false
        type: 1000Base-t (1GE)
        untagged_vlan:
          name: Wireless
          location: "{{ location['key'] }}"
        tagged_vlans:
          - name: Data
            location: "{{ location['key'] }}"
          - name: VoIP
            location: "{{ location['key'] }}"
        mtu: 1600
        mgmt_only: true
        mode: Tagged
        state: present
    - name: Update interface on child device on virtual chassis
      networktocode.nautobot.device_interface:
        url: http://nautobot.local
        token: thisIsMyToken
        device: test100
        name: GigabitEthernet2/0/1
        enabled: false
        update_vc_child: True
    - name: |
        Create an interface and update custom_field data point,
        setting the value to True
      networktocode.nautobot.device_interface:
        url: http://nautobot.local
        token: thisIsMyToken
        device: test100
        name: GigabitEthernet1/1/1
        enabled: false
        custom_fields:
          monitored: True
    - name: Create child interface
      networktocode.nautobot.device_interface:
        url: http://nautobot.local
        token: thisIsMyToken
        device: test100
        name: GigabitEthernet1/1/1
        type: Virtual
        parent_interface:
          name: GigabitEthernet1/1
    - name: Create bridge interface
      networktocode.nautobot.device_interface:
        url: http://nautobot.local
        token: thisIsMyToken
        device: test100
        name: Bridge1
        bridge:
          name: GigabitEthernet1/1

Inputs

    
lag:
    description:
    - Parent LAG interface will be a member of
    required: false
    type: raw
    version_added: 3.0.0
    version_added_collection: networktocode.nautobot

mtu:
    description:
    - The MTU of the interface
    required: false
    type: int
    version_added: 3.0.0
    version_added_collection: networktocode.nautobot

url:
    description:
    - 'The URL of the Nautobot instance resolvable by the Ansible host (for example: http://nautobot.example.com:8000)'
    required: true
    type: str

mode:
    description:
    - The mode of the interface
    required: false
    type: raw
    version_added: 3.0.0
    version_added_collection: networktocode.nautobot

name:
    description:
    - Name of the interface to be created
    required: true
    type: str
    version_added: 3.0.0
    version_added_collection: networktocode.nautobot

tags:
    description:
    - Any tags that this item may need to be associated with
    elements: raw
    required: false
    type: list
    version_added: 3.0.0
    version_added_collection: networktocode.nautobot

type:
    description:
    - 'Form factor of the interface:

      ex. 1000Base-T (1GE), Virtual, 10GBASE-T (10GE)

      This has to be specified exactly as what is found within UI

      '
    required: false
    type: str
    version_added: 3.0.0
    version_added_collection: networktocode.nautobot

label:
    description:
    - Physical label of the interface
    required: false
    type: str
    version_added: 3.0.0
    version_added_collection: networktocode.nautobot

state:
    choices:
    - absent
    - present
    default: present
    description:
    - Use C(present) or C(absent) for adding or removing.
    type: str

token:
    description:
    - The token created within Nautobot to authorize API access
    required: true
    type: str

bridge:
    description:
    - Interface that will be the bridge of the interface being created
    required: false
    type: raw
    version_added: 4.5.0
    version_added_collection: networktocode.nautobot

device:
    description:
    - Name of the device the interface will be associated with (case-sensitive)
    required: true
    type: raw
    version_added: 3.0.0
    version_added_collection: networktocode.nautobot

status:
    description:
    - The status of the interface
    - Required if I(state=present) and the interface does not exist yet
    required: false
    type: raw
    version_added: 4.5.0
    version_added_collection: networktocode.nautobot

enabled:
    description:
    - Sets whether interface shows enabled or disabled
    required: false
    type: bool
    version_added: 3.0.0
    version_added_collection: networktocode.nautobot

mgmt_only:
    description:
    - This interface is used only for out-of-band management
    required: false
    type: bool
    version_added: 3.0.0
    version_added_collection: networktocode.nautobot

api_version:
    description:
    - API Version Nautobot REST API
    required: false
    type: str
    version_added: 4.1.0
    version_added_collection: networktocode.nautobot

description:
    description:
    - The description of the interface
    required: false
    type: str
    version_added: 3.0.0
    version_added_collection: networktocode.nautobot

mac_address:
    description:
    - The MAC address of the interface
    required: false
    type: str
    version_added: 3.0.0
    version_added_collection: networktocode.nautobot

query_params:
    description:
    - This can be used to override the specified values in ALLOWED_QUERY_PARAMS that is
      defined
    - in plugins/module_utils/utils.py and provides control to users on what may make
    - an object unique in their environment.
    elements: str
    required: false
    type: list
    version_added: 3.0.0
    version_added_collection: networktocode.nautobot

tagged_vlans:
    description:
    - A list of tagged VLANS to be assigned to interface. Mode must be set to either C(Tagged)
      or C(Tagged All)
    required: false
    type: raw
    version_added: 3.0.0
    version_added_collection: networktocode.nautobot

custom_fields:
    description:
    - Must exist in Nautobot and in key/value format
    required: false
    type: dict
    version_added: 3.0.0
    version_added_collection: networktocode.nautobot

untagged_vlan:
    description:
    - The untagged VLAN to be assigned to interface
    required: false
    type: raw
    version_added: 3.0.0
    version_added_collection: networktocode.nautobot

validate_certs:
    default: true
    description:
    - If C(no), SSL certificates will not be validated. This should only be used on personally
      controlled sites using self-signed certificates.
    required: false
    type: raw

update_vc_child:
    default: false
    description:
    - 'Use when master device is specified for C(device) and the specified interface exists
      on a child device

      and needs updated

      '
    type: bool
    version_added: 3.0.0
    version_added_collection: networktocode.nautobot

parent_interface:
    description:
    - Interface that will be the parent of the interface being created
    required: false
    type: raw
    version_added: 4.5.0
    version_added_collection: networktocode.nautobot

Outputs

interface:
  description: Serialized object as created or already existent within Nautobot
  returned: on creation
  type: dict
msg:
  description: Message indicating failure or info about what has been achieved
  returned: always
  type: str