netbox_community.ansible_modules.netbox_inventory_item (0.1.10) — module

Creates or removes inventory items from 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 or removes inventory items from Netbox


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Test Netbox inventory_item module"
  connection: local
  hosts: localhost
  gather_facts: False
  tasks:
    - name: Create inventory item within Netbox with only required information
      netbox_inventory_item:
        netbox_url: http://netbox.local
        netbox_token: thisIsMyToken
        data:
          device: test100
          name: "10G-SFP+"
        state: present

    - name: Update inventory item
      netbox_inventory_item:
        netbox_url: http://netbox.local
        netbox_token: thisIsMyToken
        data:
          device: test100
          name: "10G-SFP+"
          manufacturer: "Cisco"
          part_id: "10G-SFP+"
          serial: "1234"
          asset_tag: "1234"
          description: "New SFP"
        state: present

    - name: Delete inventory item within netbox
      netbox_inventory_item:
        netbox_url: http://netbox.local
        netbox_token: thisIsMyToken
        data:
          device: test100
          name: "10G-SFP+"
        state: absent

Inputs

    
data:
    description:
    - Defines the inventory item configuration
    required: true
    suboptions:
      asset_tag:
        description:
        - The asset tag of the inventory item
      description:
        description:
        - The description of the inventory item
      device:
        description:
        - Name of the device the inventory item belongs to
        required: true
      manufacturer:
        description:
        - The manufacturer of the inventory item
      name:
        description:
        - Name of the inventory item to be created
        required: true
        type: str
      part_id:
        description:
        - The part ID of the inventory item
      serial:
        description:
        - The serial number of the inventory item
      tags:
        description:
        - Any tags that the device may need to be associated with
    type: dict

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

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

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

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

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