networktocode.nautobot.ip_address module – Creates or removes IP addresses from Nautobot

Note

This module is part of the networktocode.nautobot collection (version 5.1.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.ip_address.

New in networktocode.nautobot 1.0.0

Synopsis

  • Creates or removes IP addresses from Nautobot

Requirements

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

  • pynautobot

Parameters

Parameter

Comments

address

string

added in networktocode.nautobot 3.0.0

Required if state is present

api_version

string

added in networktocode.nautobot 4.1.0

API Version Nautobot REST API

custom_fields

dictionary

added in networktocode.nautobot 3.0.0

Must exist in Nautobot and in key/value format

description

string

added in networktocode.nautobot 3.0.0

The description of the interface

dns_name

string

added in networktocode.nautobot 3.0.0

Hostname or FQDN

namespace

string

added in networktocode.nautobot 5.0.0

namespace that IP address is associated with. IPs are unique per namespaces.

Default: :ansible-option-default:`"Global"`

nat_inside

any

added in networktocode.nautobot 3.0.0

The inside IP address this IP is assigned to

parent

any

added in networktocode.nautobot 3.0.0

With state new, it will force to get the next available IP in

this prefix. Required if state is present or new when no address is given. Unused if an address is specified.

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.

role

any

added in networktocode.nautobot 3.0.0

The role of the IP address

state

string

Use present, new or absent for adding, force adding or removing.

present will check if the IP is already created, and return it if true. new will force to create it anyway (useful for anycasts, for example).

Choices:

status

any

added in networktocode.nautobot 3.0.0

The status of the IP address

Required if state=present and does not exist yet

tags

list / elements=any

added in networktocode.nautobot 3.0.0

Any tags that this item may need to be associated with

tenant

any

added in networktocode.nautobot 3.0.0

The tenant that the device will be assigned to

token

string / required

The token created within Nautobot to authorize API access

type

string

added in networktocode.nautobot 5.0.0

url

string / required

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

validate_certs

any

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

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

Notes

Note

  • Tags should be defined as a YAML list

  • This should be ran with connection local and hosts localhost

Examples

- name: "Test Nautobot IP address module"
  connection: local
  hosts: localhost
  gather_facts: False

  tasks:
    - name: Create IP address within Nautobot with only required information
      networktocode.nautobot.ip_address:
        url: http://nautobot.local
        token: thisIsMyToken
        address: 192.168.1.10
        status: active
        state: present
    - name: Force to create (even if it already exists) the IP
      networktocode.nautobot.ip_address:
        url: http://nautobot.local
        token: thisIsMyToken
        address: 192.168.1.10
        state: new
    - name: Create the same IP under another namespace
      networktocode.nautobot.ip_address:
        url: http://nautobot.local
        token: thisIsMyToken
        address: 192.168.1.10
        namespace: MyNewNamespace
        state: new
    - name: Get a new available IP inside 192.168.1.0/24
      networktocode.nautobot.ip_address:
        url: http://nautobot.local
        token: thisIsMyToken
        parent: 192.168.1.0/24
        state: new
    - name: Delete IP address within nautobot
      networktocode.nautobot.ip_address:
        url: http://nautobot.local
        token: thisIsMyToken
        address: 192.168.1.10
        state: absent
    - name: Create IP address with several specified options in namespace Private
      networktocode.nautobot.ip_address:
        url: http://nautobot.local
        token: thisIsMyToken
        address: 192.168.1.20
        tenant: Test Tenant
        status: Reserved
        namespace: Private
        role: Loopback
        description: Test description
        tags:
          - Schnozzberry
        state: present
    - name: Create IP address and assign a nat_inside IP
      networktocode.nautobot.ip_address:
        url: http://nautobot.local
        token: thisIsMyToken
        address: 192.168.1.30
        nat_inside:
          address: 192.168.1.20

Return Values

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

Key

Description

ip_address

dictionary

Serialized object as created or already existent within Nautobot

Returned: on creation

msg

string

Message indicating failure or info about what has been achieved

Returned: always

Authors

  • Mikhail Yohman (@FragmentedPacket)

  • Anthony Ruhier (@Anthony25)