custom_field¶
Collection Note
This module is part of the networktocode.nautobot collection. To install the collection, use:
You need further requirements to be able to use this module, see the Requirements section for details.Synopsis¶
- Creates or removes custom fields from Nautobot
Requirements¶
The following Python packages are needed on the host that executes this module:
Parameters¶
Parameter | Data Type | Environment Variable | Comments |
---|---|---|---|
advanced_ui | bool | Whether or not to display this field in the advanced tab Version Added: 5.1.0 |
|
api_version | str | API Version Nautobot REST API Version Added: 4.1.0 |
|
content_types | list | Content types that this field should be available for Required if I(state=present) and the custom field does not exist yet Version Added: 5.1.0 |
|
default | raw | Default value for this field when editing models Must be in JSON format Version Added: 5.1.0 |
|
description | str | Description of this field Also used as the help text when editing models using this custom field Markdown is supported Version Added: 5.1.0 |
|
filter_logic | str | Filter logic to apply when filtering models based on this field Only compatible with I(type=text), I(type=url) and I(type=json) Version Added: 5.1.0 |
|
grouping | str | Human-readable grouping that this custom field belongs to Version Added: 5.1.0 |
|
key | str | Internal name of this field Required if I(state=present) and the custom field does not exist yet Version Added: 5.1.0 |
|
label required |
str | Name of the field as displayed to users Version Added: 5.1.0 |
|
query_params | list | 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. Version Added: 3.0.0 |
|
required | bool | Whether or not a value is required for this field when editing models Version Added: 5.1.0 |
|
state | str | Use C(present) or C(absent) for adding or removing. | |
token required |
str | The token created within Nautobot to authorize API access Can be omitted if the E(NAUTOBOT_TOKEN) environment variable is configured. | |
type | str | 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 Version Added: 5.1.0 |
|
url required |
str | The URL of the Nautobot instance resolvable by the Ansible host (for example: http://nautobot.example.com:8000) Can be omitted if the E(NAUTOBOT_URL) environment variable is configured. | |
validate_certs | raw | If C(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 E(NAUTOBOT_VALIDATE_CERTS) environment variable is configured. | |
validation_maximum | int | Maximum value allowed for this field Only compatible with I(type=integer) Version Added: 5.1.0 |
|
validation_minimum | int | Minimum value allowed for this field Only compatible with I(type=integer) Version Added: 5.1.0 |
|
validation_regex | str | Regular expression that this field must match Only compatible with I(type=text) Version Added: 5.1.0 |
|
weight | int | Position this field should be displayed in Version Added: 5.1.0 |
Notes¶
Note
- This should be ran with connection C(local) and hosts C(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¶
Key | Data Type | Description | Returned |
---|---|---|---|
custom_field | dict | Serialized object as created or already existent within Nautobot | success (when I(state=present)) |
msg | str | Message indicating failure or info about what has been achieved | always |
Authors¶
- Joe Wesch (@joewesch)