mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-09 23:00:02 -07:00
Bug fixes for gcp_compute_subnetwork (#42822)
This commit is contained in:
parent
97b3845e89
commit
f5f0d16516
2 changed files with 85 additions and 71 deletions
|
@ -15,39 +15,33 @@
|
|||
# Pre-test setup
|
||||
- name: create a network
|
||||
gcp_compute_network:
|
||||
name: 'network-subnetwork'
|
||||
name: "network-subnetwork"
|
||||
auto_create_subnetworks: true
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
scopes:
|
||||
- https://www.googleapis.com/auth/compute
|
||||
state: present
|
||||
register: network
|
||||
- name: delete a subnetwork
|
||||
gcp_compute_subnetwork:
|
||||
name: 'ansiblenet'
|
||||
region: 'us-west1'
|
||||
name: ansiblenet
|
||||
region: us-west1
|
||||
network: "{{ network }}"
|
||||
ip_cidr_range: '172.16.0.0/16'
|
||||
ip_cidr_range: 172.16.0.0/16
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
scopes:
|
||||
- https://www.googleapis.com/auth/compute
|
||||
state: absent
|
||||
#----------------------------------------------------------
|
||||
- name: create a subnetwork
|
||||
gcp_compute_subnetwork:
|
||||
name: 'ansiblenet'
|
||||
region: 'us-west1'
|
||||
name: ansiblenet
|
||||
region: us-west1
|
||||
network: "{{ network }}"
|
||||
ip_cidr_range: '172.16.0.0/16'
|
||||
ip_cidr_range: 172.16.0.0/16
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
scopes:
|
||||
- https://www.googleapis.com/auth/compute
|
||||
state: present
|
||||
register: result
|
||||
- name: assert changed is true
|
||||
|
@ -55,18 +49,31 @@
|
|||
that:
|
||||
- result.changed == true
|
||||
- "result.kind == 'compute#subnetwork'"
|
||||
# ----------------------------------------------------------------------------
|
||||
- name: create a subnetwork that already exists
|
||||
gcp_compute_subnetwork:
|
||||
name: 'ansiblenet'
|
||||
region: 'us-west1'
|
||||
network: "{{ network }}"
|
||||
ip_cidr_range: '172.16.0.0/16'
|
||||
- name: verify that subnetwork was created
|
||||
gcp_compute_subnetwork_facts:
|
||||
filters:
|
||||
- name = ansiblenet
|
||||
region: us-west1
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
scopes:
|
||||
- https://www.googleapis.com/auth/compute
|
||||
register: results
|
||||
- name: verify that command succeeded
|
||||
assert:
|
||||
that:
|
||||
- results['items'] | length == 1
|
||||
# ----------------------------------------------------------------------------
|
||||
- name: create a subnetwork that already exists
|
||||
gcp_compute_subnetwork:
|
||||
name: ansiblenet
|
||||
region: us-west1
|
||||
network: "{{ network }}"
|
||||
ip_cidr_range: 172.16.0.0/16
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
state: present
|
||||
register: result
|
||||
- name: assert changed is false
|
||||
|
@ -77,15 +84,13 @@
|
|||
#----------------------------------------------------------
|
||||
- name: delete a subnetwork
|
||||
gcp_compute_subnetwork:
|
||||
name: 'ansiblenet'
|
||||
region: 'us-west1'
|
||||
name: ansiblenet
|
||||
region: us-west1
|
||||
network: "{{ network }}"
|
||||
ip_cidr_range: '172.16.0.0/16'
|
||||
ip_cidr_range: 172.16.0.0/16
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
scopes:
|
||||
- https://www.googleapis.com/auth/compute
|
||||
state: absent
|
||||
register: result
|
||||
- name: assert changed is true
|
||||
|
@ -93,18 +98,31 @@
|
|||
that:
|
||||
- result.changed == true
|
||||
- result.has_key('kind') == False
|
||||
# ----------------------------------------------------------------------------
|
||||
- name: delete a subnetwork that does not exist
|
||||
gcp_compute_subnetwork:
|
||||
name: 'ansiblenet'
|
||||
region: 'us-west1'
|
||||
network: "{{ network }}"
|
||||
ip_cidr_range: '172.16.0.0/16'
|
||||
- name: verify that subnetwork was deleted
|
||||
gcp_compute_subnetwork_facts:
|
||||
filters:
|
||||
- name = ansiblenet
|
||||
region: us-west1
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
scopes:
|
||||
- https://www.googleapis.com/auth/compute
|
||||
register: results
|
||||
- name: verify that command succeeded
|
||||
assert:
|
||||
that:
|
||||
- results['items'] | length == 0
|
||||
# ----------------------------------------------------------------------------
|
||||
- name: delete a subnetwork that does not exist
|
||||
gcp_compute_subnetwork:
|
||||
name: ansiblenet
|
||||
region: us-west1
|
||||
network: "{{ network }}"
|
||||
ip_cidr_range: 172.16.0.0/16
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
state: absent
|
||||
register: result
|
||||
- name: assert changed is false
|
||||
|
@ -116,12 +134,10 @@
|
|||
# Post-test teardown
|
||||
- name: delete a network
|
||||
gcp_compute_network:
|
||||
name: 'network-subnetwork'
|
||||
name: "network-subnetwork"
|
||||
auto_create_subnetworks: true
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
scopes:
|
||||
- https://www.googleapis.com/auth/compute
|
||||
state: absent
|
||||
register: network
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue