equinix / equinix.metal / 1.4.1 / module / ip_subnet Assign IP subnet to a bare metal server. | "added in version" 1.4.0 of equinix.metal" Authors: Tomas Karasek (@t0mk) <tom.to.the.k@gmail.com>, Nurfet Becirevic (@nurfet-becirevic) <nurfet.becirevic@gmail.com>, Jason DeTiberus (@detiber) <jdetiberus@equinix.com>equinix.metal.ip_subnet (1.4.1) — module
Install with ansible-galaxy collection install equinix.metal:==1.4.1
collections: - name: equinix.metal version: 1.4.1
Assign or unassign IPv4 or IPv6 subnets to or from a device in Equinix Metal.
IPv4 subnets must come from already reserved block.
IPv6 subnets must come from publicly routable /56 block from your project.
See U(https://metal.equinix.com/developers/docs/networking/elastic-ips/) for more info on IP block reservation.
# 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
cidr: aliases: - name description: - IPv4 or IPv6 subnet which you want to manage. It must come from a reserved block for your project in the Packet Host. required: true type: str state: choices: - present - absent default: present description: - Desired state of the IP subnet on the specified device. - With state == C(present), you must specify either hostname or device_id. Subnet with given CIDR will then be assigned to the specified device. - With state == C(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. type: str hostname: description: - A hostname of a device to/from which to assign/remove a subnet. required: false type: str api_token: aliases: - auth_token description: - 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. required: true type: str device_id: description: - UUID of a device to/from which to assign/remove a subnet. required: false type: str project_id: description: - UUID of a project of the device to/from which to assign/remove a subnet. required: false type: str
changed: description: True if an IP address assignments were altered in any way (created or removed). returned: success sample: true type: bool device_id: description: UUID of the device associated with the specified IP address. returned: success type: str subnet: description: Dict with data about the handled IP subnet. returned: success 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 type: dict