networktocode.nautobot.custom_field (5.1.1) — module

Creates or removes custom fields from Nautobot

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

Authors: Joe Wesch (@joewesch)

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 custom fields from Nautobot


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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

Inputs

    
key:
    description:
    - Internal name of this field
    - Required if I(state=present) and the custom field does not exist yet
    required: false
    type: str
    version_added: 5.1.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

type:
    choices:
    - text
    - integer
    - boolean
    - date
    - url
    - select
    - multi-select
    - json
    - markdown
    description:
    - Data type of this field
    - Required if I(state=present) and the custom field does not exist yet
    - I(type=select) and I(type=multi-select) require choices to be defined separately
      with the I(custom_field_choice) module
    required: false
    type: str
    version_added: 5.1.0
    version_added_collection: networktocode.nautobot

label:
    description:
    - Name of the field as displayed to users
    required: true
    type: str
    version_added: 5.1.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

weight:
    description:
    - Position this field should be displayed in
    required: false
    type: int
    version_added: 5.1.0
    version_added_collection: networktocode.nautobot

default:
    description:
    - Default value for this field when editing models
    - Must be in JSON format
    required: false
    type: raw
    version_added: 5.1.0
    version_added_collection: networktocode.nautobot

grouping:
    description:
    - Human-readable grouping that this custom field belongs to
    required: false
    type: str
    version_added: 5.1.0
    version_added_collection: networktocode.nautobot

required:
    description:
    - Whether or not a value is required for this field when editing models
    required: false
    type: bool
    version_added: 5.1.0
    version_added_collection: networktocode.nautobot

advanced_ui:
    description:
    - Whether or not to display this field in the advanced tab
    required: false
    type: bool
    version_added: 5.1.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:
    - Description of this field
    - Also used as the help text when editing models using this custom field
    - Markdown is supported
    required: false
    type: str
    version_added: 5.1.0
    version_added_collection: networktocode.nautobot

filter_logic:
    choices:
    - disabled
    - loose
    - exact
    description:
    - Filter logic to apply when filtering models based on this field
    - Only compatible with I(type=text), I(type=url) and I(type=json)
    required: false
    type: str
    version_added: 5.1.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

content_types:
    description:
    - Content types that this field should be available for
    - Required if I(state=present) and the custom field does not exist yet
    elements: str
    required: false
    type: list
    version_added: 5.1.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

validation_regex:
    description:
    - Regular expression that this field must match
    - Only compatible with I(type=text)
    required: false
    type: str
    version_added: 5.1.0
    version_added_collection: networktocode.nautobot

validation_maximum:
    description:
    - Maximum value allowed for this field
    - Only compatible with I(type=integer)
    required: false
    type: int
    version_added: 5.1.0
    version_added_collection: networktocode.nautobot

validation_minimum:
    description:
    - Minimum value allowed for this field
    - Only compatible with I(type=integer)
    required: false
    type: int
    version_added: 5.1.0
    version_added_collection: networktocode.nautobot

Outputs

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