TPT-4284:ansible implement support for reserved ip for ipv4#788
Conversation
Release v0.41.1
Release v0.42.0
Release v0.43.0
Release v0.44.0
Release v0.45.0
There was a problem hiding this comment.
Pull request overview
Adds first-class support for Linode Reserved IPv4 addresses to the linode.cloud Ansible collection, including new modules for managing/querying reserved IPs and create-time assignment support for Instances and NodeBalancers.
Changes:
- Introduces
reserved_ip,reserved_ip_info, andreserved_ip_listmodules plus associated doc fragments and integration tests. - Adds create-only
ipv4parameters toinstanceandnodebalancerto allow assigning a reserved IPv4 at creation time. - Updates IP-related doc fragments/docs to include new Reserved IP fields and pins
linode_api4to a Git ref.
Reviewed changes
Copilot reviewed 22 out of 23 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/integration/targets/reserved_ip_basic/tasks/main.yaml | New integration test covering reserve/update-tags/delete flow |
| tests/integration/targets/reserved_ip_info/tasks/main.yaml | New integration test for querying a reserved IP by address |
| tests/integration/targets/reserved_ip_list/tasks/main.yaml | New integration test for listing reserved IPs |
| tests/integration/targets/instance_reserved_ip/tasks/main.yaml | New integration test for assigning a reserved IP on instance create |
| tests/integration/targets/nodebalancer_reserved_ip/tasks/main.yaml | New integration test for assigning a reserved IP on nodebalancer create |
| requirements.txt | Switches linode_api4 dependency to a Git URL |
| plugins/modules/reserved_ip.py | New module to create/update tags/delete reserved IPs |
| plugins/modules/reserved_ip_info.py | New info module to fetch a reserved IP by address |
| plugins/modules/reserved_ip_list.py | New list module to enumerate reserved IPs |
| plugins/modules/instance.py | Adds create-only ipv4 param and excludes it from update reconciliation |
| plugins/modules/nodebalancer.py | Adds create-only ipv4 param and excludes it from update reconciliation |
| plugins/module_utils/doc_fragments/reserved_ip.py | Doc fragment samples/examples for reserved_ip |
| plugins/module_utils/doc_fragments/reserved_ip_info.py | Doc fragment samples/examples for reserved_ip_info |
| plugins/module_utils/doc_fragments/reserved_ip_list.py | Doc fragment samples/examples for reserved_ip_list |
| plugins/module_utils/doc_fragments/instance.py | Adds instance example using reserved IPv4 |
| plugins/module_utils/doc_fragments/nodebalancer.py | Adds nodebalancer example using reserved IPv4 |
| plugins/module_utils/doc_fragments/ip.py | Updates IP sample fields |
| plugins/module_utils/doc_fragments/ip_info.py | Updates IP info sample fields |
| docs/modules/instance.md | Generated docs updated for new instance param |
| docs/modules/nodebalancer.md | Generated docs updated for new nodebalancer param |
| docs/modules/ip_info.md | Generated docs updated for new IP fields |
| docs/modules/ip_rdns.md | Generated docs updated for new IP fields |
| README.md | Adds module links for reserved_ip*, but docs appear missing |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 25 out of 26 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Some findings:
These are mostly for discussion, the overall changes looks great! |
| | `type` | <center>`str`</center> | <center>Optional</center> | The type of address you are requesting. Only IPv4 addresses may be allocated through this operation. **(Choices: `ipv4`)** | | ||
| | `address` | <center>`str`</center> | <center>Optional</center> | The IP address to delete. **(Conflicts With: `linode_id`,`public`,`type`)** | | ||
| | `address` | <center>`str`</center> | <center>Optional</center> | The IP address to update or delete. Required when updating an existing IP (e.g., promoting to reserved) or when deleting (state=absent). **(Conflicts With: `linode_id`,`public`,`type`)** | | ||
| | `reserved` | <center>`bool`</center> | <center>Optional</center> | Whether this IP address should be reserved. Setting to true promotes an existing allocated IP to a reserved IP via PUT /networking/ips/{address}. Requires the address parameter. | |
There was a problem hiding this comment.
API Spec says that "when 'reserved' is true, one of 'region' or 'linode_id' must be set" so shouldn't we also add a region as one of optional fields?
|
What about |
|
There are some conflicts to be resolved but generally it looks good to me |
|
@mgwoj, I've just noticed that PR goes directly to |
…ent-support-for-reserved-ip-for-ipv4
| @@ -92,10 +141,135 @@ def __init__(self) -> None: | |||
| ], | |||
There was a problem hiding this comment.
The required_together value might need to be updated to properly account for the new cases. Not sure if this will make a difference in practice though 🤔
| def _handle_present(self) -> None: | ||
| params = filter_null_values(self.module.params) | ||
| address = params.get("address") | ||
|
|
||
| if address is not None: | ||
| self._handle_update_existing_ip(address, params) | ||
| return | ||
|
|
||
| linode_id = params.get("linode_id") | ||
| public = params.get("public") | ||
| region = params.get("region") | ||
| reserved = params.get("reserved") | ||
|
|
||
| if region is not None and reserved: | ||
| # Allocate a new reserved IP via POST /networking/ips | ||
| ip_type = params.get("type", "ipv4") | ||
| try: |
| if linode_id is None: | ||
| self.fail( | ||
| msg="linode_id, public, and type are required when creating a new IP" |
📝 Description
Implements support for Linode Reserved IPv4 addresses in
ansible_linode.New modules:
reserved_ip — create, update tags, and delete reserved IP addresses
reserved_ip_info — retrieve details for a single reserved IP by address
reserved_ip_list — list and filter all reserved IPs on an account
Updated modules:
instance — new ipv4 parameter to assign a reserved IP at creation time (create-only; excluded from update path to prevent handle_updates errors)
nodebalancer — new ipv4 parameter to assign a reserved IP at creation time (create-only; excluded from create params when None and popped before handle_updates)
Other changes:
Updated ip_info and ip doc fragments with new fields: reserved, tags, interface_id, assigned_entity, vpc_nat_1_1
Added integration tests: reserved_ip_basic, reserved_ip_info, reserved_ip_list, instance_reserved_ip, nodebalancer_reserved_ip
Pinned requirements.txt to linode_api4 @ git+https://github.com/linode/linode_api4-python.git@proj/reserved-ips
Generated/updated docs via make gendocs
✔️ How to Test