Skip to content

Latest commit

 

History

History
1181 lines (618 loc) · 26.3 KB

netbox_custom_field_module.rst

File metadata and controls

1181 lines (618 loc) · 26.3 KB
orphan:

netbox.netbox.netbox_custom_field module -- Creates, updates or deletes custom fields within NetBox

Note

This module is part of the netbox.netbox collection (version 3.13.0).

To install it, use: ansible-galaxy collection install netbox.netbox. You need further requirements to be able to use this module, see :ref:`Requirements <ansible_collections.netbox.netbox.netbox_custom_field_module_requirements>` for details.

To use it in a playbook, specify: netbox.netbox.netbox_custom_field.

.. rst-class:: ansible-version-added

New in netbox.netbox 3.6.0

  • Creates, updates or removes custom fields from NetBox

The below requirements are needed on the host that executes this module.

  • pynetbox
.. rst-class:: ansible-option-table

Parameter Comments
.. rst-class:: ansible-option-title

cert

.. rst-class:: ansible-option-type-line

any

Certificate path

.. rst-class:: ansible-option-title

data

.. rst-class:: ansible-option-type-line

dictionary / required

Defines the custom field

.. rst-class:: ansible-option-title

choices

.. rst-class:: ansible-option-type-line

list / elements=string

List of available choices (for selection fields)

.. rst-class:: ansible-option-title

content_types

.. rst-class:: ansible-option-type-line

list / elements=any

The content type(s) to apply this custom field to

.. rst-class:: ansible-option-title

default

.. rst-class:: ansible-option-type-line

any

Default value of the custom field

.. rst-class:: ansible-option-title

description

.. rst-class:: ansible-option-type-line

string

Description of the custom field

.. rst-class:: ansible-option-title

filter_logic

.. rst-class:: ansible-option-type-line

any

Filter logic of the custom field

.. rst-class:: ansible-option-title

group_name

.. rst-class:: ansible-option-type-line

string

added in netbox.netbox 3.10.0

The group to associate the custom field with

.. rst-class:: ansible-option-title

label

.. rst-class:: ansible-option-type-line

string

Label of the custom field

.. rst-class:: ansible-option-title

name

.. rst-class:: ansible-option-type-line

string / required

Name of the custom field

.. rst-class:: ansible-option-title

object_type

.. rst-class:: ansible-option-type-line

string

added in netbox.netbox 3.7.0

The object type of the custom field (if any)

.. rst-class:: ansible-option-title

required

.. rst-class:: ansible-option-type-line

boolean

Whether the custom field is required

.. rst-class:: ansible-option-line

Choices:

.. rst-class:: ansible-option-title

search_weight

.. rst-class:: ansible-option-type-line

integer

added in netbox.netbox 3.10.0

Weighting for search. Lower values are considered more important. Fields with a search weight of zero will be ignored.

.. rst-class:: ansible-option-title

type

.. rst-class:: ansible-option-type-line

string

.. rst-class:: ansible-option-title

ui_visibility

.. rst-class:: ansible-option-type-line

string

added in netbox.netbox 3.10.0

The UI visibility of the custom field

.. rst-class:: ansible-option-line

Choices:

.. rst-class:: ansible-option-title

validation_maximum

.. rst-class:: ansible-option-type-line

integer

The maximum allowed value (for numeric fields)

.. rst-class:: ansible-option-title

validation_minimum

.. rst-class:: ansible-option-type-line

integer

The minimum allowed value (for numeric fields)

.. rst-class:: ansible-option-title

validation_regex

.. rst-class:: ansible-option-type-line

string

The regular expression to enforce on text fields

.. rst-class:: ansible-option-title

weight

.. rst-class:: ansible-option-type-line

integer

Fields with higher weights appear lower in a form

.. rst-class:: ansible-option-title

netbox_token

.. rst-class:: ansible-option-type-line

string / required

The NetBox API token.

.. rst-class:: ansible-option-title

netbox_url

.. rst-class:: ansible-option-type-line

string / required

The URL of the NetBox instance.

Must be accessible by the Ansible control host.

.. rst-class:: ansible-option-title

query_params

.. rst-class:: ansible-option-type-line

list / elements=string

This can be used to override the specified values in ALLOWED_QUERY_PARAMS that are defined

in plugins/module_utils/netbox_utils.py and provides control to users on what may make

an object unique in their environment.

.. rst-class:: ansible-option-title

state

.. rst-class:: ansible-option-type-line

string

The state of the object.

.. rst-class:: ansible-option-line

Choices:

.. rst-class:: ansible-option-title

validate_certs

.. rst-class:: ansible-option-type-line

any

If no, SSL certificates will not be validated.

This should only be used on personally controlled sites using a self-signed certificates.

.. rst-class:: ansible-option-line

Default: :ansible-option-default:`true`

Note

  • This should be ran with connection local and hosts localhost
- name: "Test NetBox custom_fields module"
  connection: local
  hosts: localhost
  tasks:
    - name: Create a custom field on device and virtual machine
      netbox.netbox.netbox_custom_field:
        netbox_url: http://netbox.local
        netbox_token: thisIsMyToken
        data:
          content_types:
            - dcim.device
            - virtualization.virtualmachine
          name: A Custom Field
          type: text

    - name: Update the custom field to make it required
      netbox.netbox.netbox_custom_field:
        netbox_url: http://netbox.local
        netbox_token: thisIsMyToken
        data:
          name: A Custom Field
          required: yes

    - name: Update the custom field to make it read only
      netbox.netbox.netbox_custom_field:
        netbox_url: http://netbox.local
        netbox_token: thisIsMyToken
        data:
          name: A Custom Field
          ui_visibility: read-only

    - name: Delete the custom field
      netbox.netbox.netbox_custom_field:
        netbox_url: http://netbox.local
        netbox_token: thisIsMyToken
        data:
          name: A Custom Field
        state: absent

Common return values are documented :ref:`here <common_return_values>`, the following are the fields unique to this module:

.. rst-class:: ansible-option-table

Key Description
.. rst-class:: ansible-option-title

custom_field

.. rst-class:: ansible-option-type-line

dictionary

Serialized object as created/existent/updated/deleted within NetBox

.. rst-class:: ansible-option-line

Returned: always

.. rst-class:: ansible-option-title

msg

.. rst-class:: ansible-option-type-line

string

Message indicating failure or info about what has been achieved

.. rst-class:: ansible-option-line

Returned: always

Authors

  • Martin Rødvand (@rodvand)

Collection links

Issue Tracker Repository (Sources)