networktocode.nautobot.ip_address module – Creates or removes IP addresses from Nautobot¶
Note
This module is part of the networktocode.nautobot collection (version 3.4.0).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install networktocode.nautobot
.
To use it in a playbook, specify: networktocode.nautobot.ip_address
.
New in version 1.0.0: of networktocode.nautobot
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 |
---|---|
Required if state is |
|
Definition of the assigned object. |
|
The device the interface is attached to. |
|
The name of the interface |
|
The virtual machine the interface is attached to. |
|
must exist in Nautobot |
|
The description of the interface |
|
Hostname or FQDN |
|
The inside IP address this IP is assigned to |
|
|
|
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. |
|
The role of the IP address Choices:
|
|
Choices:
|
|
The status of the IP address Required if state=present and does not exist yet |
|
Any tags that the IP address may need to be associated with |
|
The tenant that the device will be assigned to |
|
The token created within Nautobot to authorize API access |
|
URL of the Nautobot instance resolvable by Ansible control host |
|
If Default: “yes” |
|
VRF that IP address is associated with |
Notes¶
Note
Tags should be defined as a YAML list
This should be ran with connection
local
and hostslocalhost
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: Get a new available IP inside 192.168.1.0/24
networktocode.nautobot.ip_address:
url: http://nautobot.local
token: thisIsMyToken
prefix: 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
networktocode.nautobot.ip_address:
url: http://nautobot.local
token: thisIsMyToken
family: 4
address: 192.168.1.20
vrf: Test
tenant: Test Tenant
status: Reserved
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
family: 4
address: 192.168.1.30
vrf: Test
nat_inside:
address: 192.168.1.20
vrf: Test
assigned_object:
name: GigabitEthernet1
device: test100
- name: Ensure that an IP inside 192.168.1.0/24 is attached to GigabitEthernet1
networktocode.nautobot.ip_address:
url: http://nautobot.local
token: thisIsMyToken
prefix: 192.168.1.0/24
vrf: Test
assigned_object:
name: GigabitEthernet1
device: test100
state: present
- name: Attach a new available IP of 192.168.1.0/24 to GigabitEthernet1
networktocode.nautobot.ip_address:
url: http://nautobot.local
token: thisIsMyToken
prefix: 192.168.1.0/24
vrf: Test
assigned_object:
name: GigabitEthernet1
device: test100
state: new
Return Values¶
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
Serialized object as created or already existent within Nautobot Returned: on creation |
|
Message indicating failure or info about what has been achieved Returned: always |