mirror of
https://github.com/ansible-collections/google.cloud.git
synced 2025-07-30 16:41:28 -07:00
Complete test cases with default option
Signed-off-by: Jorge Gallegos <jgallego@redhat.com>
This commit is contained in:
parent
24bba779d8
commit
d980418ea7
2 changed files with 83 additions and 117 deletions
|
@ -4,30 +4,6 @@
|
|||
|
||||
- name: Test nic_type scenarios
|
||||
block:
|
||||
- name: Create disk for virtio
|
||||
google.cloud.gcp_compute_disk:
|
||||
name: "{{ resource_prefix }}-virtio"
|
||||
size_gb: 50
|
||||
source_image: projects/rhel-cloud/global/images/rhel-9-v20250513
|
||||
zone: us-central1-a
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
||||
state: present
|
||||
register: _virtio_disk
|
||||
|
||||
- name: Create disk for gVNIC
|
||||
google.cloud.gcp_compute_disk:
|
||||
name: "{{ resource_prefix }}-gvnic"
|
||||
size_gb: 50
|
||||
source_image: projects/rhel-cloud/global/images/rhel-9-v20250513
|
||||
zone: us-central1-a
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
||||
state: present
|
||||
register: _gvnic_disk
|
||||
|
||||
- name: Create network
|
||||
google.cloud.gcp_compute_network:
|
||||
name: "{{ resource_prefix }}"
|
||||
|
@ -38,101 +14,16 @@
|
|||
state: present
|
||||
register: _network
|
||||
|
||||
- name: Create virtio instance
|
||||
google.cloud.gcp_compute_instance:
|
||||
name: "{{ resource_name }}-virtio"
|
||||
machine_type: n1-standard-1
|
||||
disks:
|
||||
- auto_delete: "true"
|
||||
boot: "true"
|
||||
source: "{{ _virtio_disk }}"
|
||||
network_interfaces:
|
||||
- network: "{{ _network }}"
|
||||
nic_type: VIRTIO_NET
|
||||
zone: us-central1-a
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
||||
state: present
|
||||
register: _virtio_result
|
||||
|
||||
- name: Verify virtio instance was created
|
||||
google.cloud.gcp_compute_instance_info:
|
||||
filters:
|
||||
- name = {{ resource_name }}-virtio
|
||||
zone: us-central1-a
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
||||
scopes:
|
||||
- https://www.googleapis.com/auth/compute
|
||||
register: _virtio_info
|
||||
|
||||
- name: Pass assertions
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- _virtio_result.changed == true
|
||||
- _virtio_result.networkInterfaces[0].nicType == 'VIRTIO_NET'
|
||||
- _virtio_info.resources[0].networkInterfaces[0].nicType == 'VIRTIO_NET'
|
||||
|
||||
- name: Create gvnic instance
|
||||
google.cloud.gcp_compute_instance:
|
||||
name: "{{ resource_name }}-gvnic"
|
||||
machine_type: n1-standard-1
|
||||
disks:
|
||||
- auto_delete: "true"
|
||||
boot: "true"
|
||||
source: "{{ _gvnic_disk }}"
|
||||
network_interfaces:
|
||||
- network: "{{ _network }}"
|
||||
nic_type: GVNIC
|
||||
zone: us-central1-a
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
||||
state: present
|
||||
register: _gvnic_result
|
||||
|
||||
- name: Verify gvnic instance was created
|
||||
google.cloud.gcp_compute_instance_info:
|
||||
filters:
|
||||
- name = {{ resource_name }}-gvnic
|
||||
zone: us-central1-a
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
||||
scopes:
|
||||
- https://www.googleapis.com/auth/compute
|
||||
register: _gvnic_info
|
||||
|
||||
- name: Pass assertions
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- _gvnic_result.changed == true
|
||||
- _gvnic_result.networkInterfaces[0].nicType == 'GVNIC'
|
||||
- _gvnic_info.resources[0].networkInterfaces[0].nicType == 'GVNIC'
|
||||
- name: Loop over testcase
|
||||
ansible.builtin.include_tasks: gvnic.yml
|
||||
loop: "{{ testcases | dict2items }}"
|
||||
vars:
|
||||
testcases:
|
||||
gvnic: GVNIC
|
||||
virtio: VIRTIO_NET
|
||||
default: default
|
||||
|
||||
always:
|
||||
- name: Delete virtio instance
|
||||
google.cloud.gcp_compute_instance:
|
||||
name: "{{ resource_name }}-virtio"
|
||||
machine_type: n1-standard-1
|
||||
zone: us-central1-a
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
||||
state: absent
|
||||
|
||||
- name: Delete gVNIC instance
|
||||
google.cloud.gcp_compute_instance:
|
||||
name: "{{ resource_name }}-gvnic"
|
||||
machine_type: n1-standard-1
|
||||
zone: us-central1-a
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
||||
state: absent
|
||||
|
||||
- name: Delete network
|
||||
google.cloud.gcp_compute_network:
|
||||
name: "{{ resource_prefix }}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue