community / community.general / 1.3.14 / module / packet_ip_subnet Assign IP subnet to a bare metal server. | "added in version" 0.2.0 of community.general" Authors: Tomas Karasek (@t0mk) <tom.to.the.k@gmail.com>, Nurfet Becirevic (@nurfet-becirevic) <nurfet.becirevic@gmail.com>community.general.packet_ip_subnet (1.3.14) — module
Install with ansible-galaxy collection install community.general:==1.3.14
collections: - name: community.general version: 1.3.14
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 U(https://support.packet.com/kb/articles/elastic-ips) for more info on IP block reservation.
# 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
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 device_id: description: - UUID of a device to/from which to assign/remove a subnet. required: false type: str auth_token: description: - Packet API token. You can also supply it in env var C(PACKET_API_TOKEN). type: str project_id: description: - UUID of a project of the device to/from which to assign/remove a subnet. type: str device_count: default: 100 description: - The number of devices to retrieve from the project. The max allowed value is 1000. - See U(https://www.packet.com/developers/api/#retrieve-all-devices-of-a-project) for more info. type: int
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