netbox_community.ansible_modules.netbox_device_type (0.1.10) — module

Create, update or delete device types within Netbox

| "added in version" 0.1.0 of netbox_community.ansible_modules"

Authors: Mikhail Yohman (@FragmentedPacket)

preview | supported by community

Install collection

Install with ansible-galaxy collection install netbox_community.ansible_modules:==0.1.10


Add to requirements.yml

  collections:
    - name: netbox_community.ansible_modules
      version: 0.1.10

Description

Creates, updates or removes device types from Netbox


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Test Netbox modules"
  connection: local
  hosts: localhost
  gather_facts: False

  tasks:
    - name: Create device type within Netbox with only required information
      netbox_device_type:
        netbox_url: http://netbox.local
        netbox_token: thisIsMyToken
        data:
          slug: test-device-type
          model: ws-test-3750
          manufacturer: Test Manufacturer
        state: present

    - name: Create device type within Netbox with only required information
      netbox_device_type:
        netbox_url: http://netbox.local
        netbox_token: thisIsMyToken
        data:
          slug: test-device-type
          model: ws-test-3750
          manufacturer: Test Manufacturer
          part_number: ws-3750g-v2
          u_height: 1
          is_full_depth: False
          subdevice_role: parent
        state: present

    - name: Delete device type within netbox
      netbox_device_type:
        netbox_url: http://netbox.local
        netbox_token: thisIsMyToken
        data:
          slug: test-device-type
        state: absent

Inputs

    
data:
    description:
    - Defines the device type configuration
    required: true
    suboptions:
      comments:
        description:
        - Comments that may include additional information in regards to the device_type
      custom_fields:
        description:
        - must exist in Netbox
      is_full_depth:
        description:
        - Whether or not the device consumes both front and rear rack faces
        type: bool
      manufacturer:
        description:
        - The manufacturer of the device type
        required: true
      model:
        description:
        - The model of the device type
        required: true
      part_number:
        description:
        - The part number of the device type
      slug:
        description:
        - The slug of the device type. Must follow slug formatting (URL friendly)
        - If not specified, it will slugify the model
        - ex. test-device-type
        required: false
      subdevice_role:
        choices:
        - Parent
        - Child
        description:
        - Whether the device type is parent, child, or neither
      tags:
        description:
        - Any tags that the device type may need to be associated with
      u_height:
        description:
        - The height of the device type in rack units

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

netbox_url:
    description:
    - URL of the Netbox instance resolvable by Ansible control host
    required: true

netbox_token:
    description:
    - The token created within Netbox to authorize API access
    required: true

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

Outputs

device_type:
  description: Serialized object as created or already existent within Netbox
  returned: success (when I(state=present))
  type: dict
msg:
  description: Message indicating failure or info about what has been achieved
  returned: always
  type: str