networktocode.nautobot.custom_field module – Creates or removes custom fields from Nautobot

Note

This module is part of the networktocode.nautobot collection (version 5.2.1).

To install it, use: ansible-galaxy collection install networktocode.nautobot. You need further requirements to be able to use this module, see Requirements for details.

To use it in a playbook, specify: networktocode.nautobot.custom_field.

New in networktocode.nautobot 5.1.0

Synopsis

  • Creates or removes custom fields from Nautobot

Requirements

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

  • pynautobot

Parameters

Parameter

Comments

advanced_ui

boolean

added in networktocode.nautobot 5.1.0

Whether or not to display this field in the advanced tab

Choices:

api_version

string

added in networktocode.nautobot 4.1.0

API Version Nautobot REST API

content_types

list / elements=string

added in networktocode.nautobot 5.1.0

Content types that this field should be available for

Required if state=present and the custom field does not exist yet

default

any

added in networktocode.nautobot 5.1.0

Default value for this field when editing models

Must be in JSON format

description

string

added in networktocode.nautobot 5.1.0

Description of this field

Also used as the help text when editing models using this custom field

Markdown is supported

filter_logic

string

added in networktocode.nautobot 5.1.0

Filter logic to apply when filtering models based on this field

Only compatible with type=text, type=url and type=json

Choices:

grouping

string

added in networktocode.nautobot 5.1.0

Human-readable grouping that this custom field belongs to

key

string

added in networktocode.nautobot 5.1.0

Internal name of this field

Required if state=present and the custom field does not exist yet

label

string / required

added in networktocode.nautobot 5.1.0

Name of the field as displayed to users

query_params

list / elements=string

added in networktocode.nautobot 3.0.0

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.

required

boolean

added in networktocode.nautobot 5.1.0

Whether or not a value is required for this field when editing models

Choices:

state

string

Use present or absent for adding or removing.

Choices:

token

string / required

The token created within Nautobot to authorize API access

Can be omitted if the NAUTOBOT_TOKEN environment variable is configured.

type

string

added in networktocode.nautobot 5.1.0

url

string / required

The URL of the Nautobot instance resolvable by the Ansible host (for example: http://nautobot.example.com:8000)

Can be omitted if the NAUTOBOT_URL environment variable is configured.

validate_certs

any

If no, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates.

Can be omitted if the NAUTOBOT_VALIDATE_CERTS environment variable is configured.

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

validation_maximum

integer

added in networktocode.nautobot 5.1.0

Maximum value allowed for this field

Only compatible with type=integer

validation_minimum

integer

added in networktocode.nautobot 5.1.0

Minimum value allowed for this field

Only compatible with type=integer

validation_regex

string

added in networktocode.nautobot 5.1.0

Regular expression that this field must match

Only compatible with type=text

weight

integer

added in networktocode.nautobot 5.1.0

Position this field should be displayed in

Notes

Note

  • This should be ran with connection local and hosts localhost

Examples

- name: Create custom field within Nautobot with only required information
  networktocode.nautobot.custom_field:
    url: http://nautobot.local
    token: thisIsMyToken
    label: My Custom Field
    key: my_custom_field
    type: text
    state: present

- name: Create custom field within Nautobot with all information
  networktocode.nautobot.custom_field:
    url: http://nautobot.local
    token: thisIsMyToken
    label: My Custom Field
    grouping: My Grouping
    key: my_custom_field
    type: text
    weight: 100
    description: My Description
    required: true
    default: My Default
    filter_logic: loose
    advanced_ui: true
    content_types:
      - dcim.device
    validation_minimum: 0
    validation_maximum: 100
    validation_regex: ^[a-z]+$
    state: present

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

custom_field

dictionary

Serialized object as created or already existent within Nautobot

Returned: success (when state=present)

msg

string

Message indicating failure or info about what has been achieved

Returned: always

Authors

  • Joe Wesch (@joewesch)