|
|
@ -20,8 +20,6 @@
|
|
|
|
project: "{{ gcp_project }}"
|
|
|
|
project: "{{ gcp_project }}"
|
|
|
|
auth_kind: "{{ gcp_cred_kind }}"
|
|
|
|
auth_kind: "{{ gcp_cred_kind }}"
|
|
|
|
service_account_file: "{{ gcp_cred_file }}"
|
|
|
|
service_account_file: "{{ gcp_cred_file }}"
|
|
|
|
scopes:
|
|
|
|
|
|
|
|
- https://www.googleapis.com/auth/compute
|
|
|
|
|
|
|
|
state: absent
|
|
|
|
state: absent
|
|
|
|
#----------------------------------------------------------
|
|
|
|
#----------------------------------------------------------
|
|
|
|
- name: create a network
|
|
|
|
- name: create a network
|
|
|
@ -31,8 +29,6 @@
|
|
|
|
project: "{{ gcp_project }}"
|
|
|
|
project: "{{ gcp_project }}"
|
|
|
|
auth_kind: "{{ gcp_cred_kind }}"
|
|
|
|
auth_kind: "{{ gcp_cred_kind }}"
|
|
|
|
service_account_file: "{{ gcp_cred_file }}"
|
|
|
|
service_account_file: "{{ gcp_cred_file }}"
|
|
|
|
scopes:
|
|
|
|
|
|
|
|
- https://www.googleapis.com/auth/compute
|
|
|
|
|
|
|
|
state: present
|
|
|
|
state: present
|
|
|
|
register: result
|
|
|
|
register: result
|
|
|
|
- name: assert changed is true
|
|
|
|
- name: assert changed is true
|
|
|
@ -41,13 +37,19 @@
|
|
|
|
- result.changed == true
|
|
|
|
- result.changed == true
|
|
|
|
- "result.kind == 'compute#network'"
|
|
|
|
- "result.kind == 'compute#network'"
|
|
|
|
- name: verify that network was created
|
|
|
|
- name: verify that network was created
|
|
|
|
shell: |
|
|
|
|
gcp_compute_network_facts:
|
|
|
|
gcloud compute networks describe --project="{{ gcp_project}}" "{{ resource_name }}"
|
|
|
|
filters:
|
|
|
|
|
|
|
|
- name = {{ resource_name }}
|
|
|
|
|
|
|
|
project: "{{ gcp_project }}"
|
|
|
|
|
|
|
|
auth_kind: "{{ gcp_cred_kind }}"
|
|
|
|
|
|
|
|
service_account_file: "{{ gcp_cred_file }}"
|
|
|
|
|
|
|
|
scopes:
|
|
|
|
|
|
|
|
- https://www.googleapis.com/auth/compute
|
|
|
|
register: results
|
|
|
|
register: results
|
|
|
|
- name: verify that command succeeded
|
|
|
|
- name: verify that command succeeded
|
|
|
|
assert:
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
that:
|
|
|
|
- results.rc == 0
|
|
|
|
- results['items'] | length == 1
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
- name: create a network that already exists
|
|
|
|
- name: create a network that already exists
|
|
|
|
gcp_compute_network:
|
|
|
|
gcp_compute_network:
|
|
|
@ -56,8 +58,6 @@
|
|
|
|
project: "{{ gcp_project }}"
|
|
|
|
project: "{{ gcp_project }}"
|
|
|
|
auth_kind: "{{ gcp_cred_kind }}"
|
|
|
|
auth_kind: "{{ gcp_cred_kind }}"
|
|
|
|
service_account_file: "{{ gcp_cred_file }}"
|
|
|
|
service_account_file: "{{ gcp_cred_file }}"
|
|
|
|
scopes:
|
|
|
|
|
|
|
|
- https://www.googleapis.com/auth/compute
|
|
|
|
|
|
|
|
state: present
|
|
|
|
state: present
|
|
|
|
register: result
|
|
|
|
register: result
|
|
|
|
- name: assert changed is false
|
|
|
|
- name: assert changed is false
|
|
|
@ -73,8 +73,6 @@
|
|
|
|
project: "{{ gcp_project }}"
|
|
|
|
project: "{{ gcp_project }}"
|
|
|
|
auth_kind: "{{ gcp_cred_kind }}"
|
|
|
|
auth_kind: "{{ gcp_cred_kind }}"
|
|
|
|
service_account_file: "{{ gcp_cred_file }}"
|
|
|
|
service_account_file: "{{ gcp_cred_file }}"
|
|
|
|
scopes:
|
|
|
|
|
|
|
|
- https://www.googleapis.com/auth/compute
|
|
|
|
|
|
|
|
state: absent
|
|
|
|
state: absent
|
|
|
|
register: result
|
|
|
|
register: result
|
|
|
|
- name: assert changed is true
|
|
|
|
- name: assert changed is true
|
|
|
@ -83,15 +81,19 @@
|
|
|
|
- result.changed == true
|
|
|
|
- result.changed == true
|
|
|
|
- result.has_key('kind') == False
|
|
|
|
- result.has_key('kind') == False
|
|
|
|
- name: verify that network was deleted
|
|
|
|
- name: verify that network was deleted
|
|
|
|
shell: |
|
|
|
|
gcp_compute_network_facts:
|
|
|
|
gcloud compute networks describe --project="{{ gcp_project}}" "{{ resource_name }}"
|
|
|
|
filters:
|
|
|
|
|
|
|
|
- name = {{ resource_name }}
|
|
|
|
|
|
|
|
project: "{{ gcp_project }}"
|
|
|
|
|
|
|
|
auth_kind: "{{ gcp_cred_kind }}"
|
|
|
|
|
|
|
|
service_account_file: "{{ gcp_cred_file }}"
|
|
|
|
|
|
|
|
scopes:
|
|
|
|
|
|
|
|
- https://www.googleapis.com/auth/compute
|
|
|
|
register: results
|
|
|
|
register: results
|
|
|
|
failed_when: results.rc == 0
|
|
|
|
|
|
|
|
- name: verify that command succeeded
|
|
|
|
- name: verify that command succeeded
|
|
|
|
assert:
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
that:
|
|
|
|
- results.rc == 1
|
|
|
|
- results['items'] | length == 0
|
|
|
|
- "\"'projects/{{ gcp_project }}/global/networks/{{ resource_name }}' was not found\" in results.stderr"
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
- name: delete a network that does not exist
|
|
|
|
- name: delete a network that does not exist
|
|
|
|
gcp_compute_network:
|
|
|
|
gcp_compute_network:
|
|
|
@ -100,8 +102,6 @@
|
|
|
|
project: "{{ gcp_project }}"
|
|
|
|
project: "{{ gcp_project }}"
|
|
|
|
auth_kind: "{{ gcp_cred_kind }}"
|
|
|
|
auth_kind: "{{ gcp_cred_kind }}"
|
|
|
|
service_account_file: "{{ gcp_cred_file }}"
|
|
|
|
service_account_file: "{{ gcp_cred_file }}"
|
|
|
|
scopes:
|
|
|
|
|
|
|
|
- https://www.googleapis.com/auth/compute
|
|
|
|
|
|
|
|
state: absent
|
|
|
|
state: absent
|
|
|
|
register: result
|
|
|
|
register: result
|
|
|
|
- name: assert changed is false
|
|
|
|
- name: assert changed is false
|
|
|
|