Skip to content

Commit

Permalink
new: add vpc fields to ip_info (#434)
Browse files Browse the repository at this point in the history
* Bump types-requests from 2.31.0.2 to 2.31.0.10 (#431)

Bumps [types-requests](https://github.com/python/typeshed) from 2.31.0.2 to 2.31.0.10.
- [Commits](https://github.com/python/typeshed/commits)

---
updated-dependencies:
- dependency-name: types-requests
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* make deps upgrade (#432)

* adding vpc fields

* Explicitly handle none values for testing CA (#435)

* merging to fix errors

* adding tests for ip_info

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Lena Garber <114949949+lgarber-akamai@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 13, 2023
1 parent d98a9b8 commit 5a81b5d
Show file tree
Hide file tree
Showing 75 changed files with 141 additions and 91 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ install: build
ansible-galaxy collection install *.tar.gz --force -p $(COLLECTIONS_PATH)

deps:
pip install --upgrade -r requirements.txt -r requirements-dev.txt
pip install -r requirements.txt -r requirements-dev.txt --upgrade

lint:
pylint plugins
Expand Down
7 changes: 6 additions & 1 deletion docs/modules/ip_info.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ Get info about a Linode IP.
"rdns": "test.example.org",
"region": "us-east",
"subnet_mask": "255.255.255.0",
"type": "ipv4"
"type": "ipv4",
"vpc_nat_1_1": {
"vpc_id": 242,
"subnet_id": 194,
"address": "139.144.244.36",
}
}
```
- See the [Linode API response documentation](https://www.linode.com/docs/api/networking/#ip-address-view__responses) for a list of returned fields
Expand Down
7 changes: 6 additions & 1 deletion docs/modules/ip_rdns.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ Manage a Linode IP address's rDNS.
"rdns": "test.example.org",
"region": "us-east",
"subnet_mask": "255.255.255.0",
"type": "ipv4"
"type": "ipv4",
"vpc_nat_1_1": {
"vpc_id": 242,
"subnet_id": 194,
"address": "139.144.244.36",
}
}
```
- See the [Linode API response documentation](https://www.linode.com/docs/api/profile/#ip-address-rdns-update) for a list of returned fields
Expand Down
7 changes: 6 additions & 1 deletion plugins/module_utils/doc_fragments/ip_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,10 @@
"rdns": "test.example.org",
"region": "us-east",
"subnet_mask": "255.255.255.0",
"type": "ipv4"
"type": "ipv4",
"vpc_nat_1_1": {
"vpc_id": 242,
"subnet_id": 194,
"address": "139.144.244.36",
}
}''']
6 changes: 3 additions & 3 deletions plugins/modules/ip_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

"""This module allows users to retrieve information about a Linode IP address."""


from __future__ import absolute_import, division, print_function

from typing import Any, Optional
Expand Down Expand Up @@ -70,15 +71,14 @@ def __init__(self) -> None:
def _get_ip(self, address: str) -> IPAddress:
try:
ip_addr = IPAddress(self.client, address)

ip_addr._api_get()

return ip_addr
except Exception as exception:
self.fail(
msg="failed to get IP address {0}: {1}".format(
address, exception
)
),
exception=exception,
)

def exec_module(self, **kwargs: Any) -> Optional[dict]:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# linode-api4>=5.9.0
git+https://github.com/linode/linode_api4-python@proj/vpc
polling>=0.3.2
types-requests==2.31.0.2
types-requests==2.31.0.10
ansible-specdoc>=0.0.14
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'
2 changes: 1 addition & 1 deletion tests/integration/targets/domain_basic/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'
3 changes: 2 additions & 1 deletion tests/integration/targets/domain_list/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,5 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'

3 changes: 2 additions & 1 deletion tests/integration/targets/domain_record/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -245,4 +245,5 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'

3 changes: 2 additions & 1 deletion tests/integration/targets/domain_zone_file/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'

2 changes: 1 addition & 1 deletion tests/integration/targets/event_list/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'
2 changes: 1 addition & 1 deletion tests/integration/targets/firewall_basic/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -283,4 +283,4 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'
2 changes: 1 addition & 1 deletion tests/integration/targets/firewall_device/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,6 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'


2 changes: 1 addition & 1 deletion tests/integration/targets/firewall_icmp/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'
3 changes: 2 additions & 1 deletion tests/integration/targets/firewall_list/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,5 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'

3 changes: 2 additions & 1 deletion tests/integration/targets/firewall_update/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -887,4 +887,5 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'

2 changes: 1 addition & 1 deletion tests/integration/targets/image_basic/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'
2 changes: 1 addition & 1 deletion tests/integration/targets/image_list/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'
3 changes: 2 additions & 1 deletion tests/integration/targets/image_upload/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'

Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,4 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'
3 changes: 2 additions & 1 deletion tests/integration/targets/instance_basic/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,5 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'

3 changes: 2 additions & 1 deletion tests/integration/targets/instance_booted/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,5 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'

Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,4 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,4 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'
23 changes: 18 additions & 5 deletions tests/integration/targets/instance_config_vpc/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- name: Create a VPC
linode.cloud.vpc:
label: 'ansible-test-{{ r }}'
region: us-east
region: us-mia
description: test description
state: present
register: create_vpc
Expand All @@ -22,7 +22,7 @@
- name: Create a Linode instance with interface
linode.cloud.instance:
label: 'ansible-test-{{ r }}'
region: us-east
region: us-mia
type: g6-standard-1
disks:
- label: test-disk
Expand Down Expand Up @@ -58,10 +58,23 @@
- create_instance.configs[0].interfaces[0].ipv4.nat_1_1 == create_instance.instance.ipv4[0]
- create_instance.configs[0].interfaces[0].ipv4.vpc == '10.0.0.3'

- name: Get ip_info about the instance's vpc ip
linode.cloud.ip_info:
address: '{{ create_instance.instance.ipv4[0] }}'
register: ip_info

- name: Assert ip_info matches vpc settings
assert:
that:
- ip_info.ip.address == create_instance.instance.ipv4[0]
- ip_info.ip.vpc_nat_1_1.address == '10.0.0.3'
- ip_info.ip.vpc_nat_1_1.vpc_id == create_vpc.vpc.id
- ip_info.ip.vpc_nat_1_1.subnet_id == create_subnet.subnet.id

- name: Update the config interfaces
linode.cloud.instance:
label: 'ansible-test-{{ r }}'
region: us-east
region: us-mia
type: g6-standard-1
disks:
- label: test-disk
Expand Down Expand Up @@ -103,7 +116,7 @@
- name: Don't change the config interfaces
linode.cloud.instance:
label: 'ansible-test-{{ r }}'
region: us-east
region: us-mia
type: g6-standard-1
disks:
- label: test-disk
Expand Down Expand Up @@ -158,4 +171,4 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
REQUESTS_CA_BUNDLE: '{{ ca_file }}'
REQUESTS_CA_BUNDLE: '{{ ca_file or "" }}'
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
<<<<<<< HEAD
=======
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'

>>>>>>> 3ee3aabf6b1a20187f78b4f2371ab8902cc76b7e
3 changes: 2 additions & 1 deletion tests/integration/targets/instance_list/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,5 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'

3 changes: 2 additions & 1 deletion tests/integration/targets/instance_metadata/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'

2 changes: 1 addition & 1 deletion tests/integration/targets/instance_reboot/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'
2 changes: 1 addition & 1 deletion tests/integration/targets/instance_timeout/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'

3 changes: 2 additions & 1 deletion tests/integration/targets/instance_type_list/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'

2 changes: 1 addition & 1 deletion tests/integration/targets/ip_assign/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'


3 changes: 2 additions & 1 deletion tests/integration/targets/ip_info/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'

4 changes: 3 additions & 1 deletion tests/integration/targets/ip_rdns/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,6 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'


2 changes: 1 addition & 1 deletion tests/integration/targets/ip_share/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@
LINODE_UA_PREFIX: '{{ ua_prefix }}'
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'
3 changes: 2 additions & 1 deletion tests/integration/targets/ipv6_range_info/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'

3 changes: 2 additions & 1 deletion tests/integration/targets/lke_cluster_basic/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,5 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'

Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,5 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'

3 changes: 2 additions & 1 deletion tests/integration/targets/lke_version_list/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'

2 changes: 1 addition & 1 deletion tests/integration/targets/mysql_basic/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,4 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'
2 changes: 1 addition & 1 deletion tests/integration/targets/mysql_complex/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@
LINODE_API_TOKEN: '{{ api_token }}'
LINODE_API_URL: '{{ api_url }}'
LINODE_API_VERSION: '{{ api_version }}'
LINODE_CA: '{{ ca_file }}'
LINODE_CA: '{{ ca_file or "" }}'
Loading

0 comments on commit 5a81b5d

Please sign in to comment.