diff --git a/plugins/modules/ip_info.py b/plugins/modules/ip_info.py index 2f4ce750..7f9a53d9 100644 --- a/plugins/modules/ip_info.py +++ b/plugins/modules/ip_info.py @@ -70,7 +70,9 @@ def __init__(self) -> None: def _get_ip(self, address: str) -> IPAddress: try: - return self.client.load(IPAddress, address) + 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( diff --git a/tests/integration/targets/instance_config_vpc/tasks/main.yaml b/tests/integration/targets/instance_config_vpc/tasks/main.yaml index 437c7794..4388ff6f 100644 --- a/tests/integration/targets/instance_config_vpc/tasks/main.yaml +++ b/tests/integration/targets/instance_config_vpc/tasks/main.yaml @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 "" }}' diff --git a/tests/integration/targets/vpc_basic/tasks/main.yaml b/tests/integration/targets/vpc_basic/tasks/main.yaml index f3b92967..d7ae34a5 100644 --- a/tests/integration/targets/vpc_basic/tasks/main.yaml +++ b/tests/integration/targets/vpc_basic/tasks/main.yaml @@ -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 @@ -16,13 +16,13 @@ that: - create_vpc.changed - create_vpc.vpc.label == 'ansible-test-{{ r }}' - - create_vpc.vpc.region == 'us-east' + - create_vpc.vpc.region == 'us-mia' - create_vpc.vpc.description == 'test description' - name: Create a VPC with invalid label linode.cloud.vpc: label: 'test-vpc!!' - region: us-east + region: us-mia description: test description state: present register: invalid_label @@ -31,7 +31,7 @@ - name: Update the VPC linode.cloud.vpc: label: 'ansible-test-{{ r }}' - region: us-east + region: us-mia description: test description updated state: present register: update_vpc @@ -46,7 +46,7 @@ - name: Update the VPC with invalid label linode.cloud.vpc: label: 'ansible-test-{{ r }}!' - region: us-east + region: us-mia description: test description updated state: present register: modify_vpc @@ -55,7 +55,7 @@ - name: Don't update the VPC linode.cloud.vpc: label: 'ansible-test-{{ r }}' - region: us-east + region: us-mia description: test description updated state: present register: no_update_vpc @@ -115,4 +115,4 @@ LINODE_API_VERSION: '{{ api_version }}' # Temporary testing override; remove before merge to dev - REQUESTS_CA_BUNDLE: '{{ ca_file }}' + REQUESTS_CA_BUNDLE: '{{ ca_file or "" }}' diff --git a/tests/integration/targets/vpc_subnet/tasks/main.yaml b/tests/integration/targets/vpc_subnet/tasks/main.yaml index e77547c9..2e1eddea 100644 --- a/tests/integration/targets/vpc_subnet/tasks/main.yaml +++ b/tests/integration/targets/vpc_subnet/tasks/main.yaml @@ -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 @@ -16,7 +16,7 @@ that: - create_vpc.changed - create_vpc.vpc.label == 'ansible-test-{{ r }}' - - create_vpc.vpc.region == 'us-east' + - create_vpc.vpc.region == 'us-mia' - create_vpc.vpc.description == 'test description' - name: Create a subnet @@ -100,4 +100,4 @@ LINODE_API_VERSION: '{{ api_version }}' # Temporary testing override; remove before merge to dev - REQUESTS_CA_BUNDLE: '{{ ca_file }}' + REQUESTS_CA_BUNDLE: '{{ ca_file or "" }}'