summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/gcp_compute_network
diff options
context:
space:
mode:
authorAlex Stephen <alexstephen@google.com>2018-05-04 20:28:11 +0200
committerRyan Brown <sb@ryansb.com>2018-05-04 20:28:11 +0200
commit01f0e4ac6f78e88b4341373b0d83166468b8e1dd (patch)
tree692619df5b5ff415a8d684066aa52751fee1e61e /test/integration/targets/gcp_compute_network
parentNew module: GCP Compute Routes (#38619) (diff)
downloadansible-01f0e4ac6f78e88b4341373b0d83166468b8e1dd.tar.xz
ansible-01f0e4ac6f78e88b4341373b0d83166468b8e1dd.zip
New module: GCP Compute Networks (#38618)
Diffstat (limited to 'test/integration/targets/gcp_compute_network')
-rw-r--r--test/integration/targets/gcp_compute_network/aliases2
-rw-r--r--test/integration/targets/gcp_compute_network/defaults/main.yml3
-rw-r--r--test/integration/targets/gcp_compute_network/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_network/tasks/main.yml111
4 files changed, 116 insertions, 0 deletions
diff --git a/test/integration/targets/gcp_compute_network/aliases b/test/integration/targets/gcp_compute_network/aliases
new file mode 100644
index 0000000000..9812f019ca
--- /dev/null
+++ b/test/integration/targets/gcp_compute_network/aliases
@@ -0,0 +1,2 @@
+cloud/gcp
+unsupported
diff --git a/test/integration/targets/gcp_compute_network/defaults/main.yml b/test/integration/targets/gcp_compute_network/defaults/main.yml
new file mode 100644
index 0000000000..aa87a2a8e0
--- /dev/null
+++ b/test/integration/targets/gcp_compute_network/defaults/main.yml
@@ -0,0 +1,3 @@
+---
+# defaults file
+resource_name: '{{resource_prefix}}'
diff --git a/test/integration/targets/gcp_compute_network/meta/main.yml b/test/integration/targets/gcp_compute_network/meta/main.yml
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/test/integration/targets/gcp_compute_network/meta/main.yml
diff --git a/test/integration/targets/gcp_compute_network/tasks/main.yml b/test/integration/targets/gcp_compute_network/tasks/main.yml
new file mode 100644
index 0000000000..a802ba5325
--- /dev/null
+++ b/test/integration/targets/gcp_compute_network/tasks/main.yml
@@ -0,0 +1,111 @@
+---
+# ----------------------------------------------------------------------------
+#
+# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
+#
+# ----------------------------------------------------------------------------
+#
+# This file is automatically generated by Magic Modules and manual
+# changes will be clobbered when the file is regenerated.
+#
+# Please read more about how to change this file at
+# https://www.github.com/GoogleCloudPlatform/magic-modules
+#
+# ----------------------------------------------------------------------------
+# Pre-test setup
+- name: delete a network
+ gcp_compute_network:
+ name: "{{ resource_name }}"
+ 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
+#----------------------------------------------------------
+- name: create a network
+ gcp_compute_network:
+ name: "{{ resource_name }}"
+ 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: result
+- name: assert changed is true
+ assert:
+ that:
+ - result.changed == true
+ - "result.kind == 'compute#network'"
+- name: verify that network was created
+ shell: |
+ gcloud compute networks describe --project="{{ gcp_project}}" "{{ resource_name }}"
+ register: results
+- name: verify that command succeeded
+ assert:
+ that:
+ - results.rc == 0
+# ----------------------------------------------------------------------------
+- name: create a network that already exists
+ gcp_compute_network:
+ name: "{{ resource_name }}"
+ 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: result
+- name: assert changed is false
+ assert:
+ that:
+ - result.changed == false
+ - "result.kind == 'compute#network'"
+#----------------------------------------------------------
+- name: delete a network
+ gcp_compute_network:
+ name: "{{ resource_name }}"
+ 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: result
+- name: assert changed is true
+ assert:
+ that:
+ - result.changed == true
+ - result.has_key('kind') == False
+- name: verify that network was deleted
+ shell: |
+ gcloud compute networks describe --project="{{ gcp_project}}" "{{ resource_name }}"
+ register: results
+ failed_when: results.rc == 0
+- name: verify that command succeeded
+ assert:
+ that:
+ - results.rc == 1
+ - "\"'projects/{{ gcp_project }}/global/networks/{{ resource_name }}' was not found\" in results.stderr"
+# ----------------------------------------------------------------------------
+- name: delete a network that does not exist
+ gcp_compute_network:
+ name: "{{ resource_name }}"
+ 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: result
+- name: assert changed is false
+ assert:
+ that:
+ - result.changed == false
+ - result.has_key('kind') == False