networktocode.nautobot.inventory (5.1.1) — inventory

Nautobot inventory source

Authors: Remy Leone (@sieben), Anthony Ruhier (@Anthony25), Nikhil Singh Baliyan (@nikkytub), Sander Steffann (@steffann), Douglas Heriot (@DouglasHeriot)

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

Get inventory hosts from Nautobot

Inputs

    
cache:
    default: false
    description:
    - Toggle to enable/disable the caching of the inventory's source data, requires a
      cache plugin setup to work.
    env:
    - name: ANSIBLE_INVENTORY_CACHE
    ini:
    - key: cache
      section: inventory
    type: bool

token:
    description:
    - Nautobot API token to be able to read against Nautobot.
    - This may not be required depending on the Nautobot setup.
    env:
    - name: NAUTOBOT_TOKEN
    required: false

groups:
    default: {}
    description: Add hosts to group based on Jinja2 conditionals.
    type: dict

plugin:
    choices:
    - networktocode.nautobot.inventory
    description: token that ensures this is a source file for the 'nautobot' plugin.
    required: true

strict:
    default: false
    description:
    - If V(yes) make invalid entries a fatal error, otherwise skip and continue.
    - Since it is possible to use facts in the expressions they might not always be available
      and we ignore those errors by default.
    type: bool

compose:
    default: {}
    description: List of custom ansible host vars to create from the device object fetched
      from Nautobot
    type: dict

plurals:
    default: true
    description:
    - If True, all host vars are contained inside single-element arrays for legacy compatibility
      with old versions of this plugin.
    - Group names will be plural (ie. "locations_mylocation" instead of "location_mylocation")
    - The choices of I(group_by) will be changed by this option.
    type: boolean
    version_added: 1.0.0
    version_added_collection: networktocode.nautobot

timeout:
    default: 60
    description: Timeout for Nautobot requests in seconds
    type: int

dns_name:
    default: false
    description:
    - Force IP Addresses to be fetched so that the dns_name for the primary_ip of each
      device or VM is set as a host_var.
    - Setting interfaces will also fetch IP addresses and the dns_name host_var will be
      set.
    type: boolean

group_by:
    choices:
    - locations
    - location
    - tenants
    - tenant
    - tenant_group
    - racks
    - rack
    - rack_group
    - rack_role
    - tags
    - tag
    - device_roles
    - role
    - device_types
    - device_type
    - manufacturers
    - manufacturer
    - platforms
    - platform
    - cluster
    - cluster_type
    - cluster_group
    - is_virtual
    - services
    - status
    default: []
    description: Keys used to create groups. The I(plurals) option controls which of these
      are valid.
    elements: str
    type: list

services:
    default: true
    description:
    - If True, it adds the device or virtual machine services information in host vars.
    type: boolean
    version_added: 1.0.0
    version_added_collection: networktocode.nautobot

fetch_all:
    default: true
    description:
    - By default, fetching interfaces and services will get all of the contents of Nautobot
      regardless of query_filters applied to devices and VMs.
    - When set to False, separate requests will be made fetching interfaces, services,
      and IP addresses for each device_id and virtual_machine_id.
    - If you are using the various query_filters options to reduce the number of devices,
      querying Nautobot may be faster with fetch_all False.
    - For efficiency, when False, these requests will be batched, for example /api/dcim/interfaces?limit=0&device_id=1&device_id=2&device_id=3
    - These GET request URIs can become quite large for a large number of devices.
    - If you run into HTTP 414 errors, you can adjust the max_uri_length option to suit
      your web server.
    type: boolean
    version_added: 1.0.0
    version_added_collection: networktocode.nautobot

interfaces:
    default: false
    description:
    - If True, it adds the device or virtual machine interface information in host vars.
    type: boolean
    version_added: 1.0.0
    version_added_collection: networktocode.nautobot

api_version:
    description: The version of the Nautobot REST API.
    required: false
    version_added: 4.1.0
    version_added_collection: networktocode.nautobot

api_endpoint:
    description: Endpoint of the Nautobot API
    env:
    - name: NAUTOBOT_URL
    required: true

cache_plugin:
    default: memory
    description:
    - Cache plugin to use for the inventory's source data.
    env:
    - name: ANSIBLE_CACHE_PLUGIN
    - name: ANSIBLE_INVENTORY_CACHE_PLUGIN
    ini:
    - key: fact_caching
      section: defaults
    - key: cache_plugin
      section: inventory
    type: str

cache_prefix:
    default: ansible_inventory_
    description:
    - Prefix to use for cache plugin files/tables
    env:
    - name: ANSIBLE_CACHE_PLUGIN_PREFIX
    - name: ANSIBLE_INVENTORY_CACHE_PLUGIN_PREFIX
    ini:
    - key: fact_caching_prefix
      section: defaults
    - key: cache_prefix
      section: inventory

keyed_groups:
    default: []
    description: Add hosts to group based on the values of a variable.
    elements: dict
    suboptions:
      default_value:
        description:
        - The default value when the host variable's value is an empty string.
        - This option is mutually exclusive with O(keyed_groups[].trailing_separator).
        type: str
        version_added: '2.12'
        version_added_collection: ansible.builtin
      key:
        description:
        - The key from input dictionary used to generate groups
        type: str
      parent_group:
        description: parent group for keyed group
        type: str
      prefix:
        default: ''
        description: A keyed group name will start with this prefix
        type: str
      separator:
        default: _
        description: separator used to build the keyed group name
        type: str
      trailing_separator:
        default: true
        description:
        - Set this option to V(False) to omit the O(keyed_groups[].separator) after the
          host variable when the value is an empty string.
        - This option is mutually exclusive with O(keyed_groups[].default_value).
        type: bool
        version_added: '2.12'
        version_added_collection: ansible.builtin
    type: list

cache_timeout:
    default: 3600
    description:
    - Cache duration in seconds
    env:
    - name: ANSIBLE_CACHE_PLUGIN_TIMEOUT
    - name: ANSIBLE_INVENTORY_CACHE_TIMEOUT
    ini:
    - key: fact_caching_timeout
      section: defaults
    - key: cache_timeout
      section: inventory
    type: int

query_filters:
    default: []
    description: List of parameters passed to the query string for both devices and VMs
      (Multiple values may be separated by commas)
    elements: str
    type: list

config_context:
    default: false
    description:
    - If True, it adds config_context in host vars.
    - Config-context enables the association of arbitrary data to devices and virtual
      machines grouped by location, role, platform, and/or tenant. Please check official
      nautobot docs for more info.
    type: boolean

max_uri_length:
    default: 4000
    description:
    - When fetch_all is False, GET requests to Nautobot may become quite long and return
      a HTTP 414 (URI Too Long).
    - You can adjust this option to be smaller to avoid 414 errors, or larger for a reduced
      number of requests.
    type: int
    version_added: 1.0.0
    version_added_collection: networktocode.nautobot

use_extra_vars:
    default: false
    description: Merge extra vars into the available variables for composition (highest
      precedence).
    env:
    - name: ANSIBLE_INVENTORY_USE_EXTRA_VARS
    ini:
    - key: use_extra_vars
      section: inventory_plugins
    type: bool
    version_added: '2.11'
    version_added_collection: ansible.builtin

validate_certs:
    default: true
    description:
    - Allows connection when SSL certificates are not valid. Set to C(false) when certificates
      are not trusted.
    type: boolean

group_names_raw:
    default: false
    description: Will not add the group_by choice name to the group names
    type: boolean
    version_added: 1.0.0
    version_added_collection: networktocode.nautobot

cache_connection:
    description:
    - Cache connection data or path, read cache plugin documentation for specifics.
    env:
    - name: ANSIBLE_CACHE_PLUGIN_CONNECTION
    - name: ANSIBLE_INVENTORY_CACHE_CONNECTION
    ini:
    - key: fact_caching_connection
      section: defaults
    - key: cache_connection
      section: inventory
    type: str

follow_redirects:
    choices:
    - urllib2
    - all
    - 'yes'
    - safe
    - none
    default: urllib2
    description:
    - Determine how redirects are followed.
    - By default, I(follow_redirects) is set to uses urllib2 default behavior.

vm_query_filters:
    default: []
    description: List of parameters passed to the query string for VMs (Multiple values
      may be separated by commas)
    elements: str
    type: list

leading_separator:
    default: true
    description:
    - Use in conjunction with keyed_groups.
    - By default, a keyed group that does not have a prefix or a separator provided will
      have a name that starts with an underscore.
    - This is because the default prefix is "" and the default separator is "_".
    - Set this option to False to omit the leading underscore (or other separator) if
      no prefix is given.
    - If the group name is derived from a mapping the separator is still used to concatenate
      the items.
    - To not use a separator in the group name at all, set the separator for the keyed
      group to an empty string instead.
    type: boolean
    version_added: '2.11'
    version_added_collection: ansible.builtin

device_query_filters:
    default: []
    description: List of parameters passed to the query string for devices (Multiple values
      may be separated by commas)
    elements: str
    type: list

virtual_chassis_name:
    default: false
    description:
    - When a device is part of a virtual chassis, use the virtual chassis name as the
      Ansible inventory hostname.
    - The host var values will be from the virtual chassis master.
    type: boolean

ansible_host_dns_name:
    default: false
    description:
    - If True, sets DNS Name (fetched from primary_ip) to be used in ansible_host variable,
      instead of IP Address.
    type: boolean

flatten_custom_fields:
    default: false
    description:
    - By default, host custom fields are added as a dictionary host var named custom_fields.
    - If flatten_custom_fields is set to True, the fields will be added directly to the
      host instead.
    type: boolean
    version_added: 1.0.0
    version_added_collection: networktocode.nautobot

flatten_config_context:
    default: false
    description:
    - If I(config_context) is enabled, by default it's added as a host var named config_context.
    - If flatten_config_context is set to True, the config context variables will be added
      directly to the host instead.
    type: boolean
    version_added: 1.0.0
    version_added_collection: networktocode.nautobot

flatten_local_context_data:
    default: false
    description:
    - If I(local_context_data) is enabled, by default it's added as a host var named local_context_data.
    - If flatten_local_context_data is set to True, the config context variables will
      be added directly to the host instead.
    type: boolean
    version_added: 1.0.0
    version_added_collection: networktocode.nautobot