community.general.packet_ip_subnet module – Assign IP subnet to a bare metal server
Note
This module is part of the community.general collection (version 10.0.1).
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 community.general
.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: community.general.packet_ip_subnet
.
New in community.general 0.2.0
Synopsis
Assign or unassign IPv4 or IPv6 subnets to or from a device in the Packet host.
IPv4 subnets must come from already reserved block.
IPv6 subnets must come from publicly routable /56 block from your project.
See https://support.packet.com/kb/articles/elastic-ips for more info on IP block reservation.
Requirements
The below requirements are needed on the host that executes this module.
packet-python >= 1.35
Parameters
Parameter |
Comments |
---|---|
Packet API token. You can also supply it in environment variable |
|
IPv4 or IPv6 subnet which you want to manage. It must come from a reserved block for your project in the Packet Host. |
|
The number of devices to retrieve from the project. The max allowed value is 1000. See https://www.packet.com/developers/api/#retrieve-all-devices-of-a-project for more info. Default: |
|
UUID of a device to/from which to assign/remove a subnet. |
|
A hostname of a device to/from which to assign/remove a subnet. |
|
UUID of a project of the device to/from which to assign/remove a subnet. |
|
Desired state of the IP subnet on the specified device. With With If you leave both Choices:
|
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: full |
Can run in |
|
Support: none |
Will return details on what has changed (or possibly needs changing in |
Examples
# All the examples assume that you have your Packet API token in env var PACKET_API_TOKEN.
# You can also pass it to the auth_token parameter of the module instead.
- name: Create 1 device and assign an arbitrary public IPv4 subnet to it
hosts: localhost
tasks:
- packet_device:
project_id: 89b497ee-5afc-420a-8fb5-56984898f4df
hostnames: myserver
operating_system: ubuntu_16_04
plan: baremetal_0
facility: sjc1
state: active
# Pick an IPv4 address from a block allocated to your project.
- community.general.packet_ip_subnet:
project_id: 89b497ee-5afc-420a-8fb5-56984898f4df
hostname: myserver
cidr: "147.75.201.78/32"
# Release IP address 147.75.201.78
- name: Unassign IP address from any device in your project
hosts: localhost
tasks:
- community.general.packet_ip_subnet:
project_id: 89b497ee-5afc-420a-8fb5-56984898f4df
cidr: "147.75.201.78/32"
state: absent
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
True if an IP address assignments were altered in any way (created or removed). Returned: success Sample: |
|
UUID of the device associated with the specified IP address. Returned: success |
|
Dict with data about the handled IP subnet. Returned: success Sample: |