Skip to content
This repository has been archived by the owner on Sep 10, 2024. It is now read-only.

Latest commit

 

History

History
266 lines (228 loc) · 10.6 KB

equinix.metal.ip_subnet_module.rst

File metadata and controls

266 lines (228 loc) · 10.6 KB

equinix.metal.ip_subnet

Assign IP subnet to a bare metal server.

Version added: 1.4.0

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

  • packet-python >= 1.43.1
Parameter Choices/Defaults Comments
api_token
string / required
The Equinix Metal API token to use
If not set, then the value of the METAL_API_TOKEN, PACKET_API_TOKEN, or PACKET_TOKEN environment variable is used.

aliases: auth_token
cidr
string / required
IPv4 or IPv6 subnet which you want to manage. It must come from a reserved block for your project in the Packet Host.

aliases: name
device_id
string
UUID of a device to/from which to assign/remove a subnet.
hostname
string
A hostname of a device to/from which to assign/remove a subnet.
project_id
string
UUID of a project of the device to/from which to assign/remove a subnet.
state
string
    Choices:
  • present ←
  • absent
Desired state of the IP subnet on the specified device.
With state == present, you must specify either hostname or device_id. Subnet with given CIDR will then be assigned to the specified device.
With state == absent, you can specify either hostname or device_id. The subnet will be removed from specified devices.
If you leave both hostname and device_id empty, the subnet will be removed from any device it's assigned to.

# All the examples assume that you have your Equinix Metal API token in env var METAL_API_TOKEN.
# You can also pass it to the api_token parameter of the module instead.

- name: Create 1 device and assign an arbitrary public IPv4 subnet to it
  hosts: localhost
  tasks:

  - equinix.metal.device:
      project_id: 89b497ee-5afc-420a-8fb5-56984898f4df
      hostnames: myserver
      operating_system: ubuntu_20_04
      plan: baremetal_0
      facility: sjc1
      state: active

# Pick an IPv4 address from a block allocated to your project.

  - equinix.metal.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:
  - equinix.metal.ip_subnet:
      project_id: 89b497ee-5afc-420a-8fb5-56984898f4df
      cidr: "147.75.201.78/32"
      state: absent

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

Key Returned Description
changed
boolean
success
True if an IP address assignments were altered in any way (created or removed).

Sample:
True
device_id
string
success
UUID of the device associated with the specified IP address.

subnet
dictionary
success
Dict with data about the handled IP subnet.

Sample:
{'address': '147.75.90.241', 'address_family': 4, 'assigned_to': {'href': '/devices/61f9aa5e-0530-47f5-97c2-113828e61ed0'}, 'cidr': 31, 'created_at': '2017-08-07T15:15:30Z', 'enabled': True, 'gateway': '147.75.90.240', 'href': '/ips/31eda960-0a16-4c0f-b196-f3dc4928529f', 'id': '1eda960-0a16-4c0f-b196-f3dc4928529f', 'manageable': True, 'management': True, 'netmask': '255.255.255.254', 'network': '147.75.90.240', 'public': True}


Authors