diff --git a/test/integration/targets/gcp_appengine_firewall_rule/tasks/autogen.yml b/test/integration/targets/gcp_appengine_firewall_rule/tasks/autogen.yml new file mode 100644 index 00000000000000..5233e460a00b4f --- /dev/null +++ b/test/integration/targets/gcp_appengine_firewall_rule/tasks/autogen.yml @@ -0,0 +1,108 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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 firewall rule + gcp_appengine_firewall_rule: + priority: 1000 + source_range: 10.0.0.0 + action: ALLOW + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a firewall rule + gcp_appengine_firewall_rule: + priority: 1000 + source_range: 10.0.0.0 + action: ALLOW + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that firewall_rule was created + gcp_appengine_firewall_rule_info: + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/cloud-platform + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | length >= 1 +# ---------------------------------------------------------------------------- +- name: create a firewall rule that already exists + gcp_appengine_firewall_rule: + priority: 1000 + source_range: 10.0.0.0 + action: ALLOW + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a firewall rule + gcp_appengine_firewall_rule: + priority: 1000 + source_range: 10.0.0.0 + action: ALLOW + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that firewall_rule was deleted + gcp_appengine_firewall_rule_info: + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/cloud-platform + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a firewall rule that does not exist + gcp_appengine_firewall_rule: + priority: 1000 + source_range: 10.0.0.0 + action: ALLOW + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_appengine_firewall_rule/tasks/main.yml b/test/integration/targets/gcp_appengine_firewall_rule/tasks/main.yml index 5233e460a00b4f..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_appengine_firewall_rule/tasks/main.yml +++ b/test/integration/targets/gcp_appengine_firewall_rule/tasks/main.yml @@ -1,108 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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 firewall rule - gcp_appengine_firewall_rule: - priority: 1000 - source_range: 10.0.0.0 - action: ALLOW - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a firewall rule - gcp_appengine_firewall_rule: - priority: 1000 - source_range: 10.0.0.0 - action: ALLOW - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that firewall_rule was created - gcp_appengine_firewall_rule_info: - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/cloud-platform - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | length >= 1 -# ---------------------------------------------------------------------------- -- name: create a firewall rule that already exists - gcp_appengine_firewall_rule: - priority: 1000 - source_range: 10.0.0.0 - action: ALLOW - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a firewall rule - gcp_appengine_firewall_rule: - priority: 1000 - source_range: 10.0.0.0 - action: ALLOW - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that firewall_rule was deleted - gcp_appengine_firewall_rule_info: - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/cloud-platform - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a firewall rule that does not exist - gcp_appengine_firewall_rule: - priority: 1000 - source_range: 10.0.0.0 - action: ALLOW - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_bigquery_dataset/tasks/autogen.yml b/test/integration/targets/gcp_bigquery_dataset/tasks/autogen.yml new file mode 100644 index 00000000000000..ac1eae0dde3c4c --- /dev/null +++ b/test/integration/targets/gcp_bigquery_dataset/tasks/autogen.yml @@ -0,0 +1,108 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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 dataset + gcp_bigquery_dataset: + name: my_example_dataset + dataset_reference: + dataset_id: my_example_dataset + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a dataset + gcp_bigquery_dataset: + name: my_example_dataset + dataset_reference: + dataset_id: my_example_dataset + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that dataset was created + gcp_bigquery_dataset_info: + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/bigquery + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | map(attribute='datasetReference') | map(attribute='datasetId') | select("match", ".*my_example_dataset.*") | list | length == 1 +# ---------------------------------------------------------------------------- +- name: create a dataset that already exists + gcp_bigquery_dataset: + name: my_example_dataset + dataset_reference: + dataset_id: my_example_dataset + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a dataset + gcp_bigquery_dataset: + name: my_example_dataset + dataset_reference: + dataset_id: my_example_dataset + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that dataset was deleted + gcp_bigquery_dataset_info: + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/bigquery + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | map(attribute='datasetReference') | map(attribute='datasetId') | select("match", ".*my_example_dataset.*") | list | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a dataset that does not exist + gcp_bigquery_dataset: + name: my_example_dataset + dataset_reference: + dataset_id: my_example_dataset + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_bigquery_dataset/tasks/main.yml b/test/integration/targets/gcp_bigquery_dataset/tasks/main.yml index ac1eae0dde3c4c..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_bigquery_dataset/tasks/main.yml +++ b/test/integration/targets/gcp_bigquery_dataset/tasks/main.yml @@ -1,108 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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 dataset - gcp_bigquery_dataset: - name: my_example_dataset - dataset_reference: - dataset_id: my_example_dataset - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a dataset - gcp_bigquery_dataset: - name: my_example_dataset - dataset_reference: - dataset_id: my_example_dataset - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that dataset was created - gcp_bigquery_dataset_info: - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/bigquery - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | map(attribute='datasetReference') | map(attribute='datasetId') | select("match", ".*my_example_dataset.*") | list | length == 1 -# ---------------------------------------------------------------------------- -- name: create a dataset that already exists - gcp_bigquery_dataset: - name: my_example_dataset - dataset_reference: - dataset_id: my_example_dataset - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a dataset - gcp_bigquery_dataset: - name: my_example_dataset - dataset_reference: - dataset_id: my_example_dataset - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that dataset was deleted - gcp_bigquery_dataset_info: - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/bigquery - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | map(attribute='datasetReference') | map(attribute='datasetId') | select("match", ".*my_example_dataset.*") | list | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a dataset that does not exist - gcp_bigquery_dataset: - name: my_example_dataset - dataset_reference: - dataset_id: my_example_dataset - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_bigquery_table/tasks/autogen.yml b/test/integration/targets/gcp_bigquery_table/tasks/autogen.yml new file mode 100644 index 00000000000000..caa12eb97f5cea --- /dev/null +++ b/test/integration/targets/gcp_bigquery_table/tasks/autogen.yml @@ -0,0 +1,149 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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: create a dataset + gcp_bigquery_dataset: + name: example_dataset + dataset_reference: + dataset_id: example_dataset + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: dataset +- name: delete a table + gcp_bigquery_table: + name: example_table + dataset: example_dataset + table_reference: + dataset_id: example_dataset + project_id: "{{ gcp_project }}" + table_id: example_table + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a table + gcp_bigquery_table: + name: example_table + dataset: example_dataset + table_reference: + dataset_id: example_dataset + project_id: "{{ gcp_project }}" + table_id: example_table + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that table was created + gcp_bigquery_table_info: + dataset: example_dataset + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/bigquery + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | map(attribute='tableReference') | map(attribute='tableId') | select("match", ".*example_table.*") | list | length == 1 +# ---------------------------------------------------------------------------- +- name: create a table that already exists + gcp_bigquery_table: + name: example_table + dataset: example_dataset + table_reference: + dataset_id: example_dataset + project_id: "{{ gcp_project }}" + table_id: example_table + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a table + gcp_bigquery_table: + name: example_table + dataset: example_dataset + table_reference: + dataset_id: example_dataset + project_id: "{{ gcp_project }}" + table_id: example_table + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that table was deleted + gcp_bigquery_table_info: + dataset: example_dataset + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/bigquery + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | map(attribute='tableReference') | map(attribute='tableId') | select("match", ".*example_table.*") | list | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a table that does not exist + gcp_bigquery_table: + name: example_table + dataset: example_dataset + table_reference: + dataset_id: example_dataset + project_id: "{{ gcp_project }}" + table_id: example_table + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a dataset + gcp_bigquery_dataset: + name: example_dataset + dataset_reference: + dataset_id: example_dataset + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: dataset + ignore_errors: true diff --git a/test/integration/targets/gcp_bigquery_table/tasks/main.yml b/test/integration/targets/gcp_bigquery_table/tasks/main.yml index caa12eb97f5cea..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_bigquery_table/tasks/main.yml +++ b/test/integration/targets/gcp_bigquery_table/tasks/main.yml @@ -1,149 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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: create a dataset - gcp_bigquery_dataset: - name: example_dataset - dataset_reference: - dataset_id: example_dataset - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: dataset -- name: delete a table - gcp_bigquery_table: - name: example_table - dataset: example_dataset - table_reference: - dataset_id: example_dataset - project_id: "{{ gcp_project }}" - table_id: example_table - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a table - gcp_bigquery_table: - name: example_table - dataset: example_dataset - table_reference: - dataset_id: example_dataset - project_id: "{{ gcp_project }}" - table_id: example_table - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that table was created - gcp_bigquery_table_info: - dataset: example_dataset - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/bigquery - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | map(attribute='tableReference') | map(attribute='tableId') | select("match", ".*example_table.*") | list | length == 1 -# ---------------------------------------------------------------------------- -- name: create a table that already exists - gcp_bigquery_table: - name: example_table - dataset: example_dataset - table_reference: - dataset_id: example_dataset - project_id: "{{ gcp_project }}" - table_id: example_table - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a table - gcp_bigquery_table: - name: example_table - dataset: example_dataset - table_reference: - dataset_id: example_dataset - project_id: "{{ gcp_project }}" - table_id: example_table - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that table was deleted - gcp_bigquery_table_info: - dataset: example_dataset - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/bigquery - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | map(attribute='tableReference') | map(attribute='tableId') | select("match", ".*example_table.*") | list | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a table that does not exist - gcp_bigquery_table: - name: example_table - dataset: example_dataset - table_reference: - dataset_id: example_dataset - project_id: "{{ gcp_project }}" - table_id: example_table - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a dataset - gcp_bigquery_dataset: - name: example_dataset - dataset_reference: - dataset_id: example_dataset - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: dataset - ignore_errors: true +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_cloudfunctions_cloud_function/tasks/autogen.yml b/test/integration/targets/gcp_cloudfunctions_cloud_function/tasks/autogen.yml new file mode 100644 index 00000000000000..7c76f7149f7df6 --- /dev/null +++ b/test/integration/targets/gcp_cloudfunctions_cloud_function/tasks/autogen.yml @@ -0,0 +1,120 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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 cloud function + gcp_cloudfunctions_cloud_function: + name: "{{ resource_name }}" + location: us-central1 + entry_point: helloGET + source_archive_url: gs://ansible-cloudfunctions-bucket/function.zip + trigger_http: 'true' + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a cloud function + gcp_cloudfunctions_cloud_function: + name: "{{ resource_name }}" + location: us-central1 + entry_point: helloGET + source_archive_url: gs://ansible-cloudfunctions-bucket/function.zip + trigger_http: 'true' + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that cloud_function was created + gcp_cloudfunctions_cloud_function_info: + location: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/cloud-platform + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 1 +# ---------------------------------------------------------------------------- +- name: create a cloud function that already exists + gcp_cloudfunctions_cloud_function: + name: "{{ resource_name }}" + location: us-central1 + entry_point: helloGET + source_archive_url: gs://ansible-cloudfunctions-bucket/function.zip + trigger_http: 'true' + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a cloud function + gcp_cloudfunctions_cloud_function: + name: "{{ resource_name }}" + location: us-central1 + entry_point: helloGET + source_archive_url: gs://ansible-cloudfunctions-bucket/function.zip + trigger_http: 'true' + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that cloud_function was deleted + gcp_cloudfunctions_cloud_function_info: + location: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/cloud-platform + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a cloud function that does not exist + gcp_cloudfunctions_cloud_function: + name: "{{ resource_name }}" + location: us-central1 + entry_point: helloGET + source_archive_url: gs://ansible-cloudfunctions-bucket/function.zip + trigger_http: 'true' + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_cloudfunctions_cloud_function/tasks/main.yml b/test/integration/targets/gcp_cloudfunctions_cloud_function/tasks/main.yml index 7c76f7149f7df6..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_cloudfunctions_cloud_function/tasks/main.yml +++ b/test/integration/targets/gcp_cloudfunctions_cloud_function/tasks/main.yml @@ -1,120 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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 cloud function - gcp_cloudfunctions_cloud_function: - name: "{{ resource_name }}" - location: us-central1 - entry_point: helloGET - source_archive_url: gs://ansible-cloudfunctions-bucket/function.zip - trigger_http: 'true' - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a cloud function - gcp_cloudfunctions_cloud_function: - name: "{{ resource_name }}" - location: us-central1 - entry_point: helloGET - source_archive_url: gs://ansible-cloudfunctions-bucket/function.zip - trigger_http: 'true' - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that cloud_function was created - gcp_cloudfunctions_cloud_function_info: - location: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/cloud-platform - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 1 -# ---------------------------------------------------------------------------- -- name: create a cloud function that already exists - gcp_cloudfunctions_cloud_function: - name: "{{ resource_name }}" - location: us-central1 - entry_point: helloGET - source_archive_url: gs://ansible-cloudfunctions-bucket/function.zip - trigger_http: 'true' - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a cloud function - gcp_cloudfunctions_cloud_function: - name: "{{ resource_name }}" - location: us-central1 - entry_point: helloGET - source_archive_url: gs://ansible-cloudfunctions-bucket/function.zip - trigger_http: 'true' - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that cloud_function was deleted - gcp_cloudfunctions_cloud_function_info: - location: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/cloud-platform - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a cloud function that does not exist - gcp_cloudfunctions_cloud_function: - name: "{{ resource_name }}" - location: us-central1 - entry_point: helloGET - source_archive_url: gs://ansible-cloudfunctions-bucket/function.zip - trigger_http: 'true' - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_cloudscheduler_job/tasks/autogen.yml b/test/integration/targets/gcp_cloudscheduler_job/tasks/autogen.yml new file mode 100644 index 00000000000000..ffe687b76707c4 --- /dev/null +++ b/test/integration/targets/gcp_cloudscheduler_job/tasks/autogen.yml @@ -0,0 +1,155 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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 job + gcp_cloudscheduler_job: + name: job + region: us-central1 + schedule: "*/4 * * * *" + description: test app engine job + time_zone: Europe/London + app_engine_http_target: + http_method: POST + app_engine_routing: + service: web + version: prod + instance: my-instance-001 + relative_uri: "/ping" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a job + gcp_cloudscheduler_job: + name: job + region: us-central1 + schedule: "*/4 * * * *" + description: test app engine job + time_zone: Europe/London + app_engine_http_target: + http_method: POST + app_engine_routing: + service: web + version: prod + instance: my-instance-001 + relative_uri: "/ping" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that job was created + gcp_cloudscheduler_job_info: + region: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/cloud-platform + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | map(attribute='name') | select("match", ".*job.*") | list | length == 1 +# ---------------------------------------------------------------------------- +- name: create a job that already exists + gcp_cloudscheduler_job: + name: job + region: us-central1 + schedule: "*/4 * * * *" + description: test app engine job + time_zone: Europe/London + app_engine_http_target: + http_method: POST + app_engine_routing: + service: web + version: prod + instance: my-instance-001 + relative_uri: "/ping" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a job + gcp_cloudscheduler_job: + name: job + region: us-central1 + schedule: "*/4 * * * *" + description: test app engine job + time_zone: Europe/London + app_engine_http_target: + http_method: POST + app_engine_routing: + service: web + version: prod + instance: my-instance-001 + relative_uri: "/ping" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that job was deleted + gcp_cloudscheduler_job_info: + region: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/cloud-platform + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | map(attribute='name') | select("match", ".*job.*") | list | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a job that does not exist + gcp_cloudscheduler_job: + name: job + region: us-central1 + schedule: "*/4 * * * *" + description: test app engine job + time_zone: Europe/London + app_engine_http_target: + http_method: POST + app_engine_routing: + service: web + version: prod + instance: my-instance-001 + relative_uri: "/ping" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_cloudscheduler_job/tasks/main.yml b/test/integration/targets/gcp_cloudscheduler_job/tasks/main.yml index ffe687b76707c4..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_cloudscheduler_job/tasks/main.yml +++ b/test/integration/targets/gcp_cloudscheduler_job/tasks/main.yml @@ -1,155 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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 job - gcp_cloudscheduler_job: - name: job - region: us-central1 - schedule: "*/4 * * * *" - description: test app engine job - time_zone: Europe/London - app_engine_http_target: - http_method: POST - app_engine_routing: - service: web - version: prod - instance: my-instance-001 - relative_uri: "/ping" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a job - gcp_cloudscheduler_job: - name: job - region: us-central1 - schedule: "*/4 * * * *" - description: test app engine job - time_zone: Europe/London - app_engine_http_target: - http_method: POST - app_engine_routing: - service: web - version: prod - instance: my-instance-001 - relative_uri: "/ping" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that job was created - gcp_cloudscheduler_job_info: - region: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/cloud-platform - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | map(attribute='name') | select("match", ".*job.*") | list | length == 1 -# ---------------------------------------------------------------------------- -- name: create a job that already exists - gcp_cloudscheduler_job: - name: job - region: us-central1 - schedule: "*/4 * * * *" - description: test app engine job - time_zone: Europe/London - app_engine_http_target: - http_method: POST - app_engine_routing: - service: web - version: prod - instance: my-instance-001 - relative_uri: "/ping" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a job - gcp_cloudscheduler_job: - name: job - region: us-central1 - schedule: "*/4 * * * *" - description: test app engine job - time_zone: Europe/London - app_engine_http_target: - http_method: POST - app_engine_routing: - service: web - version: prod - instance: my-instance-001 - relative_uri: "/ping" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that job was deleted - gcp_cloudscheduler_job_info: - region: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/cloud-platform - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | map(attribute='name') | select("match", ".*job.*") | list | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a job that does not exist - gcp_cloudscheduler_job: - name: job - region: us-central1 - schedule: "*/4 * * * *" - description: test app engine job - time_zone: Europe/London - app_engine_http_target: - http_method: POST - app_engine_routing: - service: web - version: prod - instance: my-instance-001 - relative_uri: "/ping" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_cloudtasks_queue/tasks/autogen.yml b/test/integration/targets/gcp_cloudtasks_queue/tasks/autogen.yml new file mode 100644 index 00000000000000..19d583c442f3fd --- /dev/null +++ b/test/integration/targets/gcp_cloudtasks_queue/tasks/autogen.yml @@ -0,0 +1,105 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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 queue + gcp_cloudtasks_queue: + name: "{{ resource_name }}" + location: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a queue + gcp_cloudtasks_queue: + name: "{{ resource_name }}" + location: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that queue was created + gcp_cloudtasks_queue_info: + location: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/cloud-platform + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 1 +# ---------------------------------------------------------------------------- +- name: create a queue that already exists + gcp_cloudtasks_queue: + name: "{{ resource_name }}" + location: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a queue + gcp_cloudtasks_queue: + name: "{{ resource_name }}" + location: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that queue was deleted + gcp_cloudtasks_queue_info: + location: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/cloud-platform + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a queue that does not exist + gcp_cloudtasks_queue: + name: "{{ resource_name }}" + location: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_cloudtasks_queue/tasks/main.yml b/test/integration/targets/gcp_cloudtasks_queue/tasks/main.yml index 19d583c442f3fd..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_cloudtasks_queue/tasks/main.yml +++ b/test/integration/targets/gcp_cloudtasks_queue/tasks/main.yml @@ -1,105 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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 queue - gcp_cloudtasks_queue: - name: "{{ resource_name }}" - location: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a queue - gcp_cloudtasks_queue: - name: "{{ resource_name }}" - location: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that queue was created - gcp_cloudtasks_queue_info: - location: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/cloud-platform - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 1 -# ---------------------------------------------------------------------------- -- name: create a queue that already exists - gcp_cloudtasks_queue: - name: "{{ resource_name }}" - location: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a queue - gcp_cloudtasks_queue: - name: "{{ resource_name }}" - location: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that queue was deleted - gcp_cloudtasks_queue_info: - location: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/cloud-platform - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a queue that does not exist - gcp_cloudtasks_queue: - name: "{{ resource_name }}" - location: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_address/tasks/autogen.yml b/test/integration/targets/gcp_compute_address/tasks/autogen.yml new file mode 100644 index 00000000000000..124e44d2f14ef5 --- /dev/null +++ b/test/integration/targets/gcp_compute_address/tasks/autogen.yml @@ -0,0 +1,109 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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 address + gcp_compute_address: + name: test-address1 + region: us-west1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a address + gcp_compute_address: + name: test-address1 + region: us-west1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that address was created + gcp_compute_address_info: + filters: + - name = test-address1 + 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['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a address that already exists + gcp_compute_address: + name: test-address1 + region: us-west1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a address + gcp_compute_address: + name: test-address1 + region: us-west1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that address was deleted + gcp_compute_address_info: + filters: + - name = test-address1 + 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['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a address that does not exist + gcp_compute_address: + name: test-address1 + region: us-west1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_compute_address/tasks/main.yml b/test/integration/targets/gcp_compute_address/tasks/main.yml index 124e44d2f14ef5..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_compute_address/tasks/main.yml +++ b/test/integration/targets/gcp_compute_address/tasks/main.yml @@ -1,109 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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 address - gcp_compute_address: - name: test-address1 - region: us-west1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a address - gcp_compute_address: - name: test-address1 - region: us-west1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that address was created - gcp_compute_address_info: - filters: - - name = test-address1 - 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['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a address that already exists - gcp_compute_address: - name: test-address1 - region: us-west1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a address - gcp_compute_address: - name: test-address1 - region: us-west1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that address was deleted - gcp_compute_address_info: - filters: - - name = test-address1 - 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['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a address that does not exist - gcp_compute_address: - name: test-address1 - region: us-west1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_autoscaler/tasks/autogen.yml b/test/integration/targets/gcp_compute_autoscaler/tasks/autogen.yml new file mode 100644 index 00000000000000..899c88df1fc4f3 --- /dev/null +++ b/test/integration/targets/gcp_compute_autoscaler/tasks/autogen.yml @@ -0,0 +1,251 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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: create a network + gcp_compute_network: + name: network-instancetemplate + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: network +- name: create a address + gcp_compute_address: + name: address-instancetemplate + region: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: address +- name: create a instance template + gcp_compute_instance_template: + name: "{{ resource_name }}" + properties: + disks: + - auto_delete: 'true' + boot: 'true' + initialize_params: + source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts + machine_type: n1-standard-1 + network_interfaces: + - network: "{{ network }}" + access_configs: + - name: test-config + type: ONE_TO_ONE_NAT + nat_ip: "{{ address }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: instancetemplate +- name: create a instance group manager + gcp_compute_instance_group_manager: + name: "{{ resource_name }}" + base_instance_name: test1-child + instance_template: "{{ instancetemplate }}" + target_size: 3 + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: igm +- name: delete a autoscaler + gcp_compute_autoscaler: + name: "{{ resource_name }}" + zone: us-central1-a + target: "{{ igm }}" + autoscaling_policy: + max_num_replicas: 5 + min_num_replicas: 1 + cool_down_period_sec: 60 + cpu_utilization: + utilization_target: 0.5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a autoscaler + gcp_compute_autoscaler: + name: "{{ resource_name }}" + zone: us-central1-a + target: "{{ igm }}" + autoscaling_policy: + max_num_replicas: 5 + min_num_replicas: 1 + cool_down_period_sec: 60 + cpu_utilization: + utilization_target: 0.5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that autoscaler was created + gcp_compute_autoscaler_info: + filters: + - name = {{ resource_name }} + zone: us-central1-a + 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['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a autoscaler that already exists + gcp_compute_autoscaler: + name: "{{ resource_name }}" + zone: us-central1-a + target: "{{ igm }}" + autoscaling_policy: + max_num_replicas: 5 + min_num_replicas: 1 + cool_down_period_sec: 60 + cpu_utilization: + utilization_target: 0.5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a autoscaler + gcp_compute_autoscaler: + name: "{{ resource_name }}" + zone: us-central1-a + target: "{{ igm }}" + autoscaling_policy: + max_num_replicas: 5 + min_num_replicas: 1 + cool_down_period_sec: 60 + cpu_utilization: + utilization_target: 0.5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that autoscaler was deleted + gcp_compute_autoscaler_info: + filters: + - name = {{ resource_name }} + zone: us-central1-a + 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['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a autoscaler that does not exist + gcp_compute_autoscaler: + name: "{{ resource_name }}" + zone: us-central1-a + target: "{{ igm }}" + autoscaling_policy: + max_num_replicas: 5 + min_num_replicas: 1 + cool_down_period_sec: 60 + cpu_utilization: + utilization_target: 0.5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a instance group manager + gcp_compute_instance_group_manager: + name: "{{ resource_name }}" + base_instance_name: test1-child + instance_template: "{{ instancetemplate }}" + target_size: 3 + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: igm + ignore_errors: true +- name: delete a instance template + gcp_compute_instance_template: + name: "{{ resource_name }}" + properties: + disks: + - auto_delete: 'true' + boot: 'true' + initialize_params: + source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts + machine_type: n1-standard-1 + network_interfaces: + - network: "{{ network }}" + access_configs: + - name: test-config + type: ONE_TO_ONE_NAT + nat_ip: "{{ address }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: instancetemplate + ignore_errors: true +- name: delete a address + gcp_compute_address: + name: address-instancetemplate + region: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: address + ignore_errors: true +- name: delete a network + gcp_compute_network: + name: network-instancetemplate + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: network + ignore_errors: true diff --git a/test/integration/targets/gcp_compute_autoscaler/tasks/main.yml b/test/integration/targets/gcp_compute_autoscaler/tasks/main.yml index 899c88df1fc4f3..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_compute_autoscaler/tasks/main.yml +++ b/test/integration/targets/gcp_compute_autoscaler/tasks/main.yml @@ -1,251 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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: create a network - gcp_compute_network: - name: network-instancetemplate - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: network -- name: create a address - gcp_compute_address: - name: address-instancetemplate - region: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: address -- name: create a instance template - gcp_compute_instance_template: - name: "{{ resource_name }}" - properties: - disks: - - auto_delete: 'true' - boot: 'true' - initialize_params: - source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts - machine_type: n1-standard-1 - network_interfaces: - - network: "{{ network }}" - access_configs: - - name: test-config - type: ONE_TO_ONE_NAT - nat_ip: "{{ address }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: instancetemplate -- name: create a instance group manager - gcp_compute_instance_group_manager: - name: "{{ resource_name }}" - base_instance_name: test1-child - instance_template: "{{ instancetemplate }}" - target_size: 3 - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: igm -- name: delete a autoscaler - gcp_compute_autoscaler: - name: "{{ resource_name }}" - zone: us-central1-a - target: "{{ igm }}" - autoscaling_policy: - max_num_replicas: 5 - min_num_replicas: 1 - cool_down_period_sec: 60 - cpu_utilization: - utilization_target: 0.5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a autoscaler - gcp_compute_autoscaler: - name: "{{ resource_name }}" - zone: us-central1-a - target: "{{ igm }}" - autoscaling_policy: - max_num_replicas: 5 - min_num_replicas: 1 - cool_down_period_sec: 60 - cpu_utilization: - utilization_target: 0.5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that autoscaler was created - gcp_compute_autoscaler_info: - filters: - - name = {{ resource_name }} - zone: us-central1-a - 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['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a autoscaler that already exists - gcp_compute_autoscaler: - name: "{{ resource_name }}" - zone: us-central1-a - target: "{{ igm }}" - autoscaling_policy: - max_num_replicas: 5 - min_num_replicas: 1 - cool_down_period_sec: 60 - cpu_utilization: - utilization_target: 0.5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a autoscaler - gcp_compute_autoscaler: - name: "{{ resource_name }}" - zone: us-central1-a - target: "{{ igm }}" - autoscaling_policy: - max_num_replicas: 5 - min_num_replicas: 1 - cool_down_period_sec: 60 - cpu_utilization: - utilization_target: 0.5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that autoscaler was deleted - gcp_compute_autoscaler_info: - filters: - - name = {{ resource_name }} - zone: us-central1-a - 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['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a autoscaler that does not exist - gcp_compute_autoscaler: - name: "{{ resource_name }}" - zone: us-central1-a - target: "{{ igm }}" - autoscaling_policy: - max_num_replicas: 5 - min_num_replicas: 1 - cool_down_period_sec: 60 - cpu_utilization: - utilization_target: 0.5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a instance group manager - gcp_compute_instance_group_manager: - name: "{{ resource_name }}" - base_instance_name: test1-child - instance_template: "{{ instancetemplate }}" - target_size: 3 - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: igm - ignore_errors: true -- name: delete a instance template - gcp_compute_instance_template: - name: "{{ resource_name }}" - properties: - disks: - - auto_delete: 'true' - boot: 'true' - initialize_params: - source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts - machine_type: n1-standard-1 - network_interfaces: - - network: "{{ network }}" - access_configs: - - name: test-config - type: ONE_TO_ONE_NAT - nat_ip: "{{ address }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: instancetemplate - ignore_errors: true -- name: delete a address - gcp_compute_address: - name: address-instancetemplate - region: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: address - ignore_errors: true -- name: delete a network - gcp_compute_network: - name: network-instancetemplate - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: network - ignore_errors: true +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_backend_bucket/tasks/autogen.yml b/test/integration/targets/gcp_compute_backend_bucket/tasks/autogen.yml new file mode 100644 index 00000000000000..35963c90c134d9 --- /dev/null +++ b/test/integration/targets/gcp_compute_backend_bucket/tasks/autogen.yml @@ -0,0 +1,137 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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: create a bucket + gcp_storage_bucket: + name: bucket-backendbucket + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: bucket +- name: delete a backend bucket + gcp_compute_backend_bucket: + name: "{{ resource_name }}" + bucket_name: "{{ bucket.name }}" + description: A BackendBucket to connect LNB w/ Storage Bucket + enable_cdn: 'true' + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a backend bucket + gcp_compute_backend_bucket: + name: "{{ resource_name }}" + bucket_name: "{{ bucket.name }}" + description: A BackendBucket to connect LNB w/ Storage Bucket + enable_cdn: 'true' + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that backend_bucket was created + gcp_compute_backend_bucket_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a backend bucket that already exists + gcp_compute_backend_bucket: + name: "{{ resource_name }}" + bucket_name: "{{ bucket.name }}" + description: A BackendBucket to connect LNB w/ Storage Bucket + enable_cdn: 'true' + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a backend bucket + gcp_compute_backend_bucket: + name: "{{ resource_name }}" + bucket_name: "{{ bucket.name }}" + description: A BackendBucket to connect LNB w/ Storage Bucket + enable_cdn: 'true' + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that backend_bucket was deleted + gcp_compute_backend_bucket_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a backend bucket that does not exist + gcp_compute_backend_bucket: + name: "{{ resource_name }}" + bucket_name: "{{ bucket.name }}" + description: A BackendBucket to connect LNB w/ Storage Bucket + enable_cdn: 'true' + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a bucket + gcp_storage_bucket: + name: bucket-backendbucket + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: bucket + ignore_errors: true diff --git a/test/integration/targets/gcp_compute_backend_bucket/tasks/main.yml b/test/integration/targets/gcp_compute_backend_bucket/tasks/main.yml index 35963c90c134d9..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_compute_backend_bucket/tasks/main.yml +++ b/test/integration/targets/gcp_compute_backend_bucket/tasks/main.yml @@ -1,137 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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: create a bucket - gcp_storage_bucket: - name: bucket-backendbucket - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: bucket -- name: delete a backend bucket - gcp_compute_backend_bucket: - name: "{{ resource_name }}" - bucket_name: "{{ bucket.name }}" - description: A BackendBucket to connect LNB w/ Storage Bucket - enable_cdn: 'true' - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a backend bucket - gcp_compute_backend_bucket: - name: "{{ resource_name }}" - bucket_name: "{{ bucket.name }}" - description: A BackendBucket to connect LNB w/ Storage Bucket - enable_cdn: 'true' - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that backend_bucket was created - gcp_compute_backend_bucket_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a backend bucket that already exists - gcp_compute_backend_bucket: - name: "{{ resource_name }}" - bucket_name: "{{ bucket.name }}" - description: A BackendBucket to connect LNB w/ Storage Bucket - enable_cdn: 'true' - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a backend bucket - gcp_compute_backend_bucket: - name: "{{ resource_name }}" - bucket_name: "{{ bucket.name }}" - description: A BackendBucket to connect LNB w/ Storage Bucket - enable_cdn: 'true' - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that backend_bucket was deleted - gcp_compute_backend_bucket_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a backend bucket that does not exist - gcp_compute_backend_bucket: - name: "{{ resource_name }}" - bucket_name: "{{ bucket.name }}" - description: A BackendBucket to connect LNB w/ Storage Bucket - enable_cdn: 'true' - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a bucket - gcp_storage_bucket: - name: bucket-backendbucket - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: bucket - ignore_errors: true +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_backend_service/tasks/autogen.yml b/test/integration/targets/gcp_compute_backend_service/tasks/autogen.yml new file mode 100644 index 00000000000000..60fa24c4be950c --- /dev/null +++ b/test/integration/targets/gcp_compute_backend_service/tasks/autogen.yml @@ -0,0 +1,174 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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: create a instance group + gcp_compute_instance_group: + name: instancegroup-backendservice + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: instancegroup +- name: create a HTTP health check + gcp_compute_http_health_check: + name: httphealthcheck-backendservice + healthy_threshold: 10 + port: 8080 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: healthcheck +- name: delete a backend service + gcp_compute_backend_service: + name: "{{ resource_name }}" + backends: + - group: "{{ instancegroup.selfLink }}" + health_checks: + - "{{ healthcheck.selfLink }}" + enable_cdn: 'true' + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a backend service + gcp_compute_backend_service: + name: "{{ resource_name }}" + backends: + - group: "{{ instancegroup.selfLink }}" + health_checks: + - "{{ healthcheck.selfLink }}" + enable_cdn: 'true' + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that backend_service was created + gcp_compute_backend_service_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a backend service that already exists + gcp_compute_backend_service: + name: "{{ resource_name }}" + backends: + - group: "{{ instancegroup.selfLink }}" + health_checks: + - "{{ healthcheck.selfLink }}" + enable_cdn: 'true' + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a backend service + gcp_compute_backend_service: + name: "{{ resource_name }}" + backends: + - group: "{{ instancegroup.selfLink }}" + health_checks: + - "{{ healthcheck.selfLink }}" + enable_cdn: 'true' + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that backend_service was deleted + gcp_compute_backend_service_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a backend service that does not exist + gcp_compute_backend_service: + name: "{{ resource_name }}" + backends: + - group: "{{ instancegroup.selfLink }}" + health_checks: + - "{{ healthcheck.selfLink }}" + enable_cdn: 'true' + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a HTTP health check + gcp_compute_http_health_check: + name: httphealthcheck-backendservice + healthy_threshold: 10 + port: 8080 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: healthcheck + ignore_errors: true +- name: delete a instance group + gcp_compute_instance_group: + name: instancegroup-backendservice + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: instancegroup + ignore_errors: true diff --git a/test/integration/targets/gcp_compute_backend_service/tasks/main.yml b/test/integration/targets/gcp_compute_backend_service/tasks/main.yml index 60fa24c4be950c..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_compute_backend_service/tasks/main.yml +++ b/test/integration/targets/gcp_compute_backend_service/tasks/main.yml @@ -1,174 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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: create a instance group - gcp_compute_instance_group: - name: instancegroup-backendservice - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: instancegroup -- name: create a HTTP health check - gcp_compute_http_health_check: - name: httphealthcheck-backendservice - healthy_threshold: 10 - port: 8080 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: healthcheck -- name: delete a backend service - gcp_compute_backend_service: - name: "{{ resource_name }}" - backends: - - group: "{{ instancegroup.selfLink }}" - health_checks: - - "{{ healthcheck.selfLink }}" - enable_cdn: 'true' - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a backend service - gcp_compute_backend_service: - name: "{{ resource_name }}" - backends: - - group: "{{ instancegroup.selfLink }}" - health_checks: - - "{{ healthcheck.selfLink }}" - enable_cdn: 'true' - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that backend_service was created - gcp_compute_backend_service_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a backend service that already exists - gcp_compute_backend_service: - name: "{{ resource_name }}" - backends: - - group: "{{ instancegroup.selfLink }}" - health_checks: - - "{{ healthcheck.selfLink }}" - enable_cdn: 'true' - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a backend service - gcp_compute_backend_service: - name: "{{ resource_name }}" - backends: - - group: "{{ instancegroup.selfLink }}" - health_checks: - - "{{ healthcheck.selfLink }}" - enable_cdn: 'true' - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that backend_service was deleted - gcp_compute_backend_service_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a backend service that does not exist - gcp_compute_backend_service: - name: "{{ resource_name }}" - backends: - - group: "{{ instancegroup.selfLink }}" - health_checks: - - "{{ healthcheck.selfLink }}" - enable_cdn: 'true' - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a HTTP health check - gcp_compute_http_health_check: - name: httphealthcheck-backendservice - healthy_threshold: 10 - port: 8080 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: healthcheck - ignore_errors: true -- name: delete a instance group - gcp_compute_instance_group: - name: instancegroup-backendservice - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: instancegroup - ignore_errors: true +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_disk/tasks/autogen.yml b/test/integration/targets/gcp_compute_disk/tasks/autogen.yml new file mode 100644 index 00000000000000..9dd08f1b485cfc --- /dev/null +++ b/test/integration/targets/gcp_compute_disk/tasks/autogen.yml @@ -0,0 +1,124 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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 disk + gcp_compute_disk: + name: "{{ resource_name }}" + size_gb: 50 + disk_encryption_key: + raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0= + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a disk + gcp_compute_disk: + name: "{{ resource_name }}" + size_gb: 50 + disk_encryption_key: + raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0= + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that disk was created + gcp_compute_disk_info: + filters: + - name = {{ resource_name }} + zone: us-central1-a + 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['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a disk that already exists + gcp_compute_disk: + name: "{{ resource_name }}" + size_gb: 50 + disk_encryption_key: + raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0= + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a disk + gcp_compute_disk: + name: "{{ resource_name }}" + size_gb: 50 + disk_encryption_key: + raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0= + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that disk was deleted + gcp_compute_disk_info: + filters: + - name = {{ resource_name }} + zone: us-central1-a + 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['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a disk that does not exist + gcp_compute_disk: + name: "{{ resource_name }}" + size_gb: 50 + disk_encryption_key: + raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0= + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_compute_disk/tasks/main.yml b/test/integration/targets/gcp_compute_disk/tasks/main.yml index 9dd08f1b485cfc..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_compute_disk/tasks/main.yml +++ b/test/integration/targets/gcp_compute_disk/tasks/main.yml @@ -1,124 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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 disk - gcp_compute_disk: - name: "{{ resource_name }}" - size_gb: 50 - disk_encryption_key: - raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0= - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a disk - gcp_compute_disk: - name: "{{ resource_name }}" - size_gb: 50 - disk_encryption_key: - raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0= - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that disk was created - gcp_compute_disk_info: - filters: - - name = {{ resource_name }} - zone: us-central1-a - 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['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a disk that already exists - gcp_compute_disk: - name: "{{ resource_name }}" - size_gb: 50 - disk_encryption_key: - raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0= - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a disk - gcp_compute_disk: - name: "{{ resource_name }}" - size_gb: 50 - disk_encryption_key: - raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0= - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that disk was deleted - gcp_compute_disk_info: - filters: - - name = {{ resource_name }} - zone: us-central1-a - 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['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a disk that does not exist - gcp_compute_disk: - name: "{{ resource_name }}" - size_gb: 50 - disk_encryption_key: - raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0= - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_firewall/tasks/autogen.yml b/test/integration/targets/gcp_compute_firewall/tasks/autogen.yml new file mode 100644 index 00000000000000..7a775501f52192 --- /dev/null +++ b/test/integration/targets/gcp_compute_firewall/tasks/autogen.yml @@ -0,0 +1,147 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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 firewall + gcp_compute_firewall: + name: "{{ resource_name }}" + allowed: + - ip_protocol: tcp + ports: + - '22' + target_tags: + - test-ssh-server + - staging-ssh-server + source_tags: + - test-ssh-clients + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a firewall + gcp_compute_firewall: + name: "{{ resource_name }}" + allowed: + - ip_protocol: tcp + ports: + - '22' + target_tags: + - test-ssh-server + - staging-ssh-server + source_tags: + - test-ssh-clients + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that firewall was created + gcp_compute_firewall_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a firewall that already exists + gcp_compute_firewall: + name: "{{ resource_name }}" + allowed: + - ip_protocol: tcp + ports: + - '22' + target_tags: + - test-ssh-server + - staging-ssh-server + source_tags: + - test-ssh-clients + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a firewall + gcp_compute_firewall: + name: "{{ resource_name }}" + allowed: + - ip_protocol: tcp + ports: + - '22' + target_tags: + - test-ssh-server + - staging-ssh-server + source_tags: + - test-ssh-clients + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that firewall was deleted + gcp_compute_firewall_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a firewall that does not exist + gcp_compute_firewall: + name: "{{ resource_name }}" + allowed: + - ip_protocol: tcp + ports: + - '22' + target_tags: + - test-ssh-server + - staging-ssh-server + source_tags: + - test-ssh-clients + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_compute_firewall/tasks/main.yml b/test/integration/targets/gcp_compute_firewall/tasks/main.yml index 7a775501f52192..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_compute_firewall/tasks/main.yml +++ b/test/integration/targets/gcp_compute_firewall/tasks/main.yml @@ -1,147 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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 firewall - gcp_compute_firewall: - name: "{{ resource_name }}" - allowed: - - ip_protocol: tcp - ports: - - '22' - target_tags: - - test-ssh-server - - staging-ssh-server - source_tags: - - test-ssh-clients - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a firewall - gcp_compute_firewall: - name: "{{ resource_name }}" - allowed: - - ip_protocol: tcp - ports: - - '22' - target_tags: - - test-ssh-server - - staging-ssh-server - source_tags: - - test-ssh-clients - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that firewall was created - gcp_compute_firewall_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a firewall that already exists - gcp_compute_firewall: - name: "{{ resource_name }}" - allowed: - - ip_protocol: tcp - ports: - - '22' - target_tags: - - test-ssh-server - - staging-ssh-server - source_tags: - - test-ssh-clients - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a firewall - gcp_compute_firewall: - name: "{{ resource_name }}" - allowed: - - ip_protocol: tcp - ports: - - '22' - target_tags: - - test-ssh-server - - staging-ssh-server - source_tags: - - test-ssh-clients - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that firewall was deleted - gcp_compute_firewall_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a firewall that does not exist - gcp_compute_firewall: - name: "{{ resource_name }}" - allowed: - - ip_protocol: tcp - ports: - - '22' - target_tags: - - test-ssh-server - - staging-ssh-server - source_tags: - - test-ssh-clients - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_forwarding_rule/tasks/autogen.yml b/test/integration/targets/gcp_compute_forwarding_rule/tasks/autogen.yml new file mode 100644 index 00000000000000..c46fa9b8bad70e --- /dev/null +++ b/test/integration/targets/gcp_compute_forwarding_rule/tasks/autogen.yml @@ -0,0 +1,170 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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: create a address + gcp_compute_address: + name: address-forwardingrule + region: us-west1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: address +- name: create a target pool + gcp_compute_target_pool: + name: targetpool-forwardingrule + region: us-west1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: targetpool +- name: delete a forwarding rule + gcp_compute_forwarding_rule: + name: "{{ resource_name }}" + region: us-west1 + target: "{{ targetpool }}" + ip_protocol: TCP + port_range: 80-80 + ip_address: "{{ address.address }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a forwarding rule + gcp_compute_forwarding_rule: + name: "{{ resource_name }}" + region: us-west1 + target: "{{ targetpool }}" + ip_protocol: TCP + port_range: 80-80 + ip_address: "{{ address.address }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that forwarding_rule was created + gcp_compute_forwarding_rule_info: + filters: + - name = {{ resource_name }} + 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['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a forwarding rule that already exists + gcp_compute_forwarding_rule: + name: "{{ resource_name }}" + region: us-west1 + target: "{{ targetpool }}" + ip_protocol: TCP + port_range: 80-80 + ip_address: "{{ address.address }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a forwarding rule + gcp_compute_forwarding_rule: + name: "{{ resource_name }}" + region: us-west1 + target: "{{ targetpool }}" + ip_protocol: TCP + port_range: 80-80 + ip_address: "{{ address.address }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that forwarding_rule was deleted + gcp_compute_forwarding_rule_info: + filters: + - name = {{ resource_name }} + 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['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a forwarding rule that does not exist + gcp_compute_forwarding_rule: + name: "{{ resource_name }}" + region: us-west1 + target: "{{ targetpool }}" + ip_protocol: TCP + port_range: 80-80 + ip_address: "{{ address.address }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a target pool + gcp_compute_target_pool: + name: targetpool-forwardingrule + region: us-west1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: targetpool + ignore_errors: true +- name: delete a address + gcp_compute_address: + name: address-forwardingrule + region: us-west1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: address + ignore_errors: true diff --git a/test/integration/targets/gcp_compute_forwarding_rule/tasks/main.yml b/test/integration/targets/gcp_compute_forwarding_rule/tasks/main.yml index c46fa9b8bad70e..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_compute_forwarding_rule/tasks/main.yml +++ b/test/integration/targets/gcp_compute_forwarding_rule/tasks/main.yml @@ -1,170 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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: create a address - gcp_compute_address: - name: address-forwardingrule - region: us-west1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: address -- name: create a target pool - gcp_compute_target_pool: - name: targetpool-forwardingrule - region: us-west1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: targetpool -- name: delete a forwarding rule - gcp_compute_forwarding_rule: - name: "{{ resource_name }}" - region: us-west1 - target: "{{ targetpool }}" - ip_protocol: TCP - port_range: 80-80 - ip_address: "{{ address.address }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a forwarding rule - gcp_compute_forwarding_rule: - name: "{{ resource_name }}" - region: us-west1 - target: "{{ targetpool }}" - ip_protocol: TCP - port_range: 80-80 - ip_address: "{{ address.address }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that forwarding_rule was created - gcp_compute_forwarding_rule_info: - filters: - - name = {{ resource_name }} - 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['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a forwarding rule that already exists - gcp_compute_forwarding_rule: - name: "{{ resource_name }}" - region: us-west1 - target: "{{ targetpool }}" - ip_protocol: TCP - port_range: 80-80 - ip_address: "{{ address.address }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a forwarding rule - gcp_compute_forwarding_rule: - name: "{{ resource_name }}" - region: us-west1 - target: "{{ targetpool }}" - ip_protocol: TCP - port_range: 80-80 - ip_address: "{{ address.address }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that forwarding_rule was deleted - gcp_compute_forwarding_rule_info: - filters: - - name = {{ resource_name }} - 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['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a forwarding rule that does not exist - gcp_compute_forwarding_rule: - name: "{{ resource_name }}" - region: us-west1 - target: "{{ targetpool }}" - ip_protocol: TCP - port_range: 80-80 - ip_address: "{{ address.address }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a target pool - gcp_compute_target_pool: - name: targetpool-forwardingrule - region: us-west1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: targetpool - ignore_errors: true -- name: delete a address - gcp_compute_address: - name: address-forwardingrule - region: us-west1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: address - ignore_errors: true +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_global_address/tasks/autogen.yml b/test/integration/targets/gcp_compute_global_address/tasks/autogen.yml new file mode 100644 index 00000000000000..fdbd73770a14bf --- /dev/null +++ b/test/integration/targets/gcp_compute_global_address/tasks/autogen.yml @@ -0,0 +1,102 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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 global address + gcp_compute_global_address: + name: "{{ resource_name }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a global address + gcp_compute_global_address: + name: "{{ resource_name }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that global_address was created + gcp_compute_global_address_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a global address that already exists + gcp_compute_global_address: + name: "{{ resource_name }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a global address + gcp_compute_global_address: + name: "{{ resource_name }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that global_address was deleted + gcp_compute_global_address_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a global address that does not exist + gcp_compute_global_address: + name: "{{ resource_name }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_compute_global_address/tasks/main.yml b/test/integration/targets/gcp_compute_global_address/tasks/main.yml index fdbd73770a14bf..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_compute_global_address/tasks/main.yml +++ b/test/integration/targets/gcp_compute_global_address/tasks/main.yml @@ -1,102 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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 global address - gcp_compute_global_address: - name: "{{ resource_name }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a global address - gcp_compute_global_address: - name: "{{ resource_name }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that global_address was created - gcp_compute_global_address_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a global address that already exists - gcp_compute_global_address: - name: "{{ resource_name }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a global address - gcp_compute_global_address: - name: "{{ resource_name }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that global_address was deleted - gcp_compute_global_address_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a global address that does not exist - gcp_compute_global_address: - name: "{{ resource_name }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_global_forwarding_rule/tasks/autogen.yml b/test/integration/targets/gcp_compute_global_forwarding_rule/tasks/autogen.yml new file mode 100644 index 00000000000000..234f03604649ca --- /dev/null +++ b/test/integration/targets/gcp_compute_global_forwarding_rule/tasks/autogen.yml @@ -0,0 +1,251 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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: create a global address + gcp_compute_global_address: + name: globaladdress-globalforwardingrule + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: globaladdress +- name: create a instance group + gcp_compute_instance_group: + name: instancegroup-globalforwardingrule + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: instancegroup +- name: create a HTTP health check + gcp_compute_http_health_check: + name: httphealthcheck-globalforwardingrule + healthy_threshold: 10 + port: 8080 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: healthcheck +- name: create a backend service + gcp_compute_backend_service: + name: backendservice-globalforwardingrule + backends: + - group: "{{ instancegroup.selfLink }}" + health_checks: + - "{{ healthcheck.selfLink }}" + enable_cdn: 'true' + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: backendservice +- name: create a URL map + gcp_compute_url_map: + name: urlmap-globalforwardingrule + default_service: "{{ backendservice }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: urlmap +- name: create a target HTTP proxy + gcp_compute_target_http_proxy: + name: targethttpproxy-globalforwardingrule + url_map: "{{ urlmap }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: httpproxy +- name: delete a global forwarding rule + gcp_compute_global_forwarding_rule: + name: "{{ resource_name }}" + ip_address: "{{ globaladdress.address }}" + ip_protocol: TCP + port_range: 80-80 + target: "{{ httpproxy.selfLink }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a global forwarding rule + gcp_compute_global_forwarding_rule: + name: "{{ resource_name }}" + ip_address: "{{ globaladdress.address }}" + ip_protocol: TCP + port_range: 80-80 + target: "{{ httpproxy.selfLink }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that global_forwarding_rule was created + gcp_compute_global_forwarding_rule_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a global forwarding rule that already exists + gcp_compute_global_forwarding_rule: + name: "{{ resource_name }}" + ip_address: "{{ globaladdress.address }}" + ip_protocol: TCP + port_range: 80-80 + target: "{{ httpproxy.selfLink }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a global forwarding rule + gcp_compute_global_forwarding_rule: + name: "{{ resource_name }}" + ip_address: "{{ globaladdress.address }}" + ip_protocol: TCP + port_range: 80-80 + target: "{{ httpproxy.selfLink }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that global_forwarding_rule was deleted + gcp_compute_global_forwarding_rule_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a global forwarding rule that does not exist + gcp_compute_global_forwarding_rule: + name: "{{ resource_name }}" + ip_address: "{{ globaladdress.address }}" + ip_protocol: TCP + port_range: 80-80 + target: "{{ httpproxy.selfLink }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a target HTTP proxy + gcp_compute_target_http_proxy: + name: targethttpproxy-globalforwardingrule + url_map: "{{ urlmap }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: httpproxy + ignore_errors: true +- name: delete a URL map + gcp_compute_url_map: + name: urlmap-globalforwardingrule + default_service: "{{ backendservice }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: urlmap + ignore_errors: true +- name: delete a backend service + gcp_compute_backend_service: + name: backendservice-globalforwardingrule + backends: + - group: "{{ instancegroup.selfLink }}" + health_checks: + - "{{ healthcheck.selfLink }}" + enable_cdn: 'true' + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: backendservice + ignore_errors: true +- name: delete a HTTP health check + gcp_compute_http_health_check: + name: httphealthcheck-globalforwardingrule + healthy_threshold: 10 + port: 8080 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: healthcheck + ignore_errors: true +- name: delete a instance group + gcp_compute_instance_group: + name: instancegroup-globalforwardingrule + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: instancegroup + ignore_errors: true +- name: delete a global address + gcp_compute_global_address: + name: globaladdress-globalforwardingrule + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: globaladdress + ignore_errors: true diff --git a/test/integration/targets/gcp_compute_global_forwarding_rule/tasks/main.yml b/test/integration/targets/gcp_compute_global_forwarding_rule/tasks/main.yml index 234f03604649ca..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_compute_global_forwarding_rule/tasks/main.yml +++ b/test/integration/targets/gcp_compute_global_forwarding_rule/tasks/main.yml @@ -1,251 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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: create a global address - gcp_compute_global_address: - name: globaladdress-globalforwardingrule - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: globaladdress -- name: create a instance group - gcp_compute_instance_group: - name: instancegroup-globalforwardingrule - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: instancegroup -- name: create a HTTP health check - gcp_compute_http_health_check: - name: httphealthcheck-globalforwardingrule - healthy_threshold: 10 - port: 8080 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: healthcheck -- name: create a backend service - gcp_compute_backend_service: - name: backendservice-globalforwardingrule - backends: - - group: "{{ instancegroup.selfLink }}" - health_checks: - - "{{ healthcheck.selfLink }}" - enable_cdn: 'true' - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: backendservice -- name: create a URL map - gcp_compute_url_map: - name: urlmap-globalforwardingrule - default_service: "{{ backendservice }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: urlmap -- name: create a target HTTP proxy - gcp_compute_target_http_proxy: - name: targethttpproxy-globalforwardingrule - url_map: "{{ urlmap }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: httpproxy -- name: delete a global forwarding rule - gcp_compute_global_forwarding_rule: - name: "{{ resource_name }}" - ip_address: "{{ globaladdress.address }}" - ip_protocol: TCP - port_range: 80-80 - target: "{{ httpproxy.selfLink }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a global forwarding rule - gcp_compute_global_forwarding_rule: - name: "{{ resource_name }}" - ip_address: "{{ globaladdress.address }}" - ip_protocol: TCP - port_range: 80-80 - target: "{{ httpproxy.selfLink }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that global_forwarding_rule was created - gcp_compute_global_forwarding_rule_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a global forwarding rule that already exists - gcp_compute_global_forwarding_rule: - name: "{{ resource_name }}" - ip_address: "{{ globaladdress.address }}" - ip_protocol: TCP - port_range: 80-80 - target: "{{ httpproxy.selfLink }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a global forwarding rule - gcp_compute_global_forwarding_rule: - name: "{{ resource_name }}" - ip_address: "{{ globaladdress.address }}" - ip_protocol: TCP - port_range: 80-80 - target: "{{ httpproxy.selfLink }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that global_forwarding_rule was deleted - gcp_compute_global_forwarding_rule_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a global forwarding rule that does not exist - gcp_compute_global_forwarding_rule: - name: "{{ resource_name }}" - ip_address: "{{ globaladdress.address }}" - ip_protocol: TCP - port_range: 80-80 - target: "{{ httpproxy.selfLink }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a target HTTP proxy - gcp_compute_target_http_proxy: - name: targethttpproxy-globalforwardingrule - url_map: "{{ urlmap }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: httpproxy - ignore_errors: true -- name: delete a URL map - gcp_compute_url_map: - name: urlmap-globalforwardingrule - default_service: "{{ backendservice }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: urlmap - ignore_errors: true -- name: delete a backend service - gcp_compute_backend_service: - name: backendservice-globalforwardingrule - backends: - - group: "{{ instancegroup.selfLink }}" - health_checks: - - "{{ healthcheck.selfLink }}" - enable_cdn: 'true' - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: backendservice - ignore_errors: true -- name: delete a HTTP health check - gcp_compute_http_health_check: - name: httphealthcheck-globalforwardingrule - healthy_threshold: 10 - port: 8080 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: healthcheck - ignore_errors: true -- name: delete a instance group - gcp_compute_instance_group: - name: instancegroup-globalforwardingrule - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: instancegroup - ignore_errors: true -- name: delete a global address - gcp_compute_global_address: - name: globaladdress-globalforwardingrule - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: globaladdress - ignore_errors: true +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_health_check/tasks/autogen.yml b/test/integration/targets/gcp_compute_health_check/tasks/autogen.yml new file mode 100644 index 00000000000000..ab1c837cc7c7af --- /dev/null +++ b/test/integration/targets/gcp_compute_health_check/tasks/autogen.yml @@ -0,0 +1,142 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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 health check + gcp_compute_health_check: + name: "{{ resource_name }}" + type: TCP + tcp_health_check: + port_name: service-health + request: ping + response: pong + healthy_threshold: 10 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a health check + gcp_compute_health_check: + name: "{{ resource_name }}" + type: TCP + tcp_health_check: + port_name: service-health + request: ping + response: pong + healthy_threshold: 10 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that health_check was created + gcp_compute_health_check_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a health check that already exists + gcp_compute_health_check: + name: "{{ resource_name }}" + type: TCP + tcp_health_check: + port_name: service-health + request: ping + response: pong + healthy_threshold: 10 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a health check + gcp_compute_health_check: + name: "{{ resource_name }}" + type: TCP + tcp_health_check: + port_name: service-health + request: ping + response: pong + healthy_threshold: 10 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that health_check was deleted + gcp_compute_health_check_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a health check that does not exist + gcp_compute_health_check: + name: "{{ resource_name }}" + type: TCP + tcp_health_check: + port_name: service-health + request: ping + response: pong + healthy_threshold: 10 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_compute_health_check/tasks/main.yml b/test/integration/targets/gcp_compute_health_check/tasks/main.yml index ab1c837cc7c7af..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_compute_health_check/tasks/main.yml +++ b/test/integration/targets/gcp_compute_health_check/tasks/main.yml @@ -1,142 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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 health check - gcp_compute_health_check: - name: "{{ resource_name }}" - type: TCP - tcp_health_check: - port_name: service-health - request: ping - response: pong - healthy_threshold: 10 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a health check - gcp_compute_health_check: - name: "{{ resource_name }}" - type: TCP - tcp_health_check: - port_name: service-health - request: ping - response: pong - healthy_threshold: 10 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that health_check was created - gcp_compute_health_check_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a health check that already exists - gcp_compute_health_check: - name: "{{ resource_name }}" - type: TCP - tcp_health_check: - port_name: service-health - request: ping - response: pong - healthy_threshold: 10 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a health check - gcp_compute_health_check: - name: "{{ resource_name }}" - type: TCP - tcp_health_check: - port_name: service-health - request: ping - response: pong - healthy_threshold: 10 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that health_check was deleted - gcp_compute_health_check_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a health check that does not exist - gcp_compute_health_check: - name: "{{ resource_name }}" - type: TCP - tcp_health_check: - port_name: service-health - request: ping - response: pong - healthy_threshold: 10 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_http_health_check/tasks/autogen.yml b/test/integration/targets/gcp_compute_http_health_check/tasks/autogen.yml new file mode 100644 index 00000000000000..5e27f31b38a808 --- /dev/null +++ b/test/integration/targets/gcp_compute_http_health_check/tasks/autogen.yml @@ -0,0 +1,122 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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 HTTP health check + gcp_compute_http_health_check: + name: "{{ resource_name }}" + healthy_threshold: 10 + port: 8080 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a HTTP health check + gcp_compute_http_health_check: + name: "{{ resource_name }}" + healthy_threshold: 10 + port: 8080 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that http_health_check was created + gcp_compute_http_health_check_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a HTTP health check that already exists + gcp_compute_http_health_check: + name: "{{ resource_name }}" + healthy_threshold: 10 + port: 8080 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a HTTP health check + gcp_compute_http_health_check: + name: "{{ resource_name }}" + healthy_threshold: 10 + port: 8080 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that http_health_check was deleted + gcp_compute_http_health_check_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a HTTP health check that does not exist + gcp_compute_http_health_check: + name: "{{ resource_name }}" + healthy_threshold: 10 + port: 8080 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_compute_http_health_check/tasks/main.yml b/test/integration/targets/gcp_compute_http_health_check/tasks/main.yml index 5e27f31b38a808..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_compute_http_health_check/tasks/main.yml +++ b/test/integration/targets/gcp_compute_http_health_check/tasks/main.yml @@ -1,122 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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 HTTP health check - gcp_compute_http_health_check: - name: "{{ resource_name }}" - healthy_threshold: 10 - port: 8080 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a HTTP health check - gcp_compute_http_health_check: - name: "{{ resource_name }}" - healthy_threshold: 10 - port: 8080 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that http_health_check was created - gcp_compute_http_health_check_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a HTTP health check that already exists - gcp_compute_http_health_check: - name: "{{ resource_name }}" - healthy_threshold: 10 - port: 8080 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a HTTP health check - gcp_compute_http_health_check: - name: "{{ resource_name }}" - healthy_threshold: 10 - port: 8080 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that http_health_check was deleted - gcp_compute_http_health_check_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a HTTP health check that does not exist - gcp_compute_http_health_check: - name: "{{ resource_name }}" - healthy_threshold: 10 - port: 8080 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_https_health_check/tasks/autogen.yml b/test/integration/targets/gcp_compute_https_health_check/tasks/autogen.yml new file mode 100644 index 00000000000000..7d34fc837419e6 --- /dev/null +++ b/test/integration/targets/gcp_compute_https_health_check/tasks/autogen.yml @@ -0,0 +1,122 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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 HTTPS health check + gcp_compute_https_health_check: + name: "{{ resource_name }}" + healthy_threshold: 10 + port: 8080 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a HTTPS health check + gcp_compute_https_health_check: + name: "{{ resource_name }}" + healthy_threshold: 10 + port: 8080 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that https_health_check was created + gcp_compute_https_health_check_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a HTTPS health check that already exists + gcp_compute_https_health_check: + name: "{{ resource_name }}" + healthy_threshold: 10 + port: 8080 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a HTTPS health check + gcp_compute_https_health_check: + name: "{{ resource_name }}" + healthy_threshold: 10 + port: 8080 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that https_health_check was deleted + gcp_compute_https_health_check_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a HTTPS health check that does not exist + gcp_compute_https_health_check: + name: "{{ resource_name }}" + healthy_threshold: 10 + port: 8080 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_compute_https_health_check/tasks/main.yml b/test/integration/targets/gcp_compute_https_health_check/tasks/main.yml index 7d34fc837419e6..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_compute_https_health_check/tasks/main.yml +++ b/test/integration/targets/gcp_compute_https_health_check/tasks/main.yml @@ -1,122 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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 HTTPS health check - gcp_compute_https_health_check: - name: "{{ resource_name }}" - healthy_threshold: 10 - port: 8080 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a HTTPS health check - gcp_compute_https_health_check: - name: "{{ resource_name }}" - healthy_threshold: 10 - port: 8080 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that https_health_check was created - gcp_compute_https_health_check_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a HTTPS health check that already exists - gcp_compute_https_health_check: - name: "{{ resource_name }}" - healthy_threshold: 10 - port: 8080 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a HTTPS health check - gcp_compute_https_health_check: - name: "{{ resource_name }}" - healthy_threshold: 10 - port: 8080 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that https_health_check was deleted - gcp_compute_https_health_check_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a HTTPS health check that does not exist - gcp_compute_https_health_check: - name: "{{ resource_name }}" - healthy_threshold: 10 - port: 8080 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_image/tasks/autogen.yml b/test/integration/targets/gcp_compute_image/tasks/autogen.yml new file mode 100644 index 00000000000000..b51608bc116732 --- /dev/null +++ b/test/integration/targets/gcp_compute_image/tasks/autogen.yml @@ -0,0 +1,129 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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: create a disk + gcp_compute_disk: + name: disk-image + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: disk +- name: delete a image + gcp_compute_image: + name: "{{ resource_name }}" + source_disk: "{{ disk }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a image + gcp_compute_image: + name: "{{ resource_name }}" + source_disk: "{{ disk }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that image was created + gcp_compute_image_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a image that already exists + gcp_compute_image: + name: "{{ resource_name }}" + source_disk: "{{ disk }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a image + gcp_compute_image: + name: "{{ resource_name }}" + source_disk: "{{ disk }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that image was deleted + gcp_compute_image_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a image that does not exist + gcp_compute_image: + name: "{{ resource_name }}" + source_disk: "{{ disk }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a disk + gcp_compute_disk: + name: disk-image + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: disk + ignore_errors: true diff --git a/test/integration/targets/gcp_compute_image/tasks/main.yml b/test/integration/targets/gcp_compute_image/tasks/main.yml index b51608bc116732..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_compute_image/tasks/main.yml +++ b/test/integration/targets/gcp_compute_image/tasks/main.yml @@ -1,129 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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: create a disk - gcp_compute_disk: - name: disk-image - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: disk -- name: delete a image - gcp_compute_image: - name: "{{ resource_name }}" - source_disk: "{{ disk }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a image - gcp_compute_image: - name: "{{ resource_name }}" - source_disk: "{{ disk }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that image was created - gcp_compute_image_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a image that already exists - gcp_compute_image: - name: "{{ resource_name }}" - source_disk: "{{ disk }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a image - gcp_compute_image: - name: "{{ resource_name }}" - source_disk: "{{ disk }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that image was deleted - gcp_compute_image_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a image that does not exist - gcp_compute_image: - name: "{{ resource_name }}" - source_disk: "{{ disk }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a disk - gcp_compute_disk: - name: disk-image - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: disk - ignore_errors: true +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_instance/tasks/autogen.yml b/test/integration/targets/gcp_compute_instance/tasks/autogen.yml new file mode 100644 index 00000000000000..766f33222d4cec --- /dev/null +++ b/test/integration/targets/gcp_compute_instance/tasks/autogen.yml @@ -0,0 +1,251 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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: create a disk + gcp_compute_disk: + name: disk-instance + size_gb: 50 + source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: disk +- name: create a network + gcp_compute_network: + name: network-instance + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: network +- name: create a address + gcp_compute_address: + name: address-instance + region: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: address +- name: delete a instance + gcp_compute_instance: + name: "{{ resource_name }}" + machine_type: n1-standard-1 + disks: + - auto_delete: 'true' + boot: 'true' + source: "{{ disk }}" + metadata: + startup-script-url: gs:://graphite-playground/bootstrap.sh + cost-center: '12345' + labels: + environment: production + network_interfaces: + - network: "{{ network }}" + access_configs: + - name: External NAT + nat_ip: "{{ address }}" + type: ONE_TO_ONE_NAT + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a instance + gcp_compute_instance: + name: "{{ resource_name }}" + machine_type: n1-standard-1 + disks: + - auto_delete: 'true' + boot: 'true' + source: "{{ disk }}" + metadata: + startup-script-url: gs:://graphite-playground/bootstrap.sh + cost-center: '12345' + labels: + environment: production + network_interfaces: + - network: "{{ network }}" + access_configs: + - name: External NAT + nat_ip: "{{ address }}" + type: ONE_TO_ONE_NAT + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that instance was created + gcp_compute_instance_info: + filters: + - name = {{ resource_name }} + zone: us-central1-a + 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['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a instance that already exists + gcp_compute_instance: + name: "{{ resource_name }}" + machine_type: n1-standard-1 + disks: + - auto_delete: 'true' + boot: 'true' + source: "{{ disk }}" + metadata: + startup-script-url: gs:://graphite-playground/bootstrap.sh + cost-center: '12345' + labels: + environment: production + network_interfaces: + - network: "{{ network }}" + access_configs: + - name: External NAT + nat_ip: "{{ address }}" + type: ONE_TO_ONE_NAT + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a instance + gcp_compute_instance: + name: "{{ resource_name }}" + machine_type: n1-standard-1 + disks: + - auto_delete: 'true' + boot: 'true' + source: "{{ disk }}" + metadata: + startup-script-url: gs:://graphite-playground/bootstrap.sh + cost-center: '12345' + labels: + environment: production + network_interfaces: + - network: "{{ network }}" + access_configs: + - name: External NAT + nat_ip: "{{ address }}" + type: ONE_TO_ONE_NAT + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that instance was deleted + gcp_compute_instance_info: + filters: + - name = {{ resource_name }} + zone: us-central1-a + 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['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a instance that does not exist + gcp_compute_instance: + name: "{{ resource_name }}" + machine_type: n1-standard-1 + disks: + - auto_delete: 'true' + boot: 'true' + source: "{{ disk }}" + metadata: + startup-script-url: gs:://graphite-playground/bootstrap.sh + cost-center: '12345' + labels: + environment: production + network_interfaces: + - network: "{{ network }}" + access_configs: + - name: External NAT + nat_ip: "{{ address }}" + type: ONE_TO_ONE_NAT + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a address + gcp_compute_address: + name: address-instance + region: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: address + ignore_errors: true +- name: delete a network + gcp_compute_network: + name: network-instance + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: network + ignore_errors: true +- name: delete a disk + gcp_compute_disk: + name: disk-instance + size_gb: 50 + source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: disk + ignore_errors: true diff --git a/test/integration/targets/gcp_compute_instance/tasks/main.yml b/test/integration/targets/gcp_compute_instance/tasks/main.yml index 766f33222d4cec..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_compute_instance/tasks/main.yml +++ b/test/integration/targets/gcp_compute_instance/tasks/main.yml @@ -1,251 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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: create a disk - gcp_compute_disk: - name: disk-instance - size_gb: 50 - source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: disk -- name: create a network - gcp_compute_network: - name: network-instance - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: network -- name: create a address - gcp_compute_address: - name: address-instance - region: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: address -- name: delete a instance - gcp_compute_instance: - name: "{{ resource_name }}" - machine_type: n1-standard-1 - disks: - - auto_delete: 'true' - boot: 'true' - source: "{{ disk }}" - metadata: - startup-script-url: gs:://graphite-playground/bootstrap.sh - cost-center: '12345' - labels: - environment: production - network_interfaces: - - network: "{{ network }}" - access_configs: - - name: External NAT - nat_ip: "{{ address }}" - type: ONE_TO_ONE_NAT - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a instance - gcp_compute_instance: - name: "{{ resource_name }}" - machine_type: n1-standard-1 - disks: - - auto_delete: 'true' - boot: 'true' - source: "{{ disk }}" - metadata: - startup-script-url: gs:://graphite-playground/bootstrap.sh - cost-center: '12345' - labels: - environment: production - network_interfaces: - - network: "{{ network }}" - access_configs: - - name: External NAT - nat_ip: "{{ address }}" - type: ONE_TO_ONE_NAT - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that instance was created - gcp_compute_instance_info: - filters: - - name = {{ resource_name }} - zone: us-central1-a - 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['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a instance that already exists - gcp_compute_instance: - name: "{{ resource_name }}" - machine_type: n1-standard-1 - disks: - - auto_delete: 'true' - boot: 'true' - source: "{{ disk }}" - metadata: - startup-script-url: gs:://graphite-playground/bootstrap.sh - cost-center: '12345' - labels: - environment: production - network_interfaces: - - network: "{{ network }}" - access_configs: - - name: External NAT - nat_ip: "{{ address }}" - type: ONE_TO_ONE_NAT - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a instance - gcp_compute_instance: - name: "{{ resource_name }}" - machine_type: n1-standard-1 - disks: - - auto_delete: 'true' - boot: 'true' - source: "{{ disk }}" - metadata: - startup-script-url: gs:://graphite-playground/bootstrap.sh - cost-center: '12345' - labels: - environment: production - network_interfaces: - - network: "{{ network }}" - access_configs: - - name: External NAT - nat_ip: "{{ address }}" - type: ONE_TO_ONE_NAT - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that instance was deleted - gcp_compute_instance_info: - filters: - - name = {{ resource_name }} - zone: us-central1-a - 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['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a instance that does not exist - gcp_compute_instance: - name: "{{ resource_name }}" - machine_type: n1-standard-1 - disks: - - auto_delete: 'true' - boot: 'true' - source: "{{ disk }}" - metadata: - startup-script-url: gs:://graphite-playground/bootstrap.sh - cost-center: '12345' - labels: - environment: production - network_interfaces: - - network: "{{ network }}" - access_configs: - - name: External NAT - nat_ip: "{{ address }}" - type: ONE_TO_ONE_NAT - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a address - gcp_compute_address: - name: address-instance - region: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: address - ignore_errors: true -- name: delete a network - gcp_compute_network: - name: network-instance - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: network - ignore_errors: true -- name: delete a disk - gcp_compute_disk: - name: disk-instance - size_gb: 50 - source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: disk - ignore_errors: true +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_instance_group/tasks/autogen.yml b/test/integration/targets/gcp_compute_instance_group/tasks/autogen.yml new file mode 100644 index 00000000000000..b16a128bbd86f5 --- /dev/null +++ b/test/integration/targets/gcp_compute_instance_group/tasks/autogen.yml @@ -0,0 +1,149 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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: create a network + gcp_compute_network: + name: network-instancegroup + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: network +- name: delete a instance group + gcp_compute_instance_group: + name: "{{ resource_name }}" + named_ports: + - name: ansible + port: 1234 + network: "{{ network }}" + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a instance group + gcp_compute_instance_group: + name: "{{ resource_name }}" + named_ports: + - name: ansible + port: 1234 + network: "{{ network }}" + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that instance_group was created + gcp_compute_instance_group_info: + filters: + - name = {{ resource_name }} + zone: us-central1-a + 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['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a instance group that already exists + gcp_compute_instance_group: + name: "{{ resource_name }}" + named_ports: + - name: ansible + port: 1234 + network: "{{ network }}" + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a instance group + gcp_compute_instance_group: + name: "{{ resource_name }}" + named_ports: + - name: ansible + port: 1234 + network: "{{ network }}" + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that instance_group was deleted + gcp_compute_instance_group_info: + filters: + - name = {{ resource_name }} + zone: us-central1-a + 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['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a instance group that does not exist + gcp_compute_instance_group: + name: "{{ resource_name }}" + named_ports: + - name: ansible + port: 1234 + network: "{{ network }}" + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a network + gcp_compute_network: + name: network-instancegroup + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: network + ignore_errors: true diff --git a/test/integration/targets/gcp_compute_instance_group/tasks/main.yml b/test/integration/targets/gcp_compute_instance_group/tasks/main.yml index b16a128bbd86f5..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_compute_instance_group/tasks/main.yml +++ b/test/integration/targets/gcp_compute_instance_group/tasks/main.yml @@ -1,149 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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: create a network - gcp_compute_network: - name: network-instancegroup - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: network -- name: delete a instance group - gcp_compute_instance_group: - name: "{{ resource_name }}" - named_ports: - - name: ansible - port: 1234 - network: "{{ network }}" - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a instance group - gcp_compute_instance_group: - name: "{{ resource_name }}" - named_ports: - - name: ansible - port: 1234 - network: "{{ network }}" - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that instance_group was created - gcp_compute_instance_group_info: - filters: - - name = {{ resource_name }} - zone: us-central1-a - 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['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a instance group that already exists - gcp_compute_instance_group: - name: "{{ resource_name }}" - named_ports: - - name: ansible - port: 1234 - network: "{{ network }}" - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a instance group - gcp_compute_instance_group: - name: "{{ resource_name }}" - named_ports: - - name: ansible - port: 1234 - network: "{{ network }}" - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that instance_group was deleted - gcp_compute_instance_group_info: - filters: - - name = {{ resource_name }} - zone: us-central1-a - 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['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a instance group that does not exist - gcp_compute_instance_group: - name: "{{ resource_name }}" - named_ports: - - name: ansible - port: 1234 - network: "{{ network }}" - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a network - gcp_compute_network: - name: network-instancegroup - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: network - ignore_errors: true +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_instance_group_manager/tasks/autogen.yml b/test/integration/targets/gcp_compute_instance_group_manager/tasks/autogen.yml new file mode 100644 index 00000000000000..39c62e3956cfed --- /dev/null +++ b/test/integration/targets/gcp_compute_instance_group_manager/tasks/autogen.yml @@ -0,0 +1,206 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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: create a network + gcp_compute_network: + name: network-instancetemplate + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: network +- name: create a address + gcp_compute_address: + name: address-instancetemplate + region: us-west1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: address +- name: create a instance template + gcp_compute_instance_template: + name: "{{ resource_name }}" + properties: + disks: + - auto_delete: 'true' + boot: 'true' + initialize_params: + source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts + machine_type: n1-standard-1 + network_interfaces: + - network: "{{ network }}" + access_configs: + - name: test-config + type: ONE_TO_ONE_NAT + nat_ip: "{{ address }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: instancetemplate +- name: delete a instance group manager + gcp_compute_instance_group_manager: + name: "{{ resource_name }}" + base_instance_name: test1-child + instance_template: "{{ instancetemplate }}" + target_size: 3 + zone: us-west1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a instance group manager + gcp_compute_instance_group_manager: + name: "{{ resource_name }}" + base_instance_name: test1-child + instance_template: "{{ instancetemplate }}" + target_size: 3 + zone: us-west1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that instance_group_manager was created + gcp_compute_instance_group_manager_info: + filters: + - name = {{ resource_name }} + zone: us-west1-a + 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['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a instance group manager that already exists + gcp_compute_instance_group_manager: + name: "{{ resource_name }}" + base_instance_name: test1-child + instance_template: "{{ instancetemplate }}" + target_size: 3 + zone: us-west1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a instance group manager + gcp_compute_instance_group_manager: + name: "{{ resource_name }}" + base_instance_name: test1-child + instance_template: "{{ instancetemplate }}" + target_size: 3 + zone: us-west1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that instance_group_manager was deleted + gcp_compute_instance_group_manager_info: + filters: + - name = {{ resource_name }} + zone: us-west1-a + 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['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a instance group manager that does not exist + gcp_compute_instance_group_manager: + name: "{{ resource_name }}" + base_instance_name: test1-child + instance_template: "{{ instancetemplate }}" + target_size: 3 + zone: us-west1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a instance template + gcp_compute_instance_template: + name: "{{ resource_name }}" + properties: + disks: + - auto_delete: 'true' + boot: 'true' + initialize_params: + source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts + machine_type: n1-standard-1 + network_interfaces: + - network: "{{ network }}" + access_configs: + - name: test-config + type: ONE_TO_ONE_NAT + nat_ip: "{{ address }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: instancetemplate + ignore_errors: true +- name: delete a address + gcp_compute_address: + name: address-instancetemplate + region: us-west1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: address + ignore_errors: true +- name: delete a network + gcp_compute_network: + name: network-instancetemplate + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: network + ignore_errors: true diff --git a/test/integration/targets/gcp_compute_instance_group_manager/tasks/main.yml b/test/integration/targets/gcp_compute_instance_group_manager/tasks/main.yml index 39c62e3956cfed..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_compute_instance_group_manager/tasks/main.yml +++ b/test/integration/targets/gcp_compute_instance_group_manager/tasks/main.yml @@ -1,206 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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: create a network - gcp_compute_network: - name: network-instancetemplate - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: network -- name: create a address - gcp_compute_address: - name: address-instancetemplate - region: us-west1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: address -- name: create a instance template - gcp_compute_instance_template: - name: "{{ resource_name }}" - properties: - disks: - - auto_delete: 'true' - boot: 'true' - initialize_params: - source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts - machine_type: n1-standard-1 - network_interfaces: - - network: "{{ network }}" - access_configs: - - name: test-config - type: ONE_TO_ONE_NAT - nat_ip: "{{ address }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: instancetemplate -- name: delete a instance group manager - gcp_compute_instance_group_manager: - name: "{{ resource_name }}" - base_instance_name: test1-child - instance_template: "{{ instancetemplate }}" - target_size: 3 - zone: us-west1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a instance group manager - gcp_compute_instance_group_manager: - name: "{{ resource_name }}" - base_instance_name: test1-child - instance_template: "{{ instancetemplate }}" - target_size: 3 - zone: us-west1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that instance_group_manager was created - gcp_compute_instance_group_manager_info: - filters: - - name = {{ resource_name }} - zone: us-west1-a - 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['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a instance group manager that already exists - gcp_compute_instance_group_manager: - name: "{{ resource_name }}" - base_instance_name: test1-child - instance_template: "{{ instancetemplate }}" - target_size: 3 - zone: us-west1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a instance group manager - gcp_compute_instance_group_manager: - name: "{{ resource_name }}" - base_instance_name: test1-child - instance_template: "{{ instancetemplate }}" - target_size: 3 - zone: us-west1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that instance_group_manager was deleted - gcp_compute_instance_group_manager_info: - filters: - - name = {{ resource_name }} - zone: us-west1-a - 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['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a instance group manager that does not exist - gcp_compute_instance_group_manager: - name: "{{ resource_name }}" - base_instance_name: test1-child - instance_template: "{{ instancetemplate }}" - target_size: 3 - zone: us-west1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a instance template - gcp_compute_instance_template: - name: "{{ resource_name }}" - properties: - disks: - - auto_delete: 'true' - boot: 'true' - initialize_params: - source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts - machine_type: n1-standard-1 - network_interfaces: - - network: "{{ network }}" - access_configs: - - name: test-config - type: ONE_TO_ONE_NAT - nat_ip: "{{ address }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: instancetemplate - ignore_errors: true -- name: delete a address - gcp_compute_address: - name: address-instancetemplate - region: us-west1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: address - ignore_errors: true -- name: delete a network - gcp_compute_network: - name: network-instancetemplate - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: network - ignore_errors: true +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_instance_template/tasks/autogen.yml b/test/integration/targets/gcp_compute_instance_template/tasks/autogen.yml new file mode 100644 index 00000000000000..b1336624bc8dfe --- /dev/null +++ b/test/integration/targets/gcp_compute_instance_template/tasks/autogen.yml @@ -0,0 +1,206 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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: create a network + gcp_compute_network: + name: network-instancetemplate + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: network +- name: create a address + gcp_compute_address: + name: address-instancetemplate + region: us-west1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: address +- name: delete a instance template + gcp_compute_instance_template: + name: "{{ resource_name }}" + properties: + disks: + - auto_delete: 'true' + boot: 'true' + initialize_params: + source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts + machine_type: n1-standard-1 + network_interfaces: + - network: "{{ network }}" + access_configs: + - name: test-config + type: ONE_TO_ONE_NAT + nat_ip: "{{ address }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a instance template + gcp_compute_instance_template: + name: "{{ resource_name }}" + properties: + disks: + - auto_delete: 'true' + boot: 'true' + initialize_params: + source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts + machine_type: n1-standard-1 + network_interfaces: + - network: "{{ network }}" + access_configs: + - name: test-config + type: ONE_TO_ONE_NAT + nat_ip: "{{ address }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that instance_template was created + gcp_compute_instance_template_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a instance template that already exists + gcp_compute_instance_template: + name: "{{ resource_name }}" + properties: + disks: + - auto_delete: 'true' + boot: 'true' + initialize_params: + source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts + machine_type: n1-standard-1 + network_interfaces: + - network: "{{ network }}" + access_configs: + - name: test-config + type: ONE_TO_ONE_NAT + nat_ip: "{{ address }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a instance template + gcp_compute_instance_template: + name: "{{ resource_name }}" + properties: + disks: + - auto_delete: 'true' + boot: 'true' + initialize_params: + source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts + machine_type: n1-standard-1 + network_interfaces: + - network: "{{ network }}" + access_configs: + - name: test-config + type: ONE_TO_ONE_NAT + nat_ip: "{{ address }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that instance_template was deleted + gcp_compute_instance_template_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a instance template that does not exist + gcp_compute_instance_template: + name: "{{ resource_name }}" + properties: + disks: + - auto_delete: 'true' + boot: 'true' + initialize_params: + source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts + machine_type: n1-standard-1 + network_interfaces: + - network: "{{ network }}" + access_configs: + - name: test-config + type: ONE_TO_ONE_NAT + nat_ip: "{{ address }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a address + gcp_compute_address: + name: address-instancetemplate + region: us-west1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: address + ignore_errors: true +- name: delete a network + gcp_compute_network: + name: network-instancetemplate + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: network + ignore_errors: true diff --git a/test/integration/targets/gcp_compute_instance_template/tasks/main.yml b/test/integration/targets/gcp_compute_instance_template/tasks/main.yml index b1336624bc8dfe..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_compute_instance_template/tasks/main.yml +++ b/test/integration/targets/gcp_compute_instance_template/tasks/main.yml @@ -1,206 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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: create a network - gcp_compute_network: - name: network-instancetemplate - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: network -- name: create a address - gcp_compute_address: - name: address-instancetemplate - region: us-west1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: address -- name: delete a instance template - gcp_compute_instance_template: - name: "{{ resource_name }}" - properties: - disks: - - auto_delete: 'true' - boot: 'true' - initialize_params: - source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts - machine_type: n1-standard-1 - network_interfaces: - - network: "{{ network }}" - access_configs: - - name: test-config - type: ONE_TO_ONE_NAT - nat_ip: "{{ address }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a instance template - gcp_compute_instance_template: - name: "{{ resource_name }}" - properties: - disks: - - auto_delete: 'true' - boot: 'true' - initialize_params: - source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts - machine_type: n1-standard-1 - network_interfaces: - - network: "{{ network }}" - access_configs: - - name: test-config - type: ONE_TO_ONE_NAT - nat_ip: "{{ address }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that instance_template was created - gcp_compute_instance_template_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a instance template that already exists - gcp_compute_instance_template: - name: "{{ resource_name }}" - properties: - disks: - - auto_delete: 'true' - boot: 'true' - initialize_params: - source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts - machine_type: n1-standard-1 - network_interfaces: - - network: "{{ network }}" - access_configs: - - name: test-config - type: ONE_TO_ONE_NAT - nat_ip: "{{ address }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a instance template - gcp_compute_instance_template: - name: "{{ resource_name }}" - properties: - disks: - - auto_delete: 'true' - boot: 'true' - initialize_params: - source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts - machine_type: n1-standard-1 - network_interfaces: - - network: "{{ network }}" - access_configs: - - name: test-config - type: ONE_TO_ONE_NAT - nat_ip: "{{ address }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that instance_template was deleted - gcp_compute_instance_template_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a instance template that does not exist - gcp_compute_instance_template: - name: "{{ resource_name }}" - properties: - disks: - - auto_delete: 'true' - boot: 'true' - initialize_params: - source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts - machine_type: n1-standard-1 - network_interfaces: - - network: "{{ network }}" - access_configs: - - name: test-config - type: ONE_TO_ONE_NAT - nat_ip: "{{ address }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a address - gcp_compute_address: - name: address-instancetemplate - region: us-west1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: address - ignore_errors: true -- name: delete a network - gcp_compute_network: - name: network-instancetemplate - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: network - ignore_errors: true +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_network/tasks/autogen.yml b/test/integration/targets/gcp_compute_network/tasks/autogen.yml new file mode 100644 index 00000000000000..fa121c8fbebb36 --- /dev/null +++ b/test/integration/targets/gcp_compute_network/tasks/autogen.yml @@ -0,0 +1,107 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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 }}" + 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 }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that network was created + gcp_compute_network_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- 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 }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- 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 }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that network was deleted + gcp_compute_network_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- 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 }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_compute_network/tasks/main.yml b/test/integration/targets/gcp_compute_network/tasks/main.yml index fa121c8fbebb36..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_compute_network/tasks/main.yml +++ b/test/integration/targets/gcp_compute_network/tasks/main.yml @@ -1,107 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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 }}" - 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 }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that network was created - gcp_compute_network_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- 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 }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- 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 }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that network was deleted - gcp_compute_network_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- 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 }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_region_disk/tasks/autogen.yml b/test/integration/targets/gcp_compute_region_disk/tasks/autogen.yml new file mode 100644 index 00000000000000..462dd56af10369 --- /dev/null +++ b/test/integration/targets/gcp_compute_region_disk/tasks/autogen.yml @@ -0,0 +1,139 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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 region disk + gcp_compute_region_disk: + name: "{{ resource_name }}" + size_gb: 500 + disk_encryption_key: + raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0= + region: us-central1 + replica_zones: + - https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-a + - https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-b + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a region disk + gcp_compute_region_disk: + name: "{{ resource_name }}" + size_gb: 500 + disk_encryption_key: + raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0= + region: us-central1 + replica_zones: + - https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-a + - https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-b + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that region_disk was created + gcp_compute_region_disk_info: + filters: + - name = {{ resource_name }} + region: us-central1 + 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['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a region disk that already exists + gcp_compute_region_disk: + name: "{{ resource_name }}" + size_gb: 500 + disk_encryption_key: + raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0= + region: us-central1 + replica_zones: + - https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-a + - https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-b + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a region disk + gcp_compute_region_disk: + name: "{{ resource_name }}" + size_gb: 500 + disk_encryption_key: + raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0= + region: us-central1 + replica_zones: + - https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-a + - https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-b + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that region_disk was deleted + gcp_compute_region_disk_info: + filters: + - name = {{ resource_name }} + region: us-central1 + 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['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a region disk that does not exist + gcp_compute_region_disk: + name: "{{ resource_name }}" + size_gb: 500 + disk_encryption_key: + raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0= + region: us-central1 + replica_zones: + - https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-a + - https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-b + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_compute_region_disk/tasks/main.yml b/test/integration/targets/gcp_compute_region_disk/tasks/main.yml index 462dd56af10369..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_compute_region_disk/tasks/main.yml +++ b/test/integration/targets/gcp_compute_region_disk/tasks/main.yml @@ -1,139 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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 region disk - gcp_compute_region_disk: - name: "{{ resource_name }}" - size_gb: 500 - disk_encryption_key: - raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0= - region: us-central1 - replica_zones: - - https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-a - - https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-b - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a region disk - gcp_compute_region_disk: - name: "{{ resource_name }}" - size_gb: 500 - disk_encryption_key: - raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0= - region: us-central1 - replica_zones: - - https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-a - - https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-b - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that region_disk was created - gcp_compute_region_disk_info: - filters: - - name = {{ resource_name }} - region: us-central1 - 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['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a region disk that already exists - gcp_compute_region_disk: - name: "{{ resource_name }}" - size_gb: 500 - disk_encryption_key: - raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0= - region: us-central1 - replica_zones: - - https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-a - - https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-b - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a region disk - gcp_compute_region_disk: - name: "{{ resource_name }}" - size_gb: 500 - disk_encryption_key: - raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0= - region: us-central1 - replica_zones: - - https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-a - - https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-b - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that region_disk was deleted - gcp_compute_region_disk_info: - filters: - - name = {{ resource_name }} - region: us-central1 - 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['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a region disk that does not exist - gcp_compute_region_disk: - name: "{{ resource_name }}" - size_gb: 500 - disk_encryption_key: - raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0= - region: us-central1 - replica_zones: - - https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-a - - https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-b - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_route/tasks/autogen.yml b/test/integration/targets/gcp_compute_route/tasks/autogen.yml new file mode 100644 index 00000000000000..8ffb557a61e35f --- /dev/null +++ b/test/integration/targets/gcp_compute_route/tasks/autogen.yml @@ -0,0 +1,152 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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: create a network + gcp_compute_network: + name: network-route + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: network +- name: delete a route + gcp_compute_route: + name: "{{ resource_name }}" + dest_range: 192.168.6.0/24 + next_hop_gateway: global/gateways/default-internet-gateway + network: "{{ network }}" + tags: + - backends + - databases + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a route + gcp_compute_route: + name: "{{ resource_name }}" + dest_range: 192.168.6.0/24 + next_hop_gateway: global/gateways/default-internet-gateway + network: "{{ network }}" + tags: + - backends + - databases + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that route was created + gcp_compute_route_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a route that already exists + gcp_compute_route: + name: "{{ resource_name }}" + dest_range: 192.168.6.0/24 + next_hop_gateway: global/gateways/default-internet-gateway + network: "{{ network }}" + tags: + - backends + - databases + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a route + gcp_compute_route: + name: "{{ resource_name }}" + dest_range: 192.168.6.0/24 + next_hop_gateway: global/gateways/default-internet-gateway + network: "{{ network }}" + tags: + - backends + - databases + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that route was deleted + gcp_compute_route_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a route that does not exist + gcp_compute_route: + name: "{{ resource_name }}" + dest_range: 192.168.6.0/24 + next_hop_gateway: global/gateways/default-internet-gateway + network: "{{ network }}" + tags: + - backends + - databases + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a network + gcp_compute_network: + name: network-route + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: network + ignore_errors: true diff --git a/test/integration/targets/gcp_compute_route/tasks/main.yml b/test/integration/targets/gcp_compute_route/tasks/main.yml index 8ffb557a61e35f..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_compute_route/tasks/main.yml +++ b/test/integration/targets/gcp_compute_route/tasks/main.yml @@ -1,152 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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: create a network - gcp_compute_network: - name: network-route - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: network -- name: delete a route - gcp_compute_route: - name: "{{ resource_name }}" - dest_range: 192.168.6.0/24 - next_hop_gateway: global/gateways/default-internet-gateway - network: "{{ network }}" - tags: - - backends - - databases - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a route - gcp_compute_route: - name: "{{ resource_name }}" - dest_range: 192.168.6.0/24 - next_hop_gateway: global/gateways/default-internet-gateway - network: "{{ network }}" - tags: - - backends - - databases - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that route was created - gcp_compute_route_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a route that already exists - gcp_compute_route: - name: "{{ resource_name }}" - dest_range: 192.168.6.0/24 - next_hop_gateway: global/gateways/default-internet-gateway - network: "{{ network }}" - tags: - - backends - - databases - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a route - gcp_compute_route: - name: "{{ resource_name }}" - dest_range: 192.168.6.0/24 - next_hop_gateway: global/gateways/default-internet-gateway - network: "{{ network }}" - tags: - - backends - - databases - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that route was deleted - gcp_compute_route_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a route that does not exist - gcp_compute_route: - name: "{{ resource_name }}" - dest_range: 192.168.6.0/24 - next_hop_gateway: global/gateways/default-internet-gateway - network: "{{ network }}" - tags: - - backends - - databases - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a network - gcp_compute_network: - name: network-route - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: network - ignore_errors: true +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_router/tasks/autogen.yml b/test/integration/targets/gcp_compute_router/tasks/autogen.yml new file mode 100644 index 00000000000000..8a80e03efd4a86 --- /dev/null +++ b/test/integration/targets/gcp_compute_router/tasks/autogen.yml @@ -0,0 +1,174 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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: create a network + gcp_compute_network: + name: network-router + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: network +- name: delete a router + gcp_compute_router: + name: "{{ resource_name }}" + network: "{{ network }}" + bgp: + asn: 64514 + advertise_mode: CUSTOM + advertised_groups: + - ALL_SUBNETS + advertised_ip_ranges: + - range: 1.2.3.4 + - range: 6.7.0.0/16 + region: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a router + gcp_compute_router: + name: "{{ resource_name }}" + network: "{{ network }}" + bgp: + asn: 64514 + advertise_mode: CUSTOM + advertised_groups: + - ALL_SUBNETS + advertised_ip_ranges: + - range: 1.2.3.4 + - range: 6.7.0.0/16 + region: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that router was created + gcp_compute_router_info: + filters: + - name = {{ resource_name }} + region: us-central1 + 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['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a router that already exists + gcp_compute_router: + name: "{{ resource_name }}" + network: "{{ network }}" + bgp: + asn: 64514 + advertise_mode: CUSTOM + advertised_groups: + - ALL_SUBNETS + advertised_ip_ranges: + - range: 1.2.3.4 + - range: 6.7.0.0/16 + region: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a router + gcp_compute_router: + name: "{{ resource_name }}" + network: "{{ network }}" + bgp: + asn: 64514 + advertise_mode: CUSTOM + advertised_groups: + - ALL_SUBNETS + advertised_ip_ranges: + - range: 1.2.3.4 + - range: 6.7.0.0/16 + region: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that router was deleted + gcp_compute_router_info: + filters: + - name = {{ resource_name }} + region: us-central1 + 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['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a router that does not exist + gcp_compute_router: + name: "{{ resource_name }}" + network: "{{ network }}" + bgp: + asn: 64514 + advertise_mode: CUSTOM + advertised_groups: + - ALL_SUBNETS + advertised_ip_ranges: + - range: 1.2.3.4 + - range: 6.7.0.0/16 + region: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a network + gcp_compute_network: + name: network-router + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: network + ignore_errors: true diff --git a/test/integration/targets/gcp_compute_router/tasks/main.yml b/test/integration/targets/gcp_compute_router/tasks/main.yml index 8a80e03efd4a86..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_compute_router/tasks/main.yml +++ b/test/integration/targets/gcp_compute_router/tasks/main.yml @@ -1,174 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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: create a network - gcp_compute_network: - name: network-router - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: network -- name: delete a router - gcp_compute_router: - name: "{{ resource_name }}" - network: "{{ network }}" - bgp: - asn: 64514 - advertise_mode: CUSTOM - advertised_groups: - - ALL_SUBNETS - advertised_ip_ranges: - - range: 1.2.3.4 - - range: 6.7.0.0/16 - region: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a router - gcp_compute_router: - name: "{{ resource_name }}" - network: "{{ network }}" - bgp: - asn: 64514 - advertise_mode: CUSTOM - advertised_groups: - - ALL_SUBNETS - advertised_ip_ranges: - - range: 1.2.3.4 - - range: 6.7.0.0/16 - region: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that router was created - gcp_compute_router_info: - filters: - - name = {{ resource_name }} - region: us-central1 - 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['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a router that already exists - gcp_compute_router: - name: "{{ resource_name }}" - network: "{{ network }}" - bgp: - asn: 64514 - advertise_mode: CUSTOM - advertised_groups: - - ALL_SUBNETS - advertised_ip_ranges: - - range: 1.2.3.4 - - range: 6.7.0.0/16 - region: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a router - gcp_compute_router: - name: "{{ resource_name }}" - network: "{{ network }}" - bgp: - asn: 64514 - advertise_mode: CUSTOM - advertised_groups: - - ALL_SUBNETS - advertised_ip_ranges: - - range: 1.2.3.4 - - range: 6.7.0.0/16 - region: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that router was deleted - gcp_compute_router_info: - filters: - - name = {{ resource_name }} - region: us-central1 - 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['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a router that does not exist - gcp_compute_router: - name: "{{ resource_name }}" - network: "{{ network }}" - bgp: - asn: 64514 - advertise_mode: CUSTOM - advertised_groups: - - ALL_SUBNETS - advertised_ip_ranges: - - range: 1.2.3.4 - - range: 6.7.0.0/16 - region: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a network - gcp_compute_network: - name: network-router - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: network - ignore_errors: true +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_snapshot/tasks/autogen.yml b/test/integration/targets/gcp_compute_snapshot/tasks/autogen.yml new file mode 100644 index 00000000000000..f3f79328388fdd --- /dev/null +++ b/test/integration/targets/gcp_compute_snapshot/tasks/autogen.yml @@ -0,0 +1,144 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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: create a disk + gcp_compute_disk: + name: disk-snapshot + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: disk +- name: delete a snapshot + gcp_compute_snapshot: + name: "{{ resource_name }}" + source_disk: "{{ disk }}" + zone: us-central1-a + labels: + my_label: value + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a snapshot + gcp_compute_snapshot: + name: "{{ resource_name }}" + source_disk: "{{ disk }}" + zone: us-central1-a + labels: + my_label: value + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that snapshot was created + gcp_compute_snapshot_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a snapshot that already exists + gcp_compute_snapshot: + name: "{{ resource_name }}" + source_disk: "{{ disk }}" + zone: us-central1-a + labels: + my_label: value + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a snapshot + gcp_compute_snapshot: + name: "{{ resource_name }}" + source_disk: "{{ disk }}" + zone: us-central1-a + labels: + my_label: value + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that snapshot was deleted + gcp_compute_snapshot_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a snapshot that does not exist + gcp_compute_snapshot: + name: "{{ resource_name }}" + source_disk: "{{ disk }}" + zone: us-central1-a + labels: + my_label: value + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a disk + gcp_compute_disk: + name: disk-snapshot + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: disk + ignore_errors: true diff --git a/test/integration/targets/gcp_compute_snapshot/tasks/main.yml b/test/integration/targets/gcp_compute_snapshot/tasks/main.yml index f3f79328388fdd..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_compute_snapshot/tasks/main.yml +++ b/test/integration/targets/gcp_compute_snapshot/tasks/main.yml @@ -1,144 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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: create a disk - gcp_compute_disk: - name: disk-snapshot - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: disk -- name: delete a snapshot - gcp_compute_snapshot: - name: "{{ resource_name }}" - source_disk: "{{ disk }}" - zone: us-central1-a - labels: - my_label: value - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a snapshot - gcp_compute_snapshot: - name: "{{ resource_name }}" - source_disk: "{{ disk }}" - zone: us-central1-a - labels: - my_label: value - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that snapshot was created - gcp_compute_snapshot_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a snapshot that already exists - gcp_compute_snapshot: - name: "{{ resource_name }}" - source_disk: "{{ disk }}" - zone: us-central1-a - labels: - my_label: value - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a snapshot - gcp_compute_snapshot: - name: "{{ resource_name }}" - source_disk: "{{ disk }}" - zone: us-central1-a - labels: - my_label: value - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that snapshot was deleted - gcp_compute_snapshot_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a snapshot that does not exist - gcp_compute_snapshot: - name: "{{ resource_name }}" - source_disk: "{{ disk }}" - zone: us-central1-a - labels: - my_label: value - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a disk - gcp_compute_disk: - name: disk-snapshot - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: disk - ignore_errors: true +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_ssl_certificate/tasks/autogen.yml b/test/integration/targets/gcp_compute_ssl_certificate/tasks/autogen.yml new file mode 100644 index 00000000000000..efc9f9961aeccc --- /dev/null +++ b/test/integration/targets/gcp_compute_ssl_certificate/tasks/autogen.yml @@ -0,0 +1,227 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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 SSL certificate + gcp_compute_ssl_certificate: + name: "{{ resource_name }}" + description: A certificate for testing. Do not use this certificate in production + certificate: |- + -----BEGIN CERTIFICATE----- + MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG + EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT + BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm + b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN + AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2 + MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP + BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM + FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z + aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH + KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ + 4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O + BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn + 0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O + M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ + zqGNhIPGq2ULqXKK8BY= + -----END CERTIFICATE----- + private_key: |- + -----BEGIN EC PRIVATE KEY----- + MHcCAQEEIObtRo8tkUqoMjeHhsOh2ouPpXCgBcP+EDxZCB/tws15oAoGCCqGSM49 + AwEHoUQDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ4mzkzTv0dXyB750f + OGN02HtkpBOZzzvUARTR10JQoSe2/5PIwQ== + -----END EC PRIVATE KEY----- + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a SSL certificate + gcp_compute_ssl_certificate: + name: "{{ resource_name }}" + description: A certificate for testing. Do not use this certificate in production + certificate: |- + -----BEGIN CERTIFICATE----- + MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG + EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT + BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm + b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN + AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2 + MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP + BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM + FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z + aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH + KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ + 4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O + BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn + 0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O + M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ + zqGNhIPGq2ULqXKK8BY= + -----END CERTIFICATE----- + private_key: |- + -----BEGIN EC PRIVATE KEY----- + MHcCAQEEIObtRo8tkUqoMjeHhsOh2ouPpXCgBcP+EDxZCB/tws15oAoGCCqGSM49 + AwEHoUQDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ4mzkzTv0dXyB750f + OGN02HtkpBOZzzvUARTR10JQoSe2/5PIwQ== + -----END EC PRIVATE KEY----- + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that ssl_certificate was created + gcp_compute_ssl_certificate_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a SSL certificate that already exists + gcp_compute_ssl_certificate: + name: "{{ resource_name }}" + description: A certificate for testing. Do not use this certificate in production + certificate: |- + -----BEGIN CERTIFICATE----- + MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG + EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT + BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm + b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN + AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2 + MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP + BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM + FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z + aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH + KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ + 4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O + BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn + 0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O + M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ + zqGNhIPGq2ULqXKK8BY= + -----END CERTIFICATE----- + private_key: |- + -----BEGIN EC PRIVATE KEY----- + MHcCAQEEIObtRo8tkUqoMjeHhsOh2ouPpXCgBcP+EDxZCB/tws15oAoGCCqGSM49 + AwEHoUQDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ4mzkzTv0dXyB750f + OGN02HtkpBOZzzvUARTR10JQoSe2/5PIwQ== + -----END EC PRIVATE KEY----- + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a SSL certificate + gcp_compute_ssl_certificate: + name: "{{ resource_name }}" + description: A certificate for testing. Do not use this certificate in production + certificate: |- + -----BEGIN CERTIFICATE----- + MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG + EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT + BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm + b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN + AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2 + MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP + BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM + FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z + aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH + KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ + 4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O + BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn + 0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O + M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ + zqGNhIPGq2ULqXKK8BY= + -----END CERTIFICATE----- + private_key: |- + -----BEGIN EC PRIVATE KEY----- + MHcCAQEEIObtRo8tkUqoMjeHhsOh2ouPpXCgBcP+EDxZCB/tws15oAoGCCqGSM49 + AwEHoUQDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ4mzkzTv0dXyB750f + OGN02HtkpBOZzzvUARTR10JQoSe2/5PIwQ== + -----END EC PRIVATE KEY----- + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that ssl_certificate was deleted + gcp_compute_ssl_certificate_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a SSL certificate that does not exist + gcp_compute_ssl_certificate: + name: "{{ resource_name }}" + description: A certificate for testing. Do not use this certificate in production + certificate: |- + -----BEGIN CERTIFICATE----- + MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG + EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT + BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm + b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN + AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2 + MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP + BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM + FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z + aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH + KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ + 4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O + BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn + 0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O + M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ + zqGNhIPGq2ULqXKK8BY= + -----END CERTIFICATE----- + private_key: |- + -----BEGIN EC PRIVATE KEY----- + MHcCAQEEIObtRo8tkUqoMjeHhsOh2ouPpXCgBcP+EDxZCB/tws15oAoGCCqGSM49 + AwEHoUQDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ4mzkzTv0dXyB750f + OGN02HtkpBOZzzvUARTR10JQoSe2/5PIwQ== + -----END EC PRIVATE KEY----- + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_compute_ssl_certificate/tasks/main.yml b/test/integration/targets/gcp_compute_ssl_certificate/tasks/main.yml index efc9f9961aeccc..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_compute_ssl_certificate/tasks/main.yml +++ b/test/integration/targets/gcp_compute_ssl_certificate/tasks/main.yml @@ -1,227 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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 SSL certificate - gcp_compute_ssl_certificate: - name: "{{ resource_name }}" - description: A certificate for testing. Do not use this certificate in production - certificate: |- - -----BEGIN CERTIFICATE----- - MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG - EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT - BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm - b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN - AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2 - MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP - BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM - FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z - aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH - KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ - 4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O - BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn - 0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O - M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ - zqGNhIPGq2ULqXKK8BY= - -----END CERTIFICATE----- - private_key: |- - -----BEGIN EC PRIVATE KEY----- - MHcCAQEEIObtRo8tkUqoMjeHhsOh2ouPpXCgBcP+EDxZCB/tws15oAoGCCqGSM49 - AwEHoUQDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ4mzkzTv0dXyB750f - OGN02HtkpBOZzzvUARTR10JQoSe2/5PIwQ== - -----END EC PRIVATE KEY----- - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a SSL certificate - gcp_compute_ssl_certificate: - name: "{{ resource_name }}" - description: A certificate for testing. Do not use this certificate in production - certificate: |- - -----BEGIN CERTIFICATE----- - MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG - EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT - BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm - b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN - AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2 - MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP - BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM - FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z - aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH - KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ - 4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O - BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn - 0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O - M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ - zqGNhIPGq2ULqXKK8BY= - -----END CERTIFICATE----- - private_key: |- - -----BEGIN EC PRIVATE KEY----- - MHcCAQEEIObtRo8tkUqoMjeHhsOh2ouPpXCgBcP+EDxZCB/tws15oAoGCCqGSM49 - AwEHoUQDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ4mzkzTv0dXyB750f - OGN02HtkpBOZzzvUARTR10JQoSe2/5PIwQ== - -----END EC PRIVATE KEY----- - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that ssl_certificate was created - gcp_compute_ssl_certificate_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a SSL certificate that already exists - gcp_compute_ssl_certificate: - name: "{{ resource_name }}" - description: A certificate for testing. Do not use this certificate in production - certificate: |- - -----BEGIN CERTIFICATE----- - MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG - EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT - BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm - b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN - AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2 - MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP - BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM - FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z - aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH - KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ - 4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O - BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn - 0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O - M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ - zqGNhIPGq2ULqXKK8BY= - -----END CERTIFICATE----- - private_key: |- - -----BEGIN EC PRIVATE KEY----- - MHcCAQEEIObtRo8tkUqoMjeHhsOh2ouPpXCgBcP+EDxZCB/tws15oAoGCCqGSM49 - AwEHoUQDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ4mzkzTv0dXyB750f - OGN02HtkpBOZzzvUARTR10JQoSe2/5PIwQ== - -----END EC PRIVATE KEY----- - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a SSL certificate - gcp_compute_ssl_certificate: - name: "{{ resource_name }}" - description: A certificate for testing. Do not use this certificate in production - certificate: |- - -----BEGIN CERTIFICATE----- - MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG - EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT - BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm - b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN - AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2 - MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP - BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM - FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z - aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH - KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ - 4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O - BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn - 0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O - M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ - zqGNhIPGq2ULqXKK8BY= - -----END CERTIFICATE----- - private_key: |- - -----BEGIN EC PRIVATE KEY----- - MHcCAQEEIObtRo8tkUqoMjeHhsOh2ouPpXCgBcP+EDxZCB/tws15oAoGCCqGSM49 - AwEHoUQDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ4mzkzTv0dXyB750f - OGN02HtkpBOZzzvUARTR10JQoSe2/5PIwQ== - -----END EC PRIVATE KEY----- - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that ssl_certificate was deleted - gcp_compute_ssl_certificate_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a SSL certificate that does not exist - gcp_compute_ssl_certificate: - name: "{{ resource_name }}" - description: A certificate for testing. Do not use this certificate in production - certificate: |- - -----BEGIN CERTIFICATE----- - MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG - EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT - BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm - b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN - AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2 - MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP - BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM - FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z - aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH - KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ - 4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O - BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn - 0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O - M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ - zqGNhIPGq2ULqXKK8BY= - -----END CERTIFICATE----- - private_key: |- - -----BEGIN EC PRIVATE KEY----- - MHcCAQEEIObtRo8tkUqoMjeHhsOh2ouPpXCgBcP+EDxZCB/tws15oAoGCCqGSM49 - AwEHoUQDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ4mzkzTv0dXyB750f - OGN02HtkpBOZzzvUARTR10JQoSe2/5PIwQ== - -----END EC PRIVATE KEY----- - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_ssl_policy/tasks/autogen.yml b/test/integration/targets/gcp_compute_ssl_policy/tasks/autogen.yml new file mode 100644 index 00000000000000..455bb1b8829192 --- /dev/null +++ b/test/integration/targets/gcp_compute_ssl_policy/tasks/autogen.yml @@ -0,0 +1,127 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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 SSL policy + gcp_compute_ssl_policy: + name: "{{ resource_name }}" + profile: CUSTOM + min_tls_version: TLS_1_2 + custom_features: + - TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 + - TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a SSL policy + gcp_compute_ssl_policy: + name: "{{ resource_name }}" + profile: CUSTOM + min_tls_version: TLS_1_2 + custom_features: + - TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 + - TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that ssl_policy was created + gcp_compute_ssl_policy_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a SSL policy that already exists + gcp_compute_ssl_policy: + name: "{{ resource_name }}" + profile: CUSTOM + min_tls_version: TLS_1_2 + custom_features: + - TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 + - TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a SSL policy + gcp_compute_ssl_policy: + name: "{{ resource_name }}" + profile: CUSTOM + min_tls_version: TLS_1_2 + custom_features: + - TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 + - TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that ssl_policy was deleted + gcp_compute_ssl_policy_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a SSL policy that does not exist + gcp_compute_ssl_policy: + name: "{{ resource_name }}" + profile: CUSTOM + min_tls_version: TLS_1_2 + custom_features: + - TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 + - TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_compute_ssl_policy/tasks/main.yml b/test/integration/targets/gcp_compute_ssl_policy/tasks/main.yml index 455bb1b8829192..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_compute_ssl_policy/tasks/main.yml +++ b/test/integration/targets/gcp_compute_ssl_policy/tasks/main.yml @@ -1,127 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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 SSL policy - gcp_compute_ssl_policy: - name: "{{ resource_name }}" - profile: CUSTOM - min_tls_version: TLS_1_2 - custom_features: - - TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 - - TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a SSL policy - gcp_compute_ssl_policy: - name: "{{ resource_name }}" - profile: CUSTOM - min_tls_version: TLS_1_2 - custom_features: - - TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 - - TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that ssl_policy was created - gcp_compute_ssl_policy_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a SSL policy that already exists - gcp_compute_ssl_policy: - name: "{{ resource_name }}" - profile: CUSTOM - min_tls_version: TLS_1_2 - custom_features: - - TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 - - TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a SSL policy - gcp_compute_ssl_policy: - name: "{{ resource_name }}" - profile: CUSTOM - min_tls_version: TLS_1_2 - custom_features: - - TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 - - TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that ssl_policy was deleted - gcp_compute_ssl_policy_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a SSL policy that does not exist - gcp_compute_ssl_policy: - name: "{{ resource_name }}" - profile: CUSTOM - min_tls_version: TLS_1_2 - custom_features: - - TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 - - TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_subnetwork/tasks/autogen.yml b/test/integration/targets/gcp_compute_subnetwork/tasks/autogen.yml new file mode 100644 index 00000000000000..ff956ae6ad1645 --- /dev/null +++ b/test/integration/targets/gcp_compute_subnetwork/tasks/autogen.yml @@ -0,0 +1,141 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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: create a network + gcp_compute_network: + name: network-subnetwork + auto_create_subnetworks: 'true' + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: network +- name: delete a subnetwork + 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 +#---------------------------------------------------------- +- name: create a subnetwork + 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 true + assert: + that: + - result.changed == true +- name: verify that subnetwork was created + gcp_compute_subnetwork_info: + 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['resources'] | 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 + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a subnetwork + 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 true + assert: + that: + - result.changed == true +- name: verify that subnetwork was deleted + gcp_compute_subnetwork_info: + 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['resources'] | 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 + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a network + gcp_compute_network: + name: network-subnetwork + auto_create_subnetworks: 'true' + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: network + ignore_errors: true diff --git a/test/integration/targets/gcp_compute_subnetwork/tasks/main.yml b/test/integration/targets/gcp_compute_subnetwork/tasks/main.yml index ff956ae6ad1645..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_compute_subnetwork/tasks/main.yml +++ b/test/integration/targets/gcp_compute_subnetwork/tasks/main.yml @@ -1,141 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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: create a network - gcp_compute_network: - name: network-subnetwork - auto_create_subnetworks: 'true' - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: network -- name: delete a subnetwork - 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 -#---------------------------------------------------------- -- name: create a subnetwork - 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 true - assert: - that: - - result.changed == true -- name: verify that subnetwork was created - gcp_compute_subnetwork_info: - 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['resources'] | 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 - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a subnetwork - 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 true - assert: - that: - - result.changed == true -- name: verify that subnetwork was deleted - gcp_compute_subnetwork_info: - 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['resources'] | 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 - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a network - gcp_compute_network: - name: network-subnetwork - auto_create_subnetworks: 'true' - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: network - ignore_errors: true +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_target_http_proxy/tasks/autogen.yml b/test/integration/targets/gcp_compute_target_http_proxy/tasks/autogen.yml new file mode 100644 index 00000000000000..441871f521efc3 --- /dev/null +++ b/test/integration/targets/gcp_compute_target_http_proxy/tasks/autogen.yml @@ -0,0 +1,200 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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: create a instance group + gcp_compute_instance_group: + name: instancegroup-targethttpproxy + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: instancegroup +- name: create a HTTP health check + gcp_compute_http_health_check: + name: httphealthcheck-targethttpproxy + healthy_threshold: 10 + port: 8080 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: healthcheck +- name: create a backend service + gcp_compute_backend_service: + name: backendservice-targethttpproxy + backends: + - group: "{{ instancegroup.selfLink }}" + health_checks: + - "{{ healthcheck.selfLink }}" + enable_cdn: 'true' + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: backendservice +- name: create a URL map + gcp_compute_url_map: + name: urlmap-targethttpproxy + default_service: "{{ backendservice }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: urlmap +- name: delete a target HTTP proxy + gcp_compute_target_http_proxy: + name: "{{ resource_name }}" + url_map: "{{ urlmap }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a target HTTP proxy + gcp_compute_target_http_proxy: + name: "{{ resource_name }}" + url_map: "{{ urlmap }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that target_http_proxy was created + gcp_compute_target_http_proxy_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a target HTTP proxy that already exists + gcp_compute_target_http_proxy: + name: "{{ resource_name }}" + url_map: "{{ urlmap }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a target HTTP proxy + gcp_compute_target_http_proxy: + name: "{{ resource_name }}" + url_map: "{{ urlmap }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that target_http_proxy was deleted + gcp_compute_target_http_proxy_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a target HTTP proxy that does not exist + gcp_compute_target_http_proxy: + name: "{{ resource_name }}" + url_map: "{{ urlmap }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a URL map + gcp_compute_url_map: + name: urlmap-targethttpproxy + default_service: "{{ backendservice }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: urlmap + ignore_errors: true +- name: delete a backend service + gcp_compute_backend_service: + name: backendservice-targethttpproxy + backends: + - group: "{{ instancegroup.selfLink }}" + health_checks: + - "{{ healthcheck.selfLink }}" + enable_cdn: 'true' + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: backendservice + ignore_errors: true +- name: delete a HTTP health check + gcp_compute_http_health_check: + name: httphealthcheck-targethttpproxy + healthy_threshold: 10 + port: 8080 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: healthcheck + ignore_errors: true +- name: delete a instance group + gcp_compute_instance_group: + name: instancegroup-targethttpproxy + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: instancegroup + ignore_errors: true diff --git a/test/integration/targets/gcp_compute_target_http_proxy/tasks/main.yml b/test/integration/targets/gcp_compute_target_http_proxy/tasks/main.yml index 441871f521efc3..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_compute_target_http_proxy/tasks/main.yml +++ b/test/integration/targets/gcp_compute_target_http_proxy/tasks/main.yml @@ -1,200 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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: create a instance group - gcp_compute_instance_group: - name: instancegroup-targethttpproxy - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: instancegroup -- name: create a HTTP health check - gcp_compute_http_health_check: - name: httphealthcheck-targethttpproxy - healthy_threshold: 10 - port: 8080 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: healthcheck -- name: create a backend service - gcp_compute_backend_service: - name: backendservice-targethttpproxy - backends: - - group: "{{ instancegroup.selfLink }}" - health_checks: - - "{{ healthcheck.selfLink }}" - enable_cdn: 'true' - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: backendservice -- name: create a URL map - gcp_compute_url_map: - name: urlmap-targethttpproxy - default_service: "{{ backendservice }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: urlmap -- name: delete a target HTTP proxy - gcp_compute_target_http_proxy: - name: "{{ resource_name }}" - url_map: "{{ urlmap }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a target HTTP proxy - gcp_compute_target_http_proxy: - name: "{{ resource_name }}" - url_map: "{{ urlmap }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that target_http_proxy was created - gcp_compute_target_http_proxy_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a target HTTP proxy that already exists - gcp_compute_target_http_proxy: - name: "{{ resource_name }}" - url_map: "{{ urlmap }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a target HTTP proxy - gcp_compute_target_http_proxy: - name: "{{ resource_name }}" - url_map: "{{ urlmap }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that target_http_proxy was deleted - gcp_compute_target_http_proxy_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a target HTTP proxy that does not exist - gcp_compute_target_http_proxy: - name: "{{ resource_name }}" - url_map: "{{ urlmap }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a URL map - gcp_compute_url_map: - name: urlmap-targethttpproxy - default_service: "{{ backendservice }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: urlmap - ignore_errors: true -- name: delete a backend service - gcp_compute_backend_service: - name: backendservice-targethttpproxy - backends: - - group: "{{ instancegroup.selfLink }}" - health_checks: - - "{{ healthcheck.selfLink }}" - enable_cdn: 'true' - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: backendservice - ignore_errors: true -- name: delete a HTTP health check - gcp_compute_http_health_check: - name: httphealthcheck-targethttpproxy - healthy_threshold: 10 - port: 8080 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: healthcheck - ignore_errors: true -- name: delete a instance group - gcp_compute_instance_group: - name: instancegroup-targethttpproxy - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: instancegroup - ignore_errors: true +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_target_https_proxy/tasks/autogen.yml b/test/integration/targets/gcp_compute_target_https_proxy/tasks/autogen.yml new file mode 100644 index 00000000000000..b18a08ba109ba8 --- /dev/null +++ b/test/integration/targets/gcp_compute_target_https_proxy/tasks/autogen.yml @@ -0,0 +1,277 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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: create a instance group + gcp_compute_instance_group: + name: instancegroup-targethttpsproxy + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: instancegroup +- name: create a HTTP health check + gcp_compute_http_health_check: + name: httphealthcheck-targethttpsproxy + healthy_threshold: 10 + port: 8080 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: healthcheck +- name: create a backend service + gcp_compute_backend_service: + name: backendservice-targethttpsproxy + backends: + - group: "{{ instancegroup.selfLink }}" + health_checks: + - "{{ healthcheck.selfLink }}" + enable_cdn: 'true' + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: backendservice +- name: create a URL map + gcp_compute_url_map: + name: urlmap-targethttpsproxy + default_service: "{{ backendservice }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: urlmap +- name: create a SSL certificate + gcp_compute_ssl_certificate: + name: sslcert-targethttpsproxy + description: A certificate for testing. Do not use this certificate in production + certificate: |- + -----BEGIN CERTIFICATE----- + MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG + EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT + BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm + b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN + AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2 + MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP + BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM + FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z + aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH + KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ + 4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O + BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn + 0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O + M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ + zqGNhIPGq2ULqXKK8BY= + -----END CERTIFICATE----- + private_key: |- + -----BEGIN EC PRIVATE KEY----- + MHcCAQEEIObtRo8tkUqoMjeHhsOh2ouPpXCgBcP+EDxZCB/tws15oAoGCCqGSM49 + AwEHoUQDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ4mzkzTv0dXyB750f + OGN02HtkpBOZzzvUARTR10JQoSe2/5PIwQ== + -----END EC PRIVATE KEY----- + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: sslcert +- name: delete a target HTTPS proxy + gcp_compute_target_https_proxy: + name: "{{ resource_name }}" + ssl_certificates: + - "{{ sslcert }}" + url_map: "{{ urlmap }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a target HTTPS proxy + gcp_compute_target_https_proxy: + name: "{{ resource_name }}" + ssl_certificates: + - "{{ sslcert }}" + url_map: "{{ urlmap }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that target_https_proxy was created + gcp_compute_target_https_proxy_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a target HTTPS proxy that already exists + gcp_compute_target_https_proxy: + name: "{{ resource_name }}" + ssl_certificates: + - "{{ sslcert }}" + url_map: "{{ urlmap }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a target HTTPS proxy + gcp_compute_target_https_proxy: + name: "{{ resource_name }}" + ssl_certificates: + - "{{ sslcert }}" + url_map: "{{ urlmap }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that target_https_proxy was deleted + gcp_compute_target_https_proxy_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a target HTTPS proxy that does not exist + gcp_compute_target_https_proxy: + name: "{{ resource_name }}" + ssl_certificates: + - "{{ sslcert }}" + url_map: "{{ urlmap }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a SSL certificate + gcp_compute_ssl_certificate: + name: sslcert-targethttpsproxy + description: A certificate for testing. Do not use this certificate in production + certificate: |- + -----BEGIN CERTIFICATE----- + MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG + EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT + BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm + b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN + AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2 + MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP + BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM + FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z + aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH + KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ + 4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O + BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn + 0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O + M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ + zqGNhIPGq2ULqXKK8BY= + -----END CERTIFICATE----- + private_key: |- + -----BEGIN EC PRIVATE KEY----- + MHcCAQEEIObtRo8tkUqoMjeHhsOh2ouPpXCgBcP+EDxZCB/tws15oAoGCCqGSM49 + AwEHoUQDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ4mzkzTv0dXyB750f + OGN02HtkpBOZzzvUARTR10JQoSe2/5PIwQ== + -----END EC PRIVATE KEY----- + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: sslcert + ignore_errors: true +- name: delete a URL map + gcp_compute_url_map: + name: urlmap-targethttpsproxy + default_service: "{{ backendservice }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: urlmap + ignore_errors: true +- name: delete a backend service + gcp_compute_backend_service: + name: backendservice-targethttpsproxy + backends: + - group: "{{ instancegroup.selfLink }}" + health_checks: + - "{{ healthcheck.selfLink }}" + enable_cdn: 'true' + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: backendservice + ignore_errors: true +- name: delete a HTTP health check + gcp_compute_http_health_check: + name: httphealthcheck-targethttpsproxy + healthy_threshold: 10 + port: 8080 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: healthcheck + ignore_errors: true +- name: delete a instance group + gcp_compute_instance_group: + name: instancegroup-targethttpsproxy + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: instancegroup + ignore_errors: true diff --git a/test/integration/targets/gcp_compute_target_https_proxy/tasks/main.yml b/test/integration/targets/gcp_compute_target_https_proxy/tasks/main.yml index b18a08ba109ba8..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_compute_target_https_proxy/tasks/main.yml +++ b/test/integration/targets/gcp_compute_target_https_proxy/tasks/main.yml @@ -1,277 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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: create a instance group - gcp_compute_instance_group: - name: instancegroup-targethttpsproxy - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: instancegroup -- name: create a HTTP health check - gcp_compute_http_health_check: - name: httphealthcheck-targethttpsproxy - healthy_threshold: 10 - port: 8080 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: healthcheck -- name: create a backend service - gcp_compute_backend_service: - name: backendservice-targethttpsproxy - backends: - - group: "{{ instancegroup.selfLink }}" - health_checks: - - "{{ healthcheck.selfLink }}" - enable_cdn: 'true' - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: backendservice -- name: create a URL map - gcp_compute_url_map: - name: urlmap-targethttpsproxy - default_service: "{{ backendservice }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: urlmap -- name: create a SSL certificate - gcp_compute_ssl_certificate: - name: sslcert-targethttpsproxy - description: A certificate for testing. Do not use this certificate in production - certificate: |- - -----BEGIN CERTIFICATE----- - MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG - EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT - BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm - b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN - AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2 - MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP - BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM - FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z - aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH - KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ - 4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O - BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn - 0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O - M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ - zqGNhIPGq2ULqXKK8BY= - -----END CERTIFICATE----- - private_key: |- - -----BEGIN EC PRIVATE KEY----- - MHcCAQEEIObtRo8tkUqoMjeHhsOh2ouPpXCgBcP+EDxZCB/tws15oAoGCCqGSM49 - AwEHoUQDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ4mzkzTv0dXyB750f - OGN02HtkpBOZzzvUARTR10JQoSe2/5PIwQ== - -----END EC PRIVATE KEY----- - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: sslcert -- name: delete a target HTTPS proxy - gcp_compute_target_https_proxy: - name: "{{ resource_name }}" - ssl_certificates: - - "{{ sslcert }}" - url_map: "{{ urlmap }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a target HTTPS proxy - gcp_compute_target_https_proxy: - name: "{{ resource_name }}" - ssl_certificates: - - "{{ sslcert }}" - url_map: "{{ urlmap }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that target_https_proxy was created - gcp_compute_target_https_proxy_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a target HTTPS proxy that already exists - gcp_compute_target_https_proxy: - name: "{{ resource_name }}" - ssl_certificates: - - "{{ sslcert }}" - url_map: "{{ urlmap }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a target HTTPS proxy - gcp_compute_target_https_proxy: - name: "{{ resource_name }}" - ssl_certificates: - - "{{ sslcert }}" - url_map: "{{ urlmap }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that target_https_proxy was deleted - gcp_compute_target_https_proxy_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a target HTTPS proxy that does not exist - gcp_compute_target_https_proxy: - name: "{{ resource_name }}" - ssl_certificates: - - "{{ sslcert }}" - url_map: "{{ urlmap }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a SSL certificate - gcp_compute_ssl_certificate: - name: sslcert-targethttpsproxy - description: A certificate for testing. Do not use this certificate in production - certificate: |- - -----BEGIN CERTIFICATE----- - MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG - EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT - BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm - b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN - AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2 - MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP - BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM - FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z - aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH - KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ - 4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O - BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn - 0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O - M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ - zqGNhIPGq2ULqXKK8BY= - -----END CERTIFICATE----- - private_key: |- - -----BEGIN EC PRIVATE KEY----- - MHcCAQEEIObtRo8tkUqoMjeHhsOh2ouPpXCgBcP+EDxZCB/tws15oAoGCCqGSM49 - AwEHoUQDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ4mzkzTv0dXyB750f - OGN02HtkpBOZzzvUARTR10JQoSe2/5PIwQ== - -----END EC PRIVATE KEY----- - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: sslcert - ignore_errors: true -- name: delete a URL map - gcp_compute_url_map: - name: urlmap-targethttpsproxy - default_service: "{{ backendservice }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: urlmap - ignore_errors: true -- name: delete a backend service - gcp_compute_backend_service: - name: backendservice-targethttpsproxy - backends: - - group: "{{ instancegroup.selfLink }}" - health_checks: - - "{{ healthcheck.selfLink }}" - enable_cdn: 'true' - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: backendservice - ignore_errors: true -- name: delete a HTTP health check - gcp_compute_http_health_check: - name: httphealthcheck-targethttpsproxy - healthy_threshold: 10 - port: 8080 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: healthcheck - ignore_errors: true -- name: delete a instance group - gcp_compute_instance_group: - name: instancegroup-targethttpsproxy - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: instancegroup - ignore_errors: true +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_target_pool/tasks/autogen.yml b/test/integration/targets/gcp_compute_target_pool/tasks/autogen.yml new file mode 100644 index 00000000000000..756a5cccf9915e --- /dev/null +++ b/test/integration/targets/gcp_compute_target_pool/tasks/autogen.yml @@ -0,0 +1,109 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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 target pool + gcp_compute_target_pool: + name: "{{ resource_name }}" + region: us-west1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a target pool + gcp_compute_target_pool: + name: "{{ resource_name }}" + region: us-west1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that target_pool was created + gcp_compute_target_pool_info: + filters: + - name = {{ resource_name }} + 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['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a target pool that already exists + gcp_compute_target_pool: + name: "{{ resource_name }}" + region: us-west1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a target pool + gcp_compute_target_pool: + name: "{{ resource_name }}" + region: us-west1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that target_pool was deleted + gcp_compute_target_pool_info: + filters: + - name = {{ resource_name }} + 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['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a target pool that does not exist + gcp_compute_target_pool: + name: "{{ resource_name }}" + region: us-west1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_compute_target_pool/tasks/main.yml b/test/integration/targets/gcp_compute_target_pool/tasks/main.yml index 756a5cccf9915e..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_compute_target_pool/tasks/main.yml +++ b/test/integration/targets/gcp_compute_target_pool/tasks/main.yml @@ -1,109 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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 target pool - gcp_compute_target_pool: - name: "{{ resource_name }}" - region: us-west1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a target pool - gcp_compute_target_pool: - name: "{{ resource_name }}" - region: us-west1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that target_pool was created - gcp_compute_target_pool_info: - filters: - - name = {{ resource_name }} - 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['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a target pool that already exists - gcp_compute_target_pool: - name: "{{ resource_name }}" - region: us-west1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a target pool - gcp_compute_target_pool: - name: "{{ resource_name }}" - region: us-west1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that target_pool was deleted - gcp_compute_target_pool_info: - filters: - - name = {{ resource_name }} - 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['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a target pool that does not exist - gcp_compute_target_pool: - name: "{{ resource_name }}" - region: us-west1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_target_ssl_proxy/tasks/autogen.yml b/test/integration/targets/gcp_compute_target_ssl_proxy/tasks/autogen.yml new file mode 100644 index 00000000000000..f9da704f7e194a --- /dev/null +++ b/test/integration/targets/gcp_compute_target_ssl_proxy/tasks/autogen.yml @@ -0,0 +1,266 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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: create a instance group + gcp_compute_instance_group: + name: instancegroup-targetsslproxy + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: instancegroup +- name: create a health check + gcp_compute_health_check: + name: healthcheck-targetsslproxy + type: TCP + tcp_health_check: + port_name: service-health + request: ping + response: pong + healthy_threshold: 10 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: healthcheck +- name: create a backend service + gcp_compute_backend_service: + name: backendservice-targetsslproxy + backends: + - group: "{{ instancegroup.selfLink }}" + health_checks: + - "{{ healthcheck.selfLink }}" + protocol: SSL + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: backendservice +- name: create a SSL certificate + gcp_compute_ssl_certificate: + name: sslcert-targetsslproxy + description: A certificate for testing. Do not use this certificate in production + certificate: |- + -----BEGIN CERTIFICATE----- + MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG + EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT + BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm + b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN + AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2 + MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP + BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM + FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z + aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH + KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ + 4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O + BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn + 0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O + M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ + zqGNhIPGq2ULqXKK8BY= + -----END CERTIFICATE----- + private_key: |- + -----BEGIN EC PRIVATE KEY----- + MHcCAQEEIObtRo8tkUqoMjeHhsOh2ouPpXCgBcP+EDxZCB/tws15oAoGCCqGSM49 + AwEHoUQDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ4mzkzTv0dXyB750f + OGN02HtkpBOZzzvUARTR10JQoSe2/5PIwQ== + -----END EC PRIVATE KEY----- + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: sslcert +- name: delete a target SSL proxy + gcp_compute_target_ssl_proxy: + name: "{{ resource_name }}" + ssl_certificates: + - "{{ sslcert }}" + service: "{{ backendservice }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a target SSL proxy + gcp_compute_target_ssl_proxy: + name: "{{ resource_name }}" + ssl_certificates: + - "{{ sslcert }}" + service: "{{ backendservice }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that target_ssl_proxy was created + gcp_compute_target_ssl_proxy_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a target SSL proxy that already exists + gcp_compute_target_ssl_proxy: + name: "{{ resource_name }}" + ssl_certificates: + - "{{ sslcert }}" + service: "{{ backendservice }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a target SSL proxy + gcp_compute_target_ssl_proxy: + name: "{{ resource_name }}" + ssl_certificates: + - "{{ sslcert }}" + service: "{{ backendservice }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that target_ssl_proxy was deleted + gcp_compute_target_ssl_proxy_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a target SSL proxy that does not exist + gcp_compute_target_ssl_proxy: + name: "{{ resource_name }}" + ssl_certificates: + - "{{ sslcert }}" + service: "{{ backendservice }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a SSL certificate + gcp_compute_ssl_certificate: + name: sslcert-targetsslproxy + description: A certificate for testing. Do not use this certificate in production + certificate: |- + -----BEGIN CERTIFICATE----- + MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG + EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT + BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm + b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN + AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2 + MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP + BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM + FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z + aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH + KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ + 4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O + BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn + 0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O + M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ + zqGNhIPGq2ULqXKK8BY= + -----END CERTIFICATE----- + private_key: |- + -----BEGIN EC PRIVATE KEY----- + MHcCAQEEIObtRo8tkUqoMjeHhsOh2ouPpXCgBcP+EDxZCB/tws15oAoGCCqGSM49 + AwEHoUQDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ4mzkzTv0dXyB750f + OGN02HtkpBOZzzvUARTR10JQoSe2/5PIwQ== + -----END EC PRIVATE KEY----- + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: sslcert + ignore_errors: true +- name: delete a backend service + gcp_compute_backend_service: + name: backendservice-targetsslproxy + backends: + - group: "{{ instancegroup.selfLink }}" + health_checks: + - "{{ healthcheck.selfLink }}" + protocol: SSL + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: backendservice + ignore_errors: true +- name: delete a health check + gcp_compute_health_check: + name: healthcheck-targetsslproxy + type: TCP + tcp_health_check: + port_name: service-health + request: ping + response: pong + healthy_threshold: 10 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: healthcheck + ignore_errors: true +- name: delete a instance group + gcp_compute_instance_group: + name: instancegroup-targetsslproxy + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: instancegroup + ignore_errors: true diff --git a/test/integration/targets/gcp_compute_target_ssl_proxy/tasks/main.yml b/test/integration/targets/gcp_compute_target_ssl_proxy/tasks/main.yml index f9da704f7e194a..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_compute_target_ssl_proxy/tasks/main.yml +++ b/test/integration/targets/gcp_compute_target_ssl_proxy/tasks/main.yml @@ -1,266 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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: create a instance group - gcp_compute_instance_group: - name: instancegroup-targetsslproxy - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: instancegroup -- name: create a health check - gcp_compute_health_check: - name: healthcheck-targetsslproxy - type: TCP - tcp_health_check: - port_name: service-health - request: ping - response: pong - healthy_threshold: 10 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: healthcheck -- name: create a backend service - gcp_compute_backend_service: - name: backendservice-targetsslproxy - backends: - - group: "{{ instancegroup.selfLink }}" - health_checks: - - "{{ healthcheck.selfLink }}" - protocol: SSL - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: backendservice -- name: create a SSL certificate - gcp_compute_ssl_certificate: - name: sslcert-targetsslproxy - description: A certificate for testing. Do not use this certificate in production - certificate: |- - -----BEGIN CERTIFICATE----- - MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG - EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT - BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm - b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN - AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2 - MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP - BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM - FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z - aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH - KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ - 4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O - BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn - 0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O - M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ - zqGNhIPGq2ULqXKK8BY= - -----END CERTIFICATE----- - private_key: |- - -----BEGIN EC PRIVATE KEY----- - MHcCAQEEIObtRo8tkUqoMjeHhsOh2ouPpXCgBcP+EDxZCB/tws15oAoGCCqGSM49 - AwEHoUQDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ4mzkzTv0dXyB750f - OGN02HtkpBOZzzvUARTR10JQoSe2/5PIwQ== - -----END EC PRIVATE KEY----- - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: sslcert -- name: delete a target SSL proxy - gcp_compute_target_ssl_proxy: - name: "{{ resource_name }}" - ssl_certificates: - - "{{ sslcert }}" - service: "{{ backendservice }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a target SSL proxy - gcp_compute_target_ssl_proxy: - name: "{{ resource_name }}" - ssl_certificates: - - "{{ sslcert }}" - service: "{{ backendservice }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that target_ssl_proxy was created - gcp_compute_target_ssl_proxy_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a target SSL proxy that already exists - gcp_compute_target_ssl_proxy: - name: "{{ resource_name }}" - ssl_certificates: - - "{{ sslcert }}" - service: "{{ backendservice }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a target SSL proxy - gcp_compute_target_ssl_proxy: - name: "{{ resource_name }}" - ssl_certificates: - - "{{ sslcert }}" - service: "{{ backendservice }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that target_ssl_proxy was deleted - gcp_compute_target_ssl_proxy_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a target SSL proxy that does not exist - gcp_compute_target_ssl_proxy: - name: "{{ resource_name }}" - ssl_certificates: - - "{{ sslcert }}" - service: "{{ backendservice }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a SSL certificate - gcp_compute_ssl_certificate: - name: sslcert-targetsslproxy - description: A certificate for testing. Do not use this certificate in production - certificate: |- - -----BEGIN CERTIFICATE----- - MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG - EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT - BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm - b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN - AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2 - MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP - BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM - FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z - aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH - KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ - 4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O - BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn - 0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O - M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ - zqGNhIPGq2ULqXKK8BY= - -----END CERTIFICATE----- - private_key: |- - -----BEGIN EC PRIVATE KEY----- - MHcCAQEEIObtRo8tkUqoMjeHhsOh2ouPpXCgBcP+EDxZCB/tws15oAoGCCqGSM49 - AwEHoUQDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ4mzkzTv0dXyB750f - OGN02HtkpBOZzzvUARTR10JQoSe2/5PIwQ== - -----END EC PRIVATE KEY----- - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: sslcert - ignore_errors: true -- name: delete a backend service - gcp_compute_backend_service: - name: backendservice-targetsslproxy - backends: - - group: "{{ instancegroup.selfLink }}" - health_checks: - - "{{ healthcheck.selfLink }}" - protocol: SSL - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: backendservice - ignore_errors: true -- name: delete a health check - gcp_compute_health_check: - name: healthcheck-targetsslproxy - type: TCP - tcp_health_check: - port_name: service-health - request: ping - response: pong - healthy_threshold: 10 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: healthcheck - ignore_errors: true -- name: delete a instance group - gcp_compute_instance_group: - name: instancegroup-targetsslproxy - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: instancegroup - ignore_errors: true +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_target_tcp_proxy/tasks/autogen.yml b/test/integration/targets/gcp_compute_target_tcp_proxy/tasks/autogen.yml new file mode 100644 index 00000000000000..8385d591b73206 --- /dev/null +++ b/test/integration/targets/gcp_compute_target_tcp_proxy/tasks/autogen.yml @@ -0,0 +1,194 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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: create a instance group + gcp_compute_instance_group: + name: instancegroup-targettcpproxy + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: instancegroup +- name: create a health check + gcp_compute_health_check: + name: healthcheck-targettcpproxy + type: TCP + tcp_health_check: + port_name: service-health + request: ping + response: pong + healthy_threshold: 10 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: healthcheck +- name: create a backend service + gcp_compute_backend_service: + name: backendservice-targettcpproxy + backends: + - group: "{{ instancegroup.selfLink }}" + health_checks: + - "{{ healthcheck.selfLink }}" + protocol: TCP + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: backendservice +- name: delete a target TCP proxy + gcp_compute_target_tcp_proxy: + name: "{{ resource_name }}" + proxy_header: PROXY_V1 + service: "{{ backendservice }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a target TCP proxy + gcp_compute_target_tcp_proxy: + name: "{{ resource_name }}" + proxy_header: PROXY_V1 + service: "{{ backendservice }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that target_tcp_proxy was created + gcp_compute_target_tcp_proxy_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a target TCP proxy that already exists + gcp_compute_target_tcp_proxy: + name: "{{ resource_name }}" + proxy_header: PROXY_V1 + service: "{{ backendservice }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a target TCP proxy + gcp_compute_target_tcp_proxy: + name: "{{ resource_name }}" + proxy_header: PROXY_V1 + service: "{{ backendservice }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that target_tcp_proxy was deleted + gcp_compute_target_tcp_proxy_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a target TCP proxy that does not exist + gcp_compute_target_tcp_proxy: + name: "{{ resource_name }}" + proxy_header: PROXY_V1 + service: "{{ backendservice }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a backend service + gcp_compute_backend_service: + name: backendservice-targettcpproxy + backends: + - group: "{{ instancegroup.selfLink }}" + health_checks: + - "{{ healthcheck.selfLink }}" + protocol: TCP + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: backendservice + ignore_errors: true +- name: delete a health check + gcp_compute_health_check: + name: healthcheck-targettcpproxy + type: TCP + tcp_health_check: + port_name: service-health + request: ping + response: pong + healthy_threshold: 10 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: healthcheck + ignore_errors: true +- name: delete a instance group + gcp_compute_instance_group: + name: instancegroup-targettcpproxy + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: instancegroup + ignore_errors: true diff --git a/test/integration/targets/gcp_compute_target_tcp_proxy/tasks/main.yml b/test/integration/targets/gcp_compute_target_tcp_proxy/tasks/main.yml index 8385d591b73206..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_compute_target_tcp_proxy/tasks/main.yml +++ b/test/integration/targets/gcp_compute_target_tcp_proxy/tasks/main.yml @@ -1,194 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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: create a instance group - gcp_compute_instance_group: - name: instancegroup-targettcpproxy - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: instancegroup -- name: create a health check - gcp_compute_health_check: - name: healthcheck-targettcpproxy - type: TCP - tcp_health_check: - port_name: service-health - request: ping - response: pong - healthy_threshold: 10 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: healthcheck -- name: create a backend service - gcp_compute_backend_service: - name: backendservice-targettcpproxy - backends: - - group: "{{ instancegroup.selfLink }}" - health_checks: - - "{{ healthcheck.selfLink }}" - protocol: TCP - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: backendservice -- name: delete a target TCP proxy - gcp_compute_target_tcp_proxy: - name: "{{ resource_name }}" - proxy_header: PROXY_V1 - service: "{{ backendservice }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a target TCP proxy - gcp_compute_target_tcp_proxy: - name: "{{ resource_name }}" - proxy_header: PROXY_V1 - service: "{{ backendservice }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that target_tcp_proxy was created - gcp_compute_target_tcp_proxy_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a target TCP proxy that already exists - gcp_compute_target_tcp_proxy: - name: "{{ resource_name }}" - proxy_header: PROXY_V1 - service: "{{ backendservice }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a target TCP proxy - gcp_compute_target_tcp_proxy: - name: "{{ resource_name }}" - proxy_header: PROXY_V1 - service: "{{ backendservice }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that target_tcp_proxy was deleted - gcp_compute_target_tcp_proxy_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a target TCP proxy that does not exist - gcp_compute_target_tcp_proxy: - name: "{{ resource_name }}" - proxy_header: PROXY_V1 - service: "{{ backendservice }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a backend service - gcp_compute_backend_service: - name: backendservice-targettcpproxy - backends: - - group: "{{ instancegroup.selfLink }}" - health_checks: - - "{{ healthcheck.selfLink }}" - protocol: TCP - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: backendservice - ignore_errors: true -- name: delete a health check - gcp_compute_health_check: - name: healthcheck-targettcpproxy - type: TCP - tcp_health_check: - port_name: service-health - request: ping - response: pong - healthy_threshold: 10 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: healthcheck - ignore_errors: true -- name: delete a instance group - gcp_compute_instance_group: - name: instancegroup-targettcpproxy - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: instancegroup - ignore_errors: true +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_target_vpn_gateway/tasks/autogen.yml b/test/integration/targets/gcp_compute_target_vpn_gateway/tasks/autogen.yml new file mode 100644 index 00000000000000..6fd3d01dd0e5fb --- /dev/null +++ b/test/integration/targets/gcp_compute_target_vpn_gateway/tasks/autogen.yml @@ -0,0 +1,153 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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: create a address + gcp_compute_address: + name: address-vpngateway + region: us-west1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: address +- name: create a network + gcp_compute_network: + name: network-vpngateway + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: network +- name: delete a target vpn gateway + gcp_compute_target_vpn_gateway: + name: "{{ resource_name }}" + region: us-west1 + network: "{{ network }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a target vpn gateway + gcp_compute_target_vpn_gateway: + name: "{{ resource_name }}" + region: us-west1 + network: "{{ network }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that target_vpn_gateway was created + gcp_compute_target_vpn_gateway_info: + filters: + - name = {{ resource_name }} + 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['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a target vpn gateway that already exists + gcp_compute_target_vpn_gateway: + name: "{{ resource_name }}" + region: us-west1 + network: "{{ network }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a target vpn gateway + gcp_compute_target_vpn_gateway: + name: "{{ resource_name }}" + region: us-west1 + network: "{{ network }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that target_vpn_gateway was deleted + gcp_compute_target_vpn_gateway_info: + filters: + - name = {{ resource_name }} + 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['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a target vpn gateway that does not exist + gcp_compute_target_vpn_gateway: + name: "{{ resource_name }}" + region: us-west1 + network: "{{ network }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a network + gcp_compute_network: + name: network-vpngateway + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: network + ignore_errors: true +- name: delete a address + gcp_compute_address: + name: address-vpngateway + region: us-west1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: address + ignore_errors: true diff --git a/test/integration/targets/gcp_compute_target_vpn_gateway/tasks/main.yml b/test/integration/targets/gcp_compute_target_vpn_gateway/tasks/main.yml index 6fd3d01dd0e5fb..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_compute_target_vpn_gateway/tasks/main.yml +++ b/test/integration/targets/gcp_compute_target_vpn_gateway/tasks/main.yml @@ -1,153 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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: create a address - gcp_compute_address: - name: address-vpngateway - region: us-west1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: address -- name: create a network - gcp_compute_network: - name: network-vpngateway - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: network -- name: delete a target vpn gateway - gcp_compute_target_vpn_gateway: - name: "{{ resource_name }}" - region: us-west1 - network: "{{ network }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a target vpn gateway - gcp_compute_target_vpn_gateway: - name: "{{ resource_name }}" - region: us-west1 - network: "{{ network }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that target_vpn_gateway was created - gcp_compute_target_vpn_gateway_info: - filters: - - name = {{ resource_name }} - 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['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a target vpn gateway that already exists - gcp_compute_target_vpn_gateway: - name: "{{ resource_name }}" - region: us-west1 - network: "{{ network }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a target vpn gateway - gcp_compute_target_vpn_gateway: - name: "{{ resource_name }}" - region: us-west1 - network: "{{ network }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that target_vpn_gateway was deleted - gcp_compute_target_vpn_gateway_info: - filters: - - name = {{ resource_name }} - 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['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a target vpn gateway that does not exist - gcp_compute_target_vpn_gateway: - name: "{{ resource_name }}" - region: us-west1 - network: "{{ network }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a network - gcp_compute_network: - name: network-vpngateway - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: network - ignore_errors: true -- name: delete a address - gcp_compute_address: - name: address-vpngateway - region: us-west1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: address - ignore_errors: true +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_url_map/tasks/autogen.yml b/test/integration/targets/gcp_compute_url_map/tasks/autogen.yml new file mode 100644 index 00000000000000..b05a23a18b44f8 --- /dev/null +++ b/test/integration/targets/gcp_compute_url_map/tasks/autogen.yml @@ -0,0 +1,181 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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: create a instance group + gcp_compute_instance_group: + name: instancegroup-urlmap + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: instancegroup +- name: create a HTTP health check + gcp_compute_http_health_check: + name: httphealthcheck-urlmap + healthy_threshold: 10 + port: 8080 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: healthcheck +- name: create a backend service + gcp_compute_backend_service: + name: backendservice-urlmap + backends: + - group: "{{ instancegroup.selfLink }}" + health_checks: + - "{{ healthcheck.selfLink }}" + enable_cdn: 'true' + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: backendservice +- name: delete a URL map + gcp_compute_url_map: + name: "{{ resource_name }}" + default_service: "{{ backendservice }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a URL map + gcp_compute_url_map: + name: "{{ resource_name }}" + default_service: "{{ backendservice }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that url_map was created + gcp_compute_url_map_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a URL map that already exists + gcp_compute_url_map: + name: "{{ resource_name }}" + default_service: "{{ backendservice }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a URL map + gcp_compute_url_map: + name: "{{ resource_name }}" + default_service: "{{ backendservice }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that url_map was deleted + gcp_compute_url_map_info: + 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 +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a URL map that does not exist + gcp_compute_url_map: + name: "{{ resource_name }}" + default_service: "{{ backendservice }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a backend service + gcp_compute_backend_service: + name: backendservice-urlmap + backends: + - group: "{{ instancegroup.selfLink }}" + health_checks: + - "{{ healthcheck.selfLink }}" + enable_cdn: 'true' + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: backendservice + ignore_errors: true +- name: delete a HTTP health check + gcp_compute_http_health_check: + name: httphealthcheck-urlmap + healthy_threshold: 10 + port: 8080 + timeout_sec: 2 + unhealthy_threshold: 5 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: healthcheck + ignore_errors: true +- name: delete a instance group + gcp_compute_instance_group: + name: instancegroup-urlmap + zone: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: instancegroup + ignore_errors: true diff --git a/test/integration/targets/gcp_compute_url_map/tasks/main.yml b/test/integration/targets/gcp_compute_url_map/tasks/main.yml index b05a23a18b44f8..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_compute_url_map/tasks/main.yml +++ b/test/integration/targets/gcp_compute_url_map/tasks/main.yml @@ -1,181 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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: create a instance group - gcp_compute_instance_group: - name: instancegroup-urlmap - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: instancegroup -- name: create a HTTP health check - gcp_compute_http_health_check: - name: httphealthcheck-urlmap - healthy_threshold: 10 - port: 8080 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: healthcheck -- name: create a backend service - gcp_compute_backend_service: - name: backendservice-urlmap - backends: - - group: "{{ instancegroup.selfLink }}" - health_checks: - - "{{ healthcheck.selfLink }}" - enable_cdn: 'true' - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: backendservice -- name: delete a URL map - gcp_compute_url_map: - name: "{{ resource_name }}" - default_service: "{{ backendservice }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a URL map - gcp_compute_url_map: - name: "{{ resource_name }}" - default_service: "{{ backendservice }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that url_map was created - gcp_compute_url_map_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a URL map that already exists - gcp_compute_url_map: - name: "{{ resource_name }}" - default_service: "{{ backendservice }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a URL map - gcp_compute_url_map: - name: "{{ resource_name }}" - default_service: "{{ backendservice }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that url_map was deleted - gcp_compute_url_map_info: - 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 -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a URL map that does not exist - gcp_compute_url_map: - name: "{{ resource_name }}" - default_service: "{{ backendservice }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a backend service - gcp_compute_backend_service: - name: backendservice-urlmap - backends: - - group: "{{ instancegroup.selfLink }}" - health_checks: - - "{{ healthcheck.selfLink }}" - enable_cdn: 'true' - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: backendservice - ignore_errors: true -- name: delete a HTTP health check - gcp_compute_http_health_check: - name: httphealthcheck-urlmap - healthy_threshold: 10 - port: 8080 - timeout_sec: 2 - unhealthy_threshold: 5 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: healthcheck - ignore_errors: true -- name: delete a instance group - gcp_compute_instance_group: - name: instancegroup-urlmap - zone: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: instancegroup - ignore_errors: true +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_compute_vpn_tunnel/tasks/autogen.yml b/test/integration/targets/gcp_compute_vpn_tunnel/tasks/autogen.yml new file mode 100644 index 00000000000000..abd5dbb6d26d9e --- /dev/null +++ b/test/integration/targets/gcp_compute_vpn_tunnel/tasks/autogen.yml @@ -0,0 +1,202 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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: create a network + gcp_compute_network: + name: network-vpn-tunnel + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: network +- name: create a router + gcp_compute_router: + name: router-vpn-tunnel + network: "{{ network }}" + bgp: + asn: 64514 + advertise_mode: CUSTOM + advertised_groups: + - ALL_SUBNETS + advertised_ip_ranges: + - range: 1.2.3.4 + - range: 6.7.0.0/16 + region: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: router +- name: create a target vpn gateway + gcp_compute_target_vpn_gateway: + name: gateway-vpn-tunnel + region: us-west1 + network: "{{ network }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: gateway +- name: delete a vpn tunnel + gcp_compute_vpn_tunnel: + name: "{{ resource_name }}" + region: us-west1 + target_vpn_gateway: "{{ gateway }}" + router: "{{ router }}" + shared_secret: super secret + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a vpn tunnel + gcp_compute_vpn_tunnel: + name: "{{ resource_name }}" + region: us-west1 + target_vpn_gateway: "{{ gateway }}" + router: "{{ router }}" + shared_secret: super secret + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that vpn_tunnel was created + gcp_compute_vpn_tunnel_info: + filters: + - name = {{ resource_name }} + 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['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a vpn tunnel that already exists + gcp_compute_vpn_tunnel: + name: "{{ resource_name }}" + region: us-west1 + target_vpn_gateway: "{{ gateway }}" + router: "{{ router }}" + shared_secret: super secret + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a vpn tunnel + gcp_compute_vpn_tunnel: + name: "{{ resource_name }}" + region: us-west1 + target_vpn_gateway: "{{ gateway }}" + router: "{{ router }}" + shared_secret: super secret + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that vpn_tunnel was deleted + gcp_compute_vpn_tunnel_info: + filters: + - name = {{ resource_name }} + 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['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a vpn tunnel that does not exist + gcp_compute_vpn_tunnel: + name: "{{ resource_name }}" + region: us-west1 + target_vpn_gateway: "{{ gateway }}" + router: "{{ router }}" + shared_secret: super secret + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a target vpn gateway + gcp_compute_target_vpn_gateway: + name: gateway-vpn-tunnel + region: us-west1 + network: "{{ network }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: gateway + ignore_errors: true +- name: delete a router + gcp_compute_router: + name: router-vpn-tunnel + network: "{{ network }}" + bgp: + asn: 64514 + advertise_mode: CUSTOM + advertised_groups: + - ALL_SUBNETS + advertised_ip_ranges: + - range: 1.2.3.4 + - range: 6.7.0.0/16 + region: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: router + ignore_errors: true +- name: delete a network + gcp_compute_network: + name: network-vpn-tunnel + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: network + ignore_errors: true diff --git a/test/integration/targets/gcp_compute_vpn_tunnel/tasks/main.yml b/test/integration/targets/gcp_compute_vpn_tunnel/tasks/main.yml index abd5dbb6d26d9e..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_compute_vpn_tunnel/tasks/main.yml +++ b/test/integration/targets/gcp_compute_vpn_tunnel/tasks/main.yml @@ -1,202 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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: create a network - gcp_compute_network: - name: network-vpn-tunnel - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: network -- name: create a router - gcp_compute_router: - name: router-vpn-tunnel - network: "{{ network }}" - bgp: - asn: 64514 - advertise_mode: CUSTOM - advertised_groups: - - ALL_SUBNETS - advertised_ip_ranges: - - range: 1.2.3.4 - - range: 6.7.0.0/16 - region: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: router -- name: create a target vpn gateway - gcp_compute_target_vpn_gateway: - name: gateway-vpn-tunnel - region: us-west1 - network: "{{ network }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: gateway -- name: delete a vpn tunnel - gcp_compute_vpn_tunnel: - name: "{{ resource_name }}" - region: us-west1 - target_vpn_gateway: "{{ gateway }}" - router: "{{ router }}" - shared_secret: super secret - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a vpn tunnel - gcp_compute_vpn_tunnel: - name: "{{ resource_name }}" - region: us-west1 - target_vpn_gateway: "{{ gateway }}" - router: "{{ router }}" - shared_secret: super secret - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that vpn_tunnel was created - gcp_compute_vpn_tunnel_info: - filters: - - name = {{ resource_name }} - 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['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a vpn tunnel that already exists - gcp_compute_vpn_tunnel: - name: "{{ resource_name }}" - region: us-west1 - target_vpn_gateway: "{{ gateway }}" - router: "{{ router }}" - shared_secret: super secret - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a vpn tunnel - gcp_compute_vpn_tunnel: - name: "{{ resource_name }}" - region: us-west1 - target_vpn_gateway: "{{ gateway }}" - router: "{{ router }}" - shared_secret: super secret - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that vpn_tunnel was deleted - gcp_compute_vpn_tunnel_info: - filters: - - name = {{ resource_name }} - 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['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a vpn tunnel that does not exist - gcp_compute_vpn_tunnel: - name: "{{ resource_name }}" - region: us-west1 - target_vpn_gateway: "{{ gateway }}" - router: "{{ router }}" - shared_secret: super secret - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a target vpn gateway - gcp_compute_target_vpn_gateway: - name: gateway-vpn-tunnel - region: us-west1 - network: "{{ network }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: gateway - ignore_errors: true -- name: delete a router - gcp_compute_router: - name: router-vpn-tunnel - network: "{{ network }}" - bgp: - asn: 64514 - advertise_mode: CUSTOM - advertised_groups: - - ALL_SUBNETS - advertised_ip_ranges: - - range: 1.2.3.4 - - range: 6.7.0.0/16 - region: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: router - ignore_errors: true -- name: delete a network - gcp_compute_network: - name: network-vpn-tunnel - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: network - ignore_errors: true +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_container_cluster/tasks/autogen.yml b/test/integration/targets/gcp_container_cluster/tasks/autogen.yml new file mode 100644 index 00000000000000..1581a30fbb9f7c --- /dev/null +++ b/test/integration/targets/gcp_container_cluster/tasks/autogen.yml @@ -0,0 +1,140 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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 cluster + gcp_container_cluster: + name: my-cluster + initial_node_count: 2 + master_auth: + username: cluster_admin + password: my-secret-password + node_config: + machine_type: n1-standard-4 + disk_size_gb: 500 + location: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a cluster + gcp_container_cluster: + name: my-cluster + initial_node_count: 2 + master_auth: + username: cluster_admin + password: my-secret-password + node_config: + machine_type: n1-standard-4 + disk_size_gb: 500 + location: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that cluster was created + gcp_container_cluster_info: + location: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/cloud-platform + register: results +- name: verify that command succeeded + assert: + that: + - "'my-cluster' in \"{{ results['resources'] | map(attribute='name') | list }}\"" +# ---------------------------------------------------------------------------- +- name: create a cluster that already exists + gcp_container_cluster: + name: my-cluster + initial_node_count: 2 + master_auth: + username: cluster_admin + password: my-secret-password + node_config: + machine_type: n1-standard-4 + disk_size_gb: 500 + location: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a cluster + gcp_container_cluster: + name: my-cluster + initial_node_count: 2 + master_auth: + username: cluster_admin + password: my-secret-password + node_config: + machine_type: n1-standard-4 + disk_size_gb: 500 + location: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that cluster was deleted + gcp_container_cluster_info: + location: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/cloud-platform + register: results +- name: verify that command succeeded + assert: + that: + - "'my-cluster' not in \"{{ results['resources'] | map(attribute='name') | list }}\"" +# ---------------------------------------------------------------------------- +- name: delete a cluster that does not exist + gcp_container_cluster: + name: my-cluster + initial_node_count: 2 + master_auth: + username: cluster_admin + password: my-secret-password + node_config: + machine_type: n1-standard-4 + disk_size_gb: 500 + location: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_container_cluster/tasks/main.yml b/test/integration/targets/gcp_container_cluster/tasks/main.yml index 1581a30fbb9f7c..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_container_cluster/tasks/main.yml +++ b/test/integration/targets/gcp_container_cluster/tasks/main.yml @@ -1,140 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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 cluster - gcp_container_cluster: - name: my-cluster - initial_node_count: 2 - master_auth: - username: cluster_admin - password: my-secret-password - node_config: - machine_type: n1-standard-4 - disk_size_gb: 500 - location: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a cluster - gcp_container_cluster: - name: my-cluster - initial_node_count: 2 - master_auth: - username: cluster_admin - password: my-secret-password - node_config: - machine_type: n1-standard-4 - disk_size_gb: 500 - location: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that cluster was created - gcp_container_cluster_info: - location: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/cloud-platform - register: results -- name: verify that command succeeded - assert: - that: - - "'my-cluster' in \"{{ results['resources'] | map(attribute='name') | list }}\"" -# ---------------------------------------------------------------------------- -- name: create a cluster that already exists - gcp_container_cluster: - name: my-cluster - initial_node_count: 2 - master_auth: - username: cluster_admin - password: my-secret-password - node_config: - machine_type: n1-standard-4 - disk_size_gb: 500 - location: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a cluster - gcp_container_cluster: - name: my-cluster - initial_node_count: 2 - master_auth: - username: cluster_admin - password: my-secret-password - node_config: - machine_type: n1-standard-4 - disk_size_gb: 500 - location: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that cluster was deleted - gcp_container_cluster_info: - location: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/cloud-platform - register: results -- name: verify that command succeeded - assert: - that: - - "'my-cluster' not in \"{{ results['resources'] | map(attribute='name') | list }}\"" -# ---------------------------------------------------------------------------- -- name: delete a cluster that does not exist - gcp_container_cluster: - name: my-cluster - initial_node_count: 2 - master_auth: - username: cluster_admin - password: my-secret-password - node_config: - machine_type: n1-standard-4 - disk_size_gb: 500 - location: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_container_node_pool/tasks/autogen.yml b/test/integration/targets/gcp_container_node_pool/tasks/autogen.yml new file mode 100644 index 00000000000000..d62b7470594a63 --- /dev/null +++ b/test/integration/targets/gcp_container_node_pool/tasks/autogen.yml @@ -0,0 +1,141 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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: create a cluster + gcp_container_cluster: + name: cluster-nodepool + initial_node_count: 4 + location: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: cluster +- name: delete a node pool + gcp_container_node_pool: + name: my-pool + initial_node_count: 4 + cluster: "{{ cluster }}" + location: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a node pool + gcp_container_node_pool: + name: my-pool + initial_node_count: 4 + cluster: "{{ cluster }}" + location: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that node_pool was created + gcp_container_node_pool_info: + cluster: "{{ cluster }}" + location: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/cloud-platform + register: results +- name: verify that command succeeded + assert: + that: + - "'my-pool' in \"{{ results['resources'] | map(attribute='name') | list }}\"" +# ---------------------------------------------------------------------------- +- name: create a node pool that already exists + gcp_container_node_pool: + name: my-pool + initial_node_count: 4 + cluster: "{{ cluster }}" + location: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a node pool + gcp_container_node_pool: + name: my-pool + initial_node_count: 4 + cluster: "{{ cluster }}" + location: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that node_pool was deleted + gcp_container_node_pool_info: + cluster: "{{ cluster }}" + location: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/cloud-platform + register: results +- name: verify that command succeeded + assert: + that: + - "'my-pool' not in \"{{ results['resources'] | map(attribute='name') | list }}\"" +# ---------------------------------------------------------------------------- +- name: delete a node pool that does not exist + gcp_container_node_pool: + name: my-pool + initial_node_count: 4 + cluster: "{{ cluster }}" + location: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a cluster + gcp_container_cluster: + name: cluster-nodepool + initial_node_count: 4 + location: us-central1-a + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: cluster + ignore_errors: true diff --git a/test/integration/targets/gcp_container_node_pool/tasks/main.yml b/test/integration/targets/gcp_container_node_pool/tasks/main.yml index d62b7470594a63..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_container_node_pool/tasks/main.yml +++ b/test/integration/targets/gcp_container_node_pool/tasks/main.yml @@ -1,141 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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: create a cluster - gcp_container_cluster: - name: cluster-nodepool - initial_node_count: 4 - location: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: cluster -- name: delete a node pool - gcp_container_node_pool: - name: my-pool - initial_node_count: 4 - cluster: "{{ cluster }}" - location: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a node pool - gcp_container_node_pool: - name: my-pool - initial_node_count: 4 - cluster: "{{ cluster }}" - location: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that node_pool was created - gcp_container_node_pool_info: - cluster: "{{ cluster }}" - location: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/cloud-platform - register: results -- name: verify that command succeeded - assert: - that: - - "'my-pool' in \"{{ results['resources'] | map(attribute='name') | list }}\"" -# ---------------------------------------------------------------------------- -- name: create a node pool that already exists - gcp_container_node_pool: - name: my-pool - initial_node_count: 4 - cluster: "{{ cluster }}" - location: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a node pool - gcp_container_node_pool: - name: my-pool - initial_node_count: 4 - cluster: "{{ cluster }}" - location: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that node_pool was deleted - gcp_container_node_pool_info: - cluster: "{{ cluster }}" - location: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/cloud-platform - register: results -- name: verify that command succeeded - assert: - that: - - "'my-pool' not in \"{{ results['resources'] | map(attribute='name') | list }}\"" -# ---------------------------------------------------------------------------- -- name: delete a node pool that does not exist - gcp_container_node_pool: - name: my-pool - initial_node_count: 4 - cluster: "{{ cluster }}" - location: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a cluster - gcp_container_cluster: - name: cluster-nodepool - initial_node_count: 4 - location: us-central1-a - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: cluster - ignore_errors: true +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_dns_managed_zone/tasks/autogen.yml b/test/integration/targets/gcp_dns_managed_zone/tasks/autogen.yml new file mode 100644 index 00000000000000..21ce21009f1d6c --- /dev/null +++ b/test/integration/targets/gcp_dns_managed_zone/tasks/autogen.yml @@ -0,0 +1,110 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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 managed zone + gcp_dns_managed_zone: + name: "{{ resource_name }}" + dns_name: test.somewild2.example.com. + description: test zone + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a managed zone + gcp_dns_managed_zone: + name: "{{ resource_name }}" + dns_name: test.somewild2.example.com. + description: test zone + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that managed_zone was created + gcp_dns_managed_zone_info: + dns_name: test.somewild2.example.com. + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/ndev.clouddns.readwrite + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 1 +# ---------------------------------------------------------------------------- +- name: create a managed zone that already exists + gcp_dns_managed_zone: + name: "{{ resource_name }}" + dns_name: test.somewild2.example.com. + description: test zone + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a managed zone + gcp_dns_managed_zone: + name: "{{ resource_name }}" + dns_name: test.somewild2.example.com. + description: test zone + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that managed_zone was deleted + gcp_dns_managed_zone_info: + dns_name: test.somewild2.example.com. + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/ndev.clouddns.readwrite + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a managed zone that does not exist + gcp_dns_managed_zone: + name: "{{ resource_name }}" + dns_name: test.somewild2.example.com. + description: test zone + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_dns_managed_zone/tasks/main.yml b/test/integration/targets/gcp_dns_managed_zone/tasks/main.yml index 21ce21009f1d6c..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_dns_managed_zone/tasks/main.yml +++ b/test/integration/targets/gcp_dns_managed_zone/tasks/main.yml @@ -1,110 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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 managed zone - gcp_dns_managed_zone: - name: "{{ resource_name }}" - dns_name: test.somewild2.example.com. - description: test zone - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a managed zone - gcp_dns_managed_zone: - name: "{{ resource_name }}" - dns_name: test.somewild2.example.com. - description: test zone - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that managed_zone was created - gcp_dns_managed_zone_info: - dns_name: test.somewild2.example.com. - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/ndev.clouddns.readwrite - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 1 -# ---------------------------------------------------------------------------- -- name: create a managed zone that already exists - gcp_dns_managed_zone: - name: "{{ resource_name }}" - dns_name: test.somewild2.example.com. - description: test zone - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a managed zone - gcp_dns_managed_zone: - name: "{{ resource_name }}" - dns_name: test.somewild2.example.com. - description: test zone - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that managed_zone was deleted - gcp_dns_managed_zone_info: - dns_name: test.somewild2.example.com. - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/ndev.clouddns.readwrite - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a managed zone that does not exist - gcp_dns_managed_zone: - name: "{{ resource_name }}" - dns_name: test.somewild2.example.com. - description: test zone - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_dns_resource_record_set/tasks/autogen.yml b/test/integration/targets/gcp_dns_resource_record_set/tasks/autogen.yml new file mode 100644 index 00000000000000..8b5529656af506 --- /dev/null +++ b/test/integration/targets/gcp_dns_resource_record_set/tasks/autogen.yml @@ -0,0 +1,154 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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: create a managed zone + gcp_dns_managed_zone: + name: managedzone-rrs + dns_name: testzone-4.com. + description: test zone + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: managed_zone +- name: delete a resource record set + gcp_dns_resource_record_set: + name: www.testzone-4.com. + managed_zone: "{{ managed_zone }}" + type: A + ttl: 600 + target: + - 10.1.2.3 + - 40.5.6.7 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a resource record set + gcp_dns_resource_record_set: + name: www.testzone-4.com. + managed_zone: "{{ managed_zone }}" + type: A + ttl: 600 + target: + - 10.1.2.3 + - 40.5.6.7 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that resource_record_set was created + gcp_dns_resource_record_set_info: + managed_zone: "{{ managed_zone }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/ndev.clouddns.readwrite + register: results +- name: verify that command succeeded + assert: + that: + - "'www.testzone-4.com.'in \"{{ results['resources'] | map(attribute='name') | list }}\"" +# ---------------------------------------------------------------------------- +- name: create a resource record set that already exists + gcp_dns_resource_record_set: + name: www.testzone-4.com. + managed_zone: "{{ managed_zone }}" + type: A + ttl: 600 + target: + - 10.1.2.3 + - 40.5.6.7 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a resource record set + gcp_dns_resource_record_set: + name: www.testzone-4.com. + managed_zone: "{{ managed_zone }}" + type: A + ttl: 600 + target: + - 10.1.2.3 + - 40.5.6.7 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that resource_record_set was deleted + gcp_dns_resource_record_set_info: + managed_zone: "{{ managed_zone }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/ndev.clouddns.readwrite + register: results +- name: verify that command succeeded + assert: + that: + - "'www.testzone-4.com.'not in \"{{ results['resources'] | map(attribute='name') | list }}\"" +# ---------------------------------------------------------------------------- +- name: delete a resource record set that does not exist + gcp_dns_resource_record_set: + name: www.testzone-4.com. + managed_zone: "{{ managed_zone }}" + type: A + ttl: 600 + target: + - 10.1.2.3 + - 40.5.6.7 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a managed zone + gcp_dns_managed_zone: + name: managedzone-rrs + dns_name: testzone-4.com. + description: test zone + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: managed_zone + ignore_errors: true diff --git a/test/integration/targets/gcp_dns_resource_record_set/tasks/main.yml b/test/integration/targets/gcp_dns_resource_record_set/tasks/main.yml index 8b5529656af506..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_dns_resource_record_set/tasks/main.yml +++ b/test/integration/targets/gcp_dns_resource_record_set/tasks/main.yml @@ -1,154 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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: create a managed zone - gcp_dns_managed_zone: - name: managedzone-rrs - dns_name: testzone-4.com. - description: test zone - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: managed_zone -- name: delete a resource record set - gcp_dns_resource_record_set: - name: www.testzone-4.com. - managed_zone: "{{ managed_zone }}" - type: A - ttl: 600 - target: - - 10.1.2.3 - - 40.5.6.7 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a resource record set - gcp_dns_resource_record_set: - name: www.testzone-4.com. - managed_zone: "{{ managed_zone }}" - type: A - ttl: 600 - target: - - 10.1.2.3 - - 40.5.6.7 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that resource_record_set was created - gcp_dns_resource_record_set_info: - managed_zone: "{{ managed_zone }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/ndev.clouddns.readwrite - register: results -- name: verify that command succeeded - assert: - that: - - "'www.testzone-4.com.'in \"{{ results['resources'] | map(attribute='name') | list }}\"" -# ---------------------------------------------------------------------------- -- name: create a resource record set that already exists - gcp_dns_resource_record_set: - name: www.testzone-4.com. - managed_zone: "{{ managed_zone }}" - type: A - ttl: 600 - target: - - 10.1.2.3 - - 40.5.6.7 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a resource record set - gcp_dns_resource_record_set: - name: www.testzone-4.com. - managed_zone: "{{ managed_zone }}" - type: A - ttl: 600 - target: - - 10.1.2.3 - - 40.5.6.7 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that resource_record_set was deleted - gcp_dns_resource_record_set_info: - managed_zone: "{{ managed_zone }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/ndev.clouddns.readwrite - register: results -- name: verify that command succeeded - assert: - that: - - "'www.testzone-4.com.'not in \"{{ results['resources'] | map(attribute='name') | list }}\"" -# ---------------------------------------------------------------------------- -- name: delete a resource record set that does not exist - gcp_dns_resource_record_set: - name: www.testzone-4.com. - managed_zone: "{{ managed_zone }}" - type: A - ttl: 600 - target: - - 10.1.2.3 - - 40.5.6.7 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a managed zone - gcp_dns_managed_zone: - name: managedzone-rrs - dns_name: testzone-4.com. - description: test zone - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: managed_zone - ignore_errors: true +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_filestore_instance/tasks/autogen.yml b/test/integration/targets/gcp_filestore_instance/tasks/autogen.yml new file mode 100644 index 00000000000000..4713f094b01050 --- /dev/null +++ b/test/integration/targets/gcp_filestore_instance/tasks/autogen.yml @@ -0,0 +1,145 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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 instance + gcp_filestore_instance: + name: "{{ resource_name }}" + zone: us-central1-b + tier: PREMIUM + file_shares: + - capacity_gb: 2660 + name: share1 + networks: + - network: default + modes: + - MODE_IPV4 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a instance + gcp_filestore_instance: + name: "{{ resource_name }}" + zone: us-central1-b + tier: PREMIUM + file_shares: + - capacity_gb: 2660 + name: share1 + networks: + - network: default + modes: + - MODE_IPV4 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that instance was created + gcp_filestore_instance_info: + zone: us-central1-b + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/cloud-platform + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 1 +# ---------------------------------------------------------------------------- +- name: create a instance that already exists + gcp_filestore_instance: + name: "{{ resource_name }}" + zone: us-central1-b + tier: PREMIUM + file_shares: + - capacity_gb: 2660 + name: share1 + networks: + - network: default + modes: + - MODE_IPV4 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a instance + gcp_filestore_instance: + name: "{{ resource_name }}" + zone: us-central1-b + tier: PREMIUM + file_shares: + - capacity_gb: 2660 + name: share1 + networks: + - network: default + modes: + - MODE_IPV4 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that instance was deleted + gcp_filestore_instance_info: + zone: us-central1-b + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/cloud-platform + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a instance that does not exist + gcp_filestore_instance: + name: "{{ resource_name }}" + zone: us-central1-b + tier: PREMIUM + file_shares: + - capacity_gb: 2660 + name: share1 + networks: + - network: default + modes: + - MODE_IPV4 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_filestore_instance/tasks/main.yml b/test/integration/targets/gcp_filestore_instance/tasks/main.yml index 4713f094b01050..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_filestore_instance/tasks/main.yml +++ b/test/integration/targets/gcp_filestore_instance/tasks/main.yml @@ -1,145 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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 instance - gcp_filestore_instance: - name: "{{ resource_name }}" - zone: us-central1-b - tier: PREMIUM - file_shares: - - capacity_gb: 2660 - name: share1 - networks: - - network: default - modes: - - MODE_IPV4 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a instance - gcp_filestore_instance: - name: "{{ resource_name }}" - zone: us-central1-b - tier: PREMIUM - file_shares: - - capacity_gb: 2660 - name: share1 - networks: - - network: default - modes: - - MODE_IPV4 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that instance was created - gcp_filestore_instance_info: - zone: us-central1-b - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/cloud-platform - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 1 -# ---------------------------------------------------------------------------- -- name: create a instance that already exists - gcp_filestore_instance: - name: "{{ resource_name }}" - zone: us-central1-b - tier: PREMIUM - file_shares: - - capacity_gb: 2660 - name: share1 - networks: - - network: default - modes: - - MODE_IPV4 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a instance - gcp_filestore_instance: - name: "{{ resource_name }}" - zone: us-central1-b - tier: PREMIUM - file_shares: - - capacity_gb: 2660 - name: share1 - networks: - - network: default - modes: - - MODE_IPV4 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that instance was deleted - gcp_filestore_instance_info: - zone: us-central1-b - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/cloud-platform - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a instance that does not exist - gcp_filestore_instance: - name: "{{ resource_name }}" - zone: us-central1-b - tier: PREMIUM - file_shares: - - capacity_gb: 2660 - name: share1 - networks: - - network: default - modes: - - MODE_IPV4 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_iam_role/tasks/autogen.yml b/test/integration/targets/gcp_iam_role/tasks/autogen.yml new file mode 100644 index 00000000000000..04779f9489ee0d --- /dev/null +++ b/test/integration/targets/gcp_iam_role/tasks/autogen.yml @@ -0,0 +1,128 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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 role + gcp_iam_role: + name: myCustomRole2 + title: My Custom Role + description: My custom role description + included_permissions: + - iam.roles.list + - iam.roles.create + - iam.roles.delete + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a role + gcp_iam_role: + name: myCustomRole2 + title: My Custom Role + description: My custom role description + included_permissions: + - iam.roles.list + - iam.roles.create + - iam.roles.delete + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that role was created + gcp_iam_role_info: + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/iam + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | map(attribute='name') | select("match", ".*myCustomRole2.*") | list | length == 1 +# ---------------------------------------------------------------------------- +- name: create a role that already exists + gcp_iam_role: + name: myCustomRole2 + title: My Custom Role + description: My custom role description + included_permissions: + - iam.roles.list + - iam.roles.create + - iam.roles.delete + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a role + gcp_iam_role: + name: myCustomRole2 + title: My Custom Role + description: My custom role description + included_permissions: + - iam.roles.list + - iam.roles.create + - iam.roles.delete + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that role was deleted + gcp_iam_role_info: + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/iam + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | map(attribute='name') | select("match", ".*myCustomRole2.*") | list | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a role that does not exist + gcp_iam_role: + name: myCustomRole2 + title: My Custom Role + description: My custom role description + included_permissions: + - iam.roles.list + - iam.roles.create + - iam.roles.delete + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_iam_role/tasks/main.yml b/test/integration/targets/gcp_iam_role/tasks/main.yml index 04779f9489ee0d..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_iam_role/tasks/main.yml +++ b/test/integration/targets/gcp_iam_role/tasks/main.yml @@ -1,128 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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 role - gcp_iam_role: - name: myCustomRole2 - title: My Custom Role - description: My custom role description - included_permissions: - - iam.roles.list - - iam.roles.create - - iam.roles.delete - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a role - gcp_iam_role: - name: myCustomRole2 - title: My Custom Role - description: My custom role description - included_permissions: - - iam.roles.list - - iam.roles.create - - iam.roles.delete - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that role was created - gcp_iam_role_info: - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/iam - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | map(attribute='name') | select("match", ".*myCustomRole2.*") | list | length == 1 -# ---------------------------------------------------------------------------- -- name: create a role that already exists - gcp_iam_role: - name: myCustomRole2 - title: My Custom Role - description: My custom role description - included_permissions: - - iam.roles.list - - iam.roles.create - - iam.roles.delete - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a role - gcp_iam_role: - name: myCustomRole2 - title: My Custom Role - description: My custom role description - included_permissions: - - iam.roles.list - - iam.roles.create - - iam.roles.delete - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that role was deleted - gcp_iam_role_info: - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/iam - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | map(attribute='name') | select("match", ".*myCustomRole2.*") | list | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a role that does not exist - gcp_iam_role: - name: myCustomRole2 - title: My Custom Role - description: My custom role description - included_permissions: - - iam.roles.list - - iam.roles.create - - iam.roles.delete - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_iam_service_account/tasks/autogen.yml b/test/integration/targets/gcp_iam_service_account/tasks/autogen.yml new file mode 100644 index 00000000000000..1911ad9c2785ec --- /dev/null +++ b/test/integration/targets/gcp_iam_service_account/tasks/autogen.yml @@ -0,0 +1,103 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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 service account + gcp_iam_service_account: + name: sa-{{ resource_name.split("-")[-1] }}@graphite-playground.google.com.iam.gserviceaccount.com + display_name: My Ansible test key + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a service account + gcp_iam_service_account: + name: sa-{{ resource_name.split("-")[-1] }}@graphite-playground.google.com.iam.gserviceaccount.com + display_name: My Ansible test key + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that service_account was created + gcp_iam_service_account_info: + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/iam + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | map(attribute='name') | select("match", ".*sa-{{ resource_name.split("-")[-1] }}@graphite-playground.google.com.iam.gserviceaccount.com.*") | list | length == 1 +# ---------------------------------------------------------------------------- +- name: create a service account that already exists + gcp_iam_service_account: + name: sa-{{ resource_name.split("-")[-1] }}@graphite-playground.google.com.iam.gserviceaccount.com + display_name: My Ansible test key + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a service account + gcp_iam_service_account: + name: sa-{{ resource_name.split("-")[-1] }}@graphite-playground.google.com.iam.gserviceaccount.com + display_name: My Ansible test key + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that service_account was deleted + gcp_iam_service_account_info: + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/iam + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | map(attribute='name') | select("match", ".*sa-{{ resource_name.split("-")[-1] }}@graphite-playground.google.com.iam.gserviceaccount.com.*") | list | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a service account that does not exist + gcp_iam_service_account: + name: sa-{{ resource_name.split("-")[-1] }}@graphite-playground.google.com.iam.gserviceaccount.com + display_name: My Ansible test key + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_iam_service_account/tasks/main.yml b/test/integration/targets/gcp_iam_service_account/tasks/main.yml index 1911ad9c2785ec..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_iam_service_account/tasks/main.yml +++ b/test/integration/targets/gcp_iam_service_account/tasks/main.yml @@ -1,103 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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 service account - gcp_iam_service_account: - name: sa-{{ resource_name.split("-")[-1] }}@graphite-playground.google.com.iam.gserviceaccount.com - display_name: My Ansible test key - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a service account - gcp_iam_service_account: - name: sa-{{ resource_name.split("-")[-1] }}@graphite-playground.google.com.iam.gserviceaccount.com - display_name: My Ansible test key - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that service_account was created - gcp_iam_service_account_info: - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/iam - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | map(attribute='name') | select("match", ".*sa-{{ resource_name.split("-")[-1] }}@graphite-playground.google.com.iam.gserviceaccount.com.*") | list | length == 1 -# ---------------------------------------------------------------------------- -- name: create a service account that already exists - gcp_iam_service_account: - name: sa-{{ resource_name.split("-")[-1] }}@graphite-playground.google.com.iam.gserviceaccount.com - display_name: My Ansible test key - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a service account - gcp_iam_service_account: - name: sa-{{ resource_name.split("-")[-1] }}@graphite-playground.google.com.iam.gserviceaccount.com - display_name: My Ansible test key - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that service_account was deleted - gcp_iam_service_account_info: - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/iam - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | map(attribute='name') | select("match", ".*sa-{{ resource_name.split("-")[-1] }}@graphite-playground.google.com.iam.gserviceaccount.com.*") | list | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a service account that does not exist - gcp_iam_service_account: - name: sa-{{ resource_name.split("-")[-1] }}@graphite-playground.google.com.iam.gserviceaccount.com - display_name: My Ansible test key - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_kms_crypto_key/tasks/autogen.yml b/test/integration/targets/gcp_kms_crypto_key/tasks/autogen.yml new file mode 100644 index 00000000000000..ef2252c863e03c --- /dev/null +++ b/test/integration/targets/gcp_kms_crypto_key/tasks/autogen.yml @@ -0,0 +1,73 @@ +# Copyright 2019 Google Inc. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- +# Pre-test setup +- name: create a key ring + gcp_kms_key_ring: + name: key-key-ring + location: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: keyring +- name: delete a crypto key + gcp_kms_crypto_key: + name: "{{ resource_name }}" + key_ring: projects/{{ gcp_project }}/locations/us-central1/keyRings/key-key-ring + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a crypto key + gcp_kms_crypto_key: + name: "{{ resource_name }}" + key_ring: projects/{{ gcp_project }}/locations/us-central1/keyRings/key-key-ring + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that crypto_key was created + gcp_kms_crypto_key_info: + key_ring: "projects/{{ gcp_project }}/locations/us-central1/keyRings/key-key-ring" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/cloudkms + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 1 +# ---------------------------------------------------------------------------- +- name: create a crypto key that already exists + gcp_kms_crypto_key: + name: "{{ resource_name }}" + key_ring: projects/{{ gcp_project }}/locations/us-central1/keyRings/key-key-ring + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_kms_crypto_key/tasks/main.yml b/test/integration/targets/gcp_kms_crypto_key/tasks/main.yml index ef2252c863e03c..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_kms_crypto_key/tasks/main.yml +++ b/test/integration/targets/gcp_kms_crypto_key/tasks/main.yml @@ -1,73 +1,2 @@ -# Copyright 2019 Google Inc. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - --- -# Pre-test setup -- name: create a key ring - gcp_kms_key_ring: - name: key-key-ring - location: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: keyring -- name: delete a crypto key - gcp_kms_crypto_key: - name: "{{ resource_name }}" - key_ring: projects/{{ gcp_project }}/locations/us-central1/keyRings/key-key-ring - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a crypto key - gcp_kms_crypto_key: - name: "{{ resource_name }}" - key_ring: projects/{{ gcp_project }}/locations/us-central1/keyRings/key-key-ring - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that crypto_key was created - gcp_kms_crypto_key_info: - key_ring: "projects/{{ gcp_project }}/locations/us-central1/keyRings/key-key-ring" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/cloudkms - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 1 -# ---------------------------------------------------------------------------- -- name: create a crypto key that already exists - gcp_kms_crypto_key: - name: "{{ resource_name }}" - key_ring: projects/{{ gcp_project }}/locations/us-central1/keyRings/key-key-ring - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_kms_key_ring/tasks/autogen.yml b/test/integration/targets/gcp_kms_key_ring/tasks/autogen.yml new file mode 100644 index 00000000000000..34999ab1bb4b60 --- /dev/null +++ b/test/integration/targets/gcp_kms_key_ring/tasks/autogen.yml @@ -0,0 +1,63 @@ +# Copyright 2019 Google Inc. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Pre-test setup +- name: delete a key ring + gcp_kms_key_ring: + name: "{{ resource_name }}" + location: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a key ring + gcp_kms_key_ring: + name: "{{ resource_name }}" + location: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that key_ring was created + gcp_kms_key_ring_info: + location: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/cloudkms + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 1 +# ---------------------------------------------------------------------------- +- name: create a key ring that already exists + gcp_kms_key_ring: + name: "{{ resource_name }}" + location: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_kms_key_ring/tasks/main.yml b/test/integration/targets/gcp_kms_key_ring/tasks/main.yml index 34999ab1bb4b60..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_kms_key_ring/tasks/main.yml +++ b/test/integration/targets/gcp_kms_key_ring/tasks/main.yml @@ -1,63 +1,2 @@ -# Copyright 2019 Google Inc. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Pre-test setup -- name: delete a key ring - gcp_kms_key_ring: - name: "{{ resource_name }}" - location: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a key ring - gcp_kms_key_ring: - name: "{{ resource_name }}" - location: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that key_ring was created - gcp_kms_key_ring_info: - location: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/cloudkms - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 1 -# ---------------------------------------------------------------------------- -- name: create a key ring that already exists - gcp_kms_key_ring: - name: "{{ resource_name }}" - location: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +--- +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_mlengine_model/tasks/autogen.yml b/test/integration/targets/gcp_mlengine_model/tasks/autogen.yml new file mode 100644 index 00000000000000..c30bd524a84e7b --- /dev/null +++ b/test/integration/targets/gcp_mlengine_model/tasks/autogen.yml @@ -0,0 +1,113 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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 model + gcp_mlengine_model: + name: "{{ resource_name | replace('-', '_') }}" + description: My model + regions: + - us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a model + gcp_mlengine_model: + name: "{{ resource_name | replace('-', '_') }}" + description: My model + regions: + - us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that model was created + gcp_mlengine_model_info: + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/cloud-platform + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name | replace('-', '_') }}.*") | list | length == 1 +# ---------------------------------------------------------------------------- +- name: create a model that already exists + gcp_mlengine_model: + name: "{{ resource_name | replace('-', '_') }}" + description: My model + regions: + - us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a model + gcp_mlengine_model: + name: "{{ resource_name | replace('-', '_') }}" + description: My model + regions: + - us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that model was deleted + gcp_mlengine_model_info: + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/cloud-platform + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name | replace('-', '_') }}.*") | list | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a model that does not exist + gcp_mlengine_model: + name: "{{ resource_name | replace('-', '_') }}" + description: My model + regions: + - us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_mlengine_model/tasks/main.yml b/test/integration/targets/gcp_mlengine_model/tasks/main.yml index c30bd524a84e7b..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_mlengine_model/tasks/main.yml +++ b/test/integration/targets/gcp_mlengine_model/tasks/main.yml @@ -1,113 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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 model - gcp_mlengine_model: - name: "{{ resource_name | replace('-', '_') }}" - description: My model - regions: - - us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a model - gcp_mlengine_model: - name: "{{ resource_name | replace('-', '_') }}" - description: My model - regions: - - us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that model was created - gcp_mlengine_model_info: - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/cloud-platform - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name | replace('-', '_') }}.*") | list | length == 1 -# ---------------------------------------------------------------------------- -- name: create a model that already exists - gcp_mlengine_model: - name: "{{ resource_name | replace('-', '_') }}" - description: My model - regions: - - us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a model - gcp_mlengine_model: - name: "{{ resource_name | replace('-', '_') }}" - description: My model - regions: - - us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that model was deleted - gcp_mlengine_model_info: - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/cloud-platform - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name | replace('-', '_') }}.*") | list | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a model that does not exist - gcp_mlengine_model: - name: "{{ resource_name | replace('-', '_') }}" - description: My model - regions: - - us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_mlengine_version/tasks/autogen.yml b/test/integration/targets/gcp_mlengine_version/tasks/autogen.yml new file mode 100644 index 00000000000000..c84d3a5e9e36a0 --- /dev/null +++ b/test/integration/targets/gcp_mlengine_version/tasks/autogen.yml @@ -0,0 +1,155 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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: create a model + gcp_mlengine_model: + name: model_version + description: My model + regions: + - us-central1 + online_prediction_logging: 'true' + online_prediction_console_logging: 'true' + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: model +- name: delete a version + gcp_mlengine_version: + name: "{{ resource_name | replace('-', '_') }}" + model: "{{ model }}" + runtime_version: 1.13 + python_version: 3.5 + is_default: 'true' + deployment_uri: gs://ansible-cloudml-bucket/ + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a version + gcp_mlengine_version: + name: "{{ resource_name | replace('-', '_') }}" + model: "{{ model }}" + runtime_version: 1.13 + python_version: 3.5 + is_default: 'true' + deployment_uri: gs://ansible-cloudml-bucket/ + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that version was created + gcp_mlengine_version_info: + model: "{{ model }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/cloud-platform + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name | replace('-', '_') }}.*") | list | length == 1 +# ---------------------------------------------------------------------------- +- name: create a version that already exists + gcp_mlengine_version: + name: "{{ resource_name | replace('-', '_') }}" + model: "{{ model }}" + runtime_version: 1.13 + python_version: 3.5 + is_default: 'true' + deployment_uri: gs://ansible-cloudml-bucket/ + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a version + gcp_mlengine_version: + name: "{{ resource_name | replace('-', '_') }}" + model: "{{ model }}" + runtime_version: 1.13 + python_version: 3.5 + is_default: 'true' + deployment_uri: gs://ansible-cloudml-bucket/ + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that version was deleted + gcp_mlengine_version_info: + model: "{{ model }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/cloud-platform + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name | replace('-', '_') }}.*") | list | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a version that does not exist + gcp_mlengine_version: + name: "{{ resource_name | replace('-', '_') }}" + model: "{{ model }}" + runtime_version: 1.13 + python_version: 3.5 + is_default: 'true' + deployment_uri: gs://ansible-cloudml-bucket/ + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a model + gcp_mlengine_model: + name: model_version + description: My model + regions: + - us-central1 + online_prediction_logging: 'true' + online_prediction_console_logging: 'true' + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: model + ignore_errors: true diff --git a/test/integration/targets/gcp_mlengine_version/tasks/main.yml b/test/integration/targets/gcp_mlengine_version/tasks/main.yml index c84d3a5e9e36a0..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_mlengine_version/tasks/main.yml +++ b/test/integration/targets/gcp_mlengine_version/tasks/main.yml @@ -1,155 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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: create a model - gcp_mlengine_model: - name: model_version - description: My model - regions: - - us-central1 - online_prediction_logging: 'true' - online_prediction_console_logging: 'true' - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: model -- name: delete a version - gcp_mlengine_version: - name: "{{ resource_name | replace('-', '_') }}" - model: "{{ model }}" - runtime_version: 1.13 - python_version: 3.5 - is_default: 'true' - deployment_uri: gs://ansible-cloudml-bucket/ - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a version - gcp_mlengine_version: - name: "{{ resource_name | replace('-', '_') }}" - model: "{{ model }}" - runtime_version: 1.13 - python_version: 3.5 - is_default: 'true' - deployment_uri: gs://ansible-cloudml-bucket/ - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that version was created - gcp_mlengine_version_info: - model: "{{ model }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/cloud-platform - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name | replace('-', '_') }}.*") | list | length == 1 -# ---------------------------------------------------------------------------- -- name: create a version that already exists - gcp_mlengine_version: - name: "{{ resource_name | replace('-', '_') }}" - model: "{{ model }}" - runtime_version: 1.13 - python_version: 3.5 - is_default: 'true' - deployment_uri: gs://ansible-cloudml-bucket/ - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a version - gcp_mlengine_version: - name: "{{ resource_name | replace('-', '_') }}" - model: "{{ model }}" - runtime_version: 1.13 - python_version: 3.5 - is_default: 'true' - deployment_uri: gs://ansible-cloudml-bucket/ - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that version was deleted - gcp_mlengine_version_info: - model: "{{ model }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/cloud-platform - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name | replace('-', '_') }}.*") | list | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a version that does not exist - gcp_mlengine_version: - name: "{{ resource_name | replace('-', '_') }}" - model: "{{ model }}" - runtime_version: 1.13 - python_version: 3.5 - is_default: 'true' - deployment_uri: gs://ansible-cloudml-bucket/ - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a model - gcp_mlengine_model: - name: model_version - description: My model - regions: - - us-central1 - online_prediction_logging: 'true' - online_prediction_console_logging: 'true' - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: model - ignore_errors: true +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_pubsub_subscription/tasks/autogen.yml b/test/integration/targets/gcp_pubsub_subscription/tasks/autogen.yml new file mode 100644 index 00000000000000..c7babda72ee043 --- /dev/null +++ b/test/integration/targets/gcp_pubsub_subscription/tasks/autogen.yml @@ -0,0 +1,128 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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: create a topic + gcp_pubsub_topic: + name: topic-subscription + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: topic +- name: delete a subscription + gcp_pubsub_subscription: + name: "{{ resource_name }}" + topic: "{{ topic }}" + ack_deadline_seconds: 300 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a subscription + gcp_pubsub_subscription: + name: "{{ resource_name }}" + topic: "{{ topic }}" + ack_deadline_seconds: 300 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that subscription was created + gcp_pubsub_subscription_info: + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/pubsub + register: results +- name: verify that command succeeded + assert: + that: + - "\"{{resource_name}}\" in \"{{ results['resources'] | map(attribute='name') | list }}\"" +# ---------------------------------------------------------------------------- +- name: create a subscription that already exists + gcp_pubsub_subscription: + name: "{{ resource_name }}" + topic: "{{ topic }}" + ack_deadline_seconds: 300 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a subscription + gcp_pubsub_subscription: + name: "{{ resource_name }}" + topic: "{{ topic }}" + ack_deadline_seconds: 300 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that subscription was deleted + gcp_pubsub_subscription_info: + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/pubsub + register: results +- name: verify that command succeeded + assert: + that: + - "\"{{resource_name}}\" not in \"{{ results['resources'] | map(attribute='name') | list }}\"" +# ---------------------------------------------------------------------------- +- name: delete a subscription that does not exist + gcp_pubsub_subscription: + name: "{{ resource_name }}" + topic: "{{ topic }}" + ack_deadline_seconds: 300 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a topic + gcp_pubsub_topic: + name: topic-subscription + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: topic + ignore_errors: true diff --git a/test/integration/targets/gcp_pubsub_subscription/tasks/main.yml b/test/integration/targets/gcp_pubsub_subscription/tasks/main.yml index c7babda72ee043..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_pubsub_subscription/tasks/main.yml +++ b/test/integration/targets/gcp_pubsub_subscription/tasks/main.yml @@ -1,128 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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: create a topic - gcp_pubsub_topic: - name: topic-subscription - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: topic -- name: delete a subscription - gcp_pubsub_subscription: - name: "{{ resource_name }}" - topic: "{{ topic }}" - ack_deadline_seconds: 300 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a subscription - gcp_pubsub_subscription: - name: "{{ resource_name }}" - topic: "{{ topic }}" - ack_deadline_seconds: 300 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that subscription was created - gcp_pubsub_subscription_info: - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/pubsub - register: results -- name: verify that command succeeded - assert: - that: - - "\"{{resource_name}}\" in \"{{ results['resources'] | map(attribute='name') | list }}\"" -# ---------------------------------------------------------------------------- -- name: create a subscription that already exists - gcp_pubsub_subscription: - name: "{{ resource_name }}" - topic: "{{ topic }}" - ack_deadline_seconds: 300 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a subscription - gcp_pubsub_subscription: - name: "{{ resource_name }}" - topic: "{{ topic }}" - ack_deadline_seconds: 300 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that subscription was deleted - gcp_pubsub_subscription_info: - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/pubsub - register: results -- name: verify that command succeeded - assert: - that: - - "\"{{resource_name}}\" not in \"{{ results['resources'] | map(attribute='name') | list }}\"" -# ---------------------------------------------------------------------------- -- name: delete a subscription that does not exist - gcp_pubsub_subscription: - name: "{{ resource_name }}" - topic: "{{ topic }}" - ack_deadline_seconds: 300 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a topic - gcp_pubsub_topic: - name: topic-subscription - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: topic - ignore_errors: true +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_pubsub_topic/tasks/autogen.yml b/test/integration/targets/gcp_pubsub_topic/tasks/autogen.yml new file mode 100644 index 00000000000000..9dff2b2d7190aa --- /dev/null +++ b/test/integration/targets/gcp_pubsub_topic/tasks/autogen.yml @@ -0,0 +1,98 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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 topic + gcp_pubsub_topic: + name: test-topic1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a topic + gcp_pubsub_topic: + name: test-topic1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that topic was created + gcp_pubsub_topic_info: + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/pubsub + register: results +- name: verify that command succeeded + assert: + that: + - "'test-topic1' in \"{{ results['resources'] | map(attribute='name') | list }}\"" +# ---------------------------------------------------------------------------- +- name: create a topic that already exists + gcp_pubsub_topic: + name: test-topic1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a topic + gcp_pubsub_topic: + name: test-topic1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that topic was deleted + gcp_pubsub_topic_info: + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/pubsub + register: results +- name: verify that command succeeded + assert: + that: + - "'test-topic1' not in \"{{ results['resources'] | map(attribute='name') | list }}\"" +# ---------------------------------------------------------------------------- +- name: delete a topic that does not exist + gcp_pubsub_topic: + name: test-topic1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_pubsub_topic/tasks/main.yml b/test/integration/targets/gcp_pubsub_topic/tasks/main.yml index 9dff2b2d7190aa..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_pubsub_topic/tasks/main.yml +++ b/test/integration/targets/gcp_pubsub_topic/tasks/main.yml @@ -1,98 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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 topic - gcp_pubsub_topic: - name: test-topic1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a topic - gcp_pubsub_topic: - name: test-topic1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that topic was created - gcp_pubsub_topic_info: - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/pubsub - register: results -- name: verify that command succeeded - assert: - that: - - "'test-topic1' in \"{{ results['resources'] | map(attribute='name') | list }}\"" -# ---------------------------------------------------------------------------- -- name: create a topic that already exists - gcp_pubsub_topic: - name: test-topic1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a topic - gcp_pubsub_topic: - name: test-topic1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that topic was deleted - gcp_pubsub_topic_info: - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/pubsub - register: results -- name: verify that command succeeded - assert: - that: - - "'test-topic1' not in \"{{ results['resources'] | map(attribute='name') | list }}\"" -# ---------------------------------------------------------------------------- -- name: delete a topic that does not exist - gcp_pubsub_topic: - name: test-topic1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_redis_instance/tasks/autogen.yml b/test/integration/targets/gcp_redis_instance/tasks/autogen.yml new file mode 100644 index 00000000000000..b859625b98ce9e --- /dev/null +++ b/test/integration/targets/gcp_redis_instance/tasks/autogen.yml @@ -0,0 +1,170 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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: create a network + gcp_compute_network: + name: network-instance + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: network +- name: delete a instance + gcp_redis_instance: + name: instance37 + tier: STANDARD_HA + memory_size_gb: 1 + region: us-central1 + location_id: us-central1-a + redis_version: REDIS_3_2 + display_name: Ansible Test Instance + reserved_ip_range: 192.168.0.0/29 + labels: + my_key: my_val + other_key: other_val + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a instance + gcp_redis_instance: + name: instance37 + tier: STANDARD_HA + memory_size_gb: 1 + region: us-central1 + location_id: us-central1-a + redis_version: REDIS_3_2 + display_name: Ansible Test Instance + reserved_ip_range: 192.168.0.0/29 + labels: + my_key: my_val + other_key: other_val + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that instance was created + gcp_redis_instance_info: + region: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/cloud-platform + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | map(attribute='name') | select("match", ".*instance37.*") | list | length == 1 +# ---------------------------------------------------------------------------- +- name: create a instance that already exists + gcp_redis_instance: + name: instance37 + tier: STANDARD_HA + memory_size_gb: 1 + region: us-central1 + location_id: us-central1-a + redis_version: REDIS_3_2 + display_name: Ansible Test Instance + reserved_ip_range: 192.168.0.0/29 + labels: + my_key: my_val + other_key: other_val + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a instance + gcp_redis_instance: + name: instance37 + tier: STANDARD_HA + memory_size_gb: 1 + region: us-central1 + location_id: us-central1-a + redis_version: REDIS_3_2 + display_name: Ansible Test Instance + reserved_ip_range: 192.168.0.0/29 + labels: + my_key: my_val + other_key: other_val + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that instance was deleted + gcp_redis_instance_info: + region: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/cloud-platform + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | map(attribute='name') | select("match", ".*instance37.*") | list | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a instance that does not exist + gcp_redis_instance: + name: instance37 + tier: STANDARD_HA + memory_size_gb: 1 + region: us-central1 + location_id: us-central1-a + redis_version: REDIS_3_2 + display_name: Ansible Test Instance + reserved_ip_range: 192.168.0.0/29 + labels: + my_key: my_val + other_key: other_val + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a network + gcp_compute_network: + name: network-instance + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: network + ignore_errors: true diff --git a/test/integration/targets/gcp_redis_instance/tasks/main.yml b/test/integration/targets/gcp_redis_instance/tasks/main.yml index b859625b98ce9e..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_redis_instance/tasks/main.yml +++ b/test/integration/targets/gcp_redis_instance/tasks/main.yml @@ -1,170 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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: create a network - gcp_compute_network: - name: network-instance - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: network -- name: delete a instance - gcp_redis_instance: - name: instance37 - tier: STANDARD_HA - memory_size_gb: 1 - region: us-central1 - location_id: us-central1-a - redis_version: REDIS_3_2 - display_name: Ansible Test Instance - reserved_ip_range: 192.168.0.0/29 - labels: - my_key: my_val - other_key: other_val - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a instance - gcp_redis_instance: - name: instance37 - tier: STANDARD_HA - memory_size_gb: 1 - region: us-central1 - location_id: us-central1-a - redis_version: REDIS_3_2 - display_name: Ansible Test Instance - reserved_ip_range: 192.168.0.0/29 - labels: - my_key: my_val - other_key: other_val - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that instance was created - gcp_redis_instance_info: - region: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/cloud-platform - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | map(attribute='name') | select("match", ".*instance37.*") | list | length == 1 -# ---------------------------------------------------------------------------- -- name: create a instance that already exists - gcp_redis_instance: - name: instance37 - tier: STANDARD_HA - memory_size_gb: 1 - region: us-central1 - location_id: us-central1-a - redis_version: REDIS_3_2 - display_name: Ansible Test Instance - reserved_ip_range: 192.168.0.0/29 - labels: - my_key: my_val - other_key: other_val - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a instance - gcp_redis_instance: - name: instance37 - tier: STANDARD_HA - memory_size_gb: 1 - region: us-central1 - location_id: us-central1-a - redis_version: REDIS_3_2 - display_name: Ansible Test Instance - reserved_ip_range: 192.168.0.0/29 - labels: - my_key: my_val - other_key: other_val - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that instance was deleted - gcp_redis_instance_info: - region: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/cloud-platform - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | map(attribute='name') | select("match", ".*instance37.*") | list | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a instance that does not exist - gcp_redis_instance: - name: instance37 - tier: STANDARD_HA - memory_size_gb: 1 - region: us-central1 - location_id: us-central1-a - redis_version: REDIS_3_2 - display_name: Ansible Test Instance - reserved_ip_range: 192.168.0.0/29 - labels: - my_key: my_val - other_key: other_val - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a network - gcp_compute_network: - name: network-instance - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: network - ignore_errors: true +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_resourcemanager_project/tasks/autogen.yml b/test/integration/targets/gcp_resourcemanager_project/tasks/autogen.yml new file mode 100644 index 00000000000000..083660a9d275a5 --- /dev/null +++ b/test/integration/targets/gcp_resourcemanager_project/tasks/autogen.yml @@ -0,0 +1,113 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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 project + gcp_resourcemanager_project: + name: My Sample Project + id: alextest-{{ 10000000000 | random }} + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + parent: + type: organization + id: 636173955921 + state: absent +#---------------------------------------------------------- +- name: create a project + gcp_resourcemanager_project: + name: My Sample Project + id: alextest-{{ 10000000000 | random }} + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + parent: + type: organization + id: 636173955921 + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that project was created + gcp_resourcemanager_project_info: + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/cloud-platform + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | map(attribute='name') | select("match", ".*My Sample Project.*") | list | length == 1 +# ---------------------------------------------------------------------------- +- name: create a project that already exists + gcp_resourcemanager_project: + name: My Sample Project + id: alextest-{{ 10000000000 | random }} + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + parent: + type: organization + id: 636173955921 + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a project + gcp_resourcemanager_project: + name: My Sample Project + id: alextest-{{ 10000000000 | random }} + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + parent: + type: organization + id: 636173955921 + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that project was deleted + gcp_resourcemanager_project_info: + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/cloud-platform + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | map(attribute='name') | select("match", ".*My Sample Project.*") | list | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a project that does not exist + gcp_resourcemanager_project: + name: My Sample Project + id: alextest-{{ 10000000000 | random }} + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + parent: + type: organization + id: 636173955921 + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_resourcemanager_project/tasks/main.yml b/test/integration/targets/gcp_resourcemanager_project/tasks/main.yml index 083660a9d275a5..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_resourcemanager_project/tasks/main.yml +++ b/test/integration/targets/gcp_resourcemanager_project/tasks/main.yml @@ -1,113 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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 project - gcp_resourcemanager_project: - name: My Sample Project - id: alextest-{{ 10000000000 | random }} - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - parent: - type: organization - id: 636173955921 - state: absent -#---------------------------------------------------------- -- name: create a project - gcp_resourcemanager_project: - name: My Sample Project - id: alextest-{{ 10000000000 | random }} - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - parent: - type: organization - id: 636173955921 - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that project was created - gcp_resourcemanager_project_info: - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/cloud-platform - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | map(attribute='name') | select("match", ".*My Sample Project.*") | list | length == 1 -# ---------------------------------------------------------------------------- -- name: create a project that already exists - gcp_resourcemanager_project: - name: My Sample Project - id: alextest-{{ 10000000000 | random }} - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - parent: - type: organization - id: 636173955921 - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a project - gcp_resourcemanager_project: - name: My Sample Project - id: alextest-{{ 10000000000 | random }} - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - parent: - type: organization - id: 636173955921 - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that project was deleted - gcp_resourcemanager_project_info: - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/cloud-platform - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | map(attribute='name') | select("match", ".*My Sample Project.*") | list | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a project that does not exist - gcp_resourcemanager_project: - name: My Sample Project - id: alextest-{{ 10000000000 | random }} - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - parent: - type: organization - id: 636173955921 - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_sourcerepo_repository/tasks/autogen.yml b/test/integration/targets/gcp_sourcerepo_repository/tasks/autogen.yml new file mode 100644 index 00000000000000..5ae6e3494512cf --- /dev/null +++ b/test/integration/targets/gcp_sourcerepo_repository/tasks/autogen.yml @@ -0,0 +1,98 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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 repository + gcp_sourcerepo_repository: + name: "{{ resource_name }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a repository + gcp_sourcerepo_repository: + name: "{{ resource_name }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that repository was created + gcp_sourcerepo_repository_info: + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/cloud-platform + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 1 +# ---------------------------------------------------------------------------- +- name: create a repository that already exists + gcp_sourcerepo_repository: + name: "{{ resource_name }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a repository + gcp_sourcerepo_repository: + name: "{{ resource_name }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that repository was deleted + gcp_sourcerepo_repository_info: + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/cloud-platform + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a repository that does not exist + gcp_sourcerepo_repository: + name: "{{ resource_name }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_sourcerepo_repository/tasks/main.yml b/test/integration/targets/gcp_sourcerepo_repository/tasks/main.yml index 5ae6e3494512cf..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_sourcerepo_repository/tasks/main.yml +++ b/test/integration/targets/gcp_sourcerepo_repository/tasks/main.yml @@ -1,98 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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 repository - gcp_sourcerepo_repository: - name: "{{ resource_name }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a repository - gcp_sourcerepo_repository: - name: "{{ resource_name }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that repository was created - gcp_sourcerepo_repository_info: - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/cloud-platform - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 1 -# ---------------------------------------------------------------------------- -- name: create a repository that already exists - gcp_sourcerepo_repository: - name: "{{ resource_name }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a repository - gcp_sourcerepo_repository: - name: "{{ resource_name }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that repository was deleted - gcp_sourcerepo_repository_info: - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/cloud-platform - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a repository that does not exist - gcp_sourcerepo_repository: - name: "{{ resource_name }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_spanner_database/tasks/autogen.yml b/test/integration/targets/gcp_spanner_database/tasks/autogen.yml new file mode 100644 index 00000000000000..3fda4e4397a40e --- /dev/null +++ b/test/integration/targets/gcp_spanner_database/tasks/autogen.yml @@ -0,0 +1,135 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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: create a instance + gcp_spanner_instance: + name: instance-database + display_name: My Spanner Instance + node_count: 2 + labels: + cost_center: ti-1700004 + config: regional-us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: instance +- name: delete a database + gcp_spanner_database: + name: webstore + instance: "{{ instance }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a database + gcp_spanner_database: + name: webstore + instance: "{{ instance }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that database was created + gcp_spanner_database_info: + instance: "{{ instance }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/spanner.admin + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | map(attribute='name') | select("match", ".*webstore.*") | list | length == 1 +# ---------------------------------------------------------------------------- +- name: create a database that already exists + gcp_spanner_database: + name: webstore + instance: "{{ instance }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a database + gcp_spanner_database: + name: webstore + instance: "{{ instance }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that database was deleted + gcp_spanner_database_info: + instance: "{{ instance }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/spanner.admin + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | map(attribute='name') | select("match", ".*webstore.*") | list | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a database that does not exist + gcp_spanner_database: + name: webstore + instance: "{{ instance }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a instance + gcp_spanner_instance: + name: instance-database + display_name: My Spanner Instance + node_count: 2 + labels: + cost_center: ti-1700004 + config: regional-us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: instance + ignore_errors: true diff --git a/test/integration/targets/gcp_spanner_database/tasks/main.yml b/test/integration/targets/gcp_spanner_database/tasks/main.yml index 3fda4e4397a40e..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_spanner_database/tasks/main.yml +++ b/test/integration/targets/gcp_spanner_database/tasks/main.yml @@ -1,135 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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: create a instance - gcp_spanner_instance: - name: instance-database - display_name: My Spanner Instance - node_count: 2 - labels: - cost_center: ti-1700004 - config: regional-us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: instance -- name: delete a database - gcp_spanner_database: - name: webstore - instance: "{{ instance }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a database - gcp_spanner_database: - name: webstore - instance: "{{ instance }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that database was created - gcp_spanner_database_info: - instance: "{{ instance }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/spanner.admin - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | map(attribute='name') | select("match", ".*webstore.*") | list | length == 1 -# ---------------------------------------------------------------------------- -- name: create a database that already exists - gcp_spanner_database: - name: webstore - instance: "{{ instance }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a database - gcp_spanner_database: - name: webstore - instance: "{{ instance }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that database was deleted - gcp_spanner_database_info: - instance: "{{ instance }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/spanner.admin - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | map(attribute='name') | select("match", ".*webstore.*") | list | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a database that does not exist - gcp_spanner_database: - name: webstore - instance: "{{ instance }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a instance - gcp_spanner_instance: - name: instance-database - display_name: My Spanner Instance - node_count: 2 - labels: - cost_center: ti-1700004 - config: regional-us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: instance - ignore_errors: true +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_spanner_instance/tasks/autogen.yml b/test/integration/targets/gcp_spanner_instance/tasks/autogen.yml new file mode 100644 index 00000000000000..8fb40459a80431 --- /dev/null +++ b/test/integration/targets/gcp_spanner_instance/tasks/autogen.yml @@ -0,0 +1,123 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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 instance + gcp_spanner_instance: + name: testinstance + display_name: My Spanner Instance + node_count: 2 + labels: + cost_center: ti-1700004 + config: regional-us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a instance + gcp_spanner_instance: + name: testinstance + display_name: My Spanner Instance + node_count: 2 + labels: + cost_center: ti-1700004 + config: regional-us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that instance was created + gcp_spanner_instance_info: + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/spanner.admin + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | map(attribute='name') | select("match", ".*testinstance.*") | list | length == 1 +# ---------------------------------------------------------------------------- +- name: create a instance that already exists + gcp_spanner_instance: + name: testinstance + display_name: My Spanner Instance + node_count: 2 + labels: + cost_center: ti-1700004 + config: regional-us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a instance + gcp_spanner_instance: + name: testinstance + display_name: My Spanner Instance + node_count: 2 + labels: + cost_center: ti-1700004 + config: regional-us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that instance was deleted + gcp_spanner_instance_info: + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/spanner.admin + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | map(attribute='name') | select("match", ".*testinstance.*") | list | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a instance that does not exist + gcp_spanner_instance: + name: testinstance + display_name: My Spanner Instance + node_count: 2 + labels: + cost_center: ti-1700004 + config: regional-us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_spanner_instance/tasks/main.yml b/test/integration/targets/gcp_spanner_instance/tasks/main.yml index 8fb40459a80431..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_spanner_instance/tasks/main.yml +++ b/test/integration/targets/gcp_spanner_instance/tasks/main.yml @@ -1,123 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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 instance - gcp_spanner_instance: - name: testinstance - display_name: My Spanner Instance - node_count: 2 - labels: - cost_center: ti-1700004 - config: regional-us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a instance - gcp_spanner_instance: - name: testinstance - display_name: My Spanner Instance - node_count: 2 - labels: - cost_center: ti-1700004 - config: regional-us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that instance was created - gcp_spanner_instance_info: - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/spanner.admin - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | map(attribute='name') | select("match", ".*testinstance.*") | list | length == 1 -# ---------------------------------------------------------------------------- -- name: create a instance that already exists - gcp_spanner_instance: - name: testinstance - display_name: My Spanner Instance - node_count: 2 - labels: - cost_center: ti-1700004 - config: regional-us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a instance - gcp_spanner_instance: - name: testinstance - display_name: My Spanner Instance - node_count: 2 - labels: - cost_center: ti-1700004 - config: regional-us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that instance was deleted - gcp_spanner_instance_info: - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/spanner.admin - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | map(attribute='name') | select("match", ".*testinstance.*") | list | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a instance that does not exist - gcp_spanner_instance: - name: testinstance - display_name: My Spanner Instance - node_count: 2 - labels: - cost_center: ti-1700004 - config: regional-us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_sql_database/tasks/autogen.yml b/test/integration/targets/gcp_sql_database/tasks/autogen.yml new file mode 100644 index 00000000000000..ebe9cbdc06d9af --- /dev/null +++ b/test/integration/targets/gcp_sql_database/tasks/autogen.yml @@ -0,0 +1,144 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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: create a instance + gcp_sql_instance: + name: "{{resource_name}}-3" + settings: + ip_configuration: + authorized_networks: + - name: google dns server + value: 8.8.8.8/32 + tier: db-n1-standard-1 + region: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: instance +- name: delete a database + gcp_sql_database: + name: "{{ resource_name }}" + charset: utf8 + instance: "{{ instance.name }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a database + gcp_sql_database: + name: "{{ resource_name }}" + charset: utf8 + instance: "{{ instance.name }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that database was created + gcp_sql_database_info: + instance: "{{ instance.name }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/sqlservice.admin + register: results +- name: verify that command succeeded + assert: + that: + - "\"{{resource_name}}\" in \"{{ results['resources'] | map(attribute='name') | list }}\"" +# ---------------------------------------------------------------------------- +- name: create a database that already exists + gcp_sql_database: + name: "{{ resource_name }}" + charset: utf8 + instance: "{{ instance.name }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a database + gcp_sql_database: + name: "{{ resource_name }}" + charset: utf8 + instance: "{{ instance.name }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that database was deleted + gcp_sql_database_info: + instance: "{{ instance.name }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/sqlservice.admin + register: results +- name: verify that command succeeded + assert: + that: + - "\"{{resource_name}}\" not in \"{{ results['resources'] | map(attribute='name') | list }}\"" +# ---------------------------------------------------------------------------- +- name: delete a database that does not exist + gcp_sql_database: + name: "{{ resource_name }}" + charset: utf8 + instance: "{{ instance.name }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a instance + gcp_sql_instance: + name: "{{resource_name}}-3" + settings: + ip_configuration: + authorized_networks: + - name: google dns server + value: 8.8.8.8/32 + tier: db-n1-standard-1 + region: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: instance + ignore_errors: true diff --git a/test/integration/targets/gcp_sql_database/tasks/main.yml b/test/integration/targets/gcp_sql_database/tasks/main.yml index ebe9cbdc06d9af..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_sql_database/tasks/main.yml +++ b/test/integration/targets/gcp_sql_database/tasks/main.yml @@ -1,144 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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: create a instance - gcp_sql_instance: - name: "{{resource_name}}-3" - settings: - ip_configuration: - authorized_networks: - - name: google dns server - value: 8.8.8.8/32 - tier: db-n1-standard-1 - region: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: instance -- name: delete a database - gcp_sql_database: - name: "{{ resource_name }}" - charset: utf8 - instance: "{{ instance.name }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a database - gcp_sql_database: - name: "{{ resource_name }}" - charset: utf8 - instance: "{{ instance.name }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that database was created - gcp_sql_database_info: - instance: "{{ instance.name }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/sqlservice.admin - register: results -- name: verify that command succeeded - assert: - that: - - "\"{{resource_name}}\" in \"{{ results['resources'] | map(attribute='name') | list }}\"" -# ---------------------------------------------------------------------------- -- name: create a database that already exists - gcp_sql_database: - name: "{{ resource_name }}" - charset: utf8 - instance: "{{ instance.name }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a database - gcp_sql_database: - name: "{{ resource_name }}" - charset: utf8 - instance: "{{ instance.name }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that database was deleted - gcp_sql_database_info: - instance: "{{ instance.name }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/sqlservice.admin - register: results -- name: verify that command succeeded - assert: - that: - - "\"{{resource_name}}\" not in \"{{ results['resources'] | map(attribute='name') | list }}\"" -# ---------------------------------------------------------------------------- -- name: delete a database that does not exist - gcp_sql_database: - name: "{{ resource_name }}" - charset: utf8 - instance: "{{ instance.name }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a instance - gcp_sql_instance: - name: "{{resource_name}}-3" - settings: - ip_configuration: - authorized_networks: - - name: google dns server - value: 8.8.8.8/32 - tier: db-n1-standard-1 - region: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: instance - ignore_errors: true +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_sql_instance/tasks/autogen.yml b/test/integration/targets/gcp_sql_instance/tasks/autogen.yml new file mode 100644 index 00000000000000..1ddcda92ad862e --- /dev/null +++ b/test/integration/targets/gcp_sql_instance/tasks/autogen.yml @@ -0,0 +1,133 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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 instance + gcp_sql_instance: + name: "{{resource_name}}-2" + settings: + ip_configuration: + authorized_networks: + - name: google dns server + value: 8.8.8.8/32 + tier: db-n1-standard-1 + region: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a instance + gcp_sql_instance: + name: "{{resource_name}}-2" + settings: + ip_configuration: + authorized_networks: + - name: google dns server + value: 8.8.8.8/32 + tier: db-n1-standard-1 + region: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that instance was created + gcp_sql_instance_info: + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/sqlservice.admin + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | map(attribute='name') | select("match", ".*{{resource_name}}-2.*") | list | length == 1 +# ---------------------------------------------------------------------------- +- name: create a instance that already exists + gcp_sql_instance: + name: "{{resource_name}}-2" + settings: + ip_configuration: + authorized_networks: + - name: google dns server + value: 8.8.8.8/32 + tier: db-n1-standard-1 + region: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a instance + gcp_sql_instance: + name: "{{resource_name}}-2" + settings: + ip_configuration: + authorized_networks: + - name: google dns server + value: 8.8.8.8/32 + tier: db-n1-standard-1 + region: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that instance was deleted + gcp_sql_instance_info: + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/sqlservice.admin + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | map(attribute='name') | select("match", ".*{{resource_name}}-2.*") | list | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a instance that does not exist + gcp_sql_instance: + name: "{{resource_name}}-2" + settings: + ip_configuration: + authorized_networks: + - name: google dns server + value: 8.8.8.8/32 + tier: db-n1-standard-1 + region: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_sql_instance/tasks/main.yml b/test/integration/targets/gcp_sql_instance/tasks/main.yml index 1ddcda92ad862e..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_sql_instance/tasks/main.yml +++ b/test/integration/targets/gcp_sql_instance/tasks/main.yml @@ -1,133 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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 instance - gcp_sql_instance: - name: "{{resource_name}}-2" - settings: - ip_configuration: - authorized_networks: - - name: google dns server - value: 8.8.8.8/32 - tier: db-n1-standard-1 - region: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a instance - gcp_sql_instance: - name: "{{resource_name}}-2" - settings: - ip_configuration: - authorized_networks: - - name: google dns server - value: 8.8.8.8/32 - tier: db-n1-standard-1 - region: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that instance was created - gcp_sql_instance_info: - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/sqlservice.admin - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | map(attribute='name') | select("match", ".*{{resource_name}}-2.*") | list | length == 1 -# ---------------------------------------------------------------------------- -- name: create a instance that already exists - gcp_sql_instance: - name: "{{resource_name}}-2" - settings: - ip_configuration: - authorized_networks: - - name: google dns server - value: 8.8.8.8/32 - tier: db-n1-standard-1 - region: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a instance - gcp_sql_instance: - name: "{{resource_name}}-2" - settings: - ip_configuration: - authorized_networks: - - name: google dns server - value: 8.8.8.8/32 - tier: db-n1-standard-1 - region: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that instance was deleted - gcp_sql_instance_info: - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/sqlservice.admin - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | map(attribute='name') | select("match", ".*{{resource_name}}-2.*") | list | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a instance that does not exist - gcp_sql_instance: - name: "{{resource_name}}-2" - settings: - ip_configuration: - authorized_networks: - - name: google dns server - value: 8.8.8.8/32 - tier: db-n1-standard-1 - region: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_sql_user/tasks/autogen.yml b/test/integration/targets/gcp_sql_user/tasks/autogen.yml new file mode 100644 index 00000000000000..d7f6d09daf3885 --- /dev/null +++ b/test/integration/targets/gcp_sql_user/tasks/autogen.yml @@ -0,0 +1,149 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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: create a instance + gcp_sql_instance: + name: "{{resource_name}}-1" + settings: + ip_configuration: + authorized_networks: + - name: google dns server + value: 8.8.8.8/32 + tier: db-n1-standard-1 + region: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: instance +- name: delete a user + gcp_sql_user: + name: test-user + host: 10.1.2.3 + password: secret-password + instance: "{{ instance }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a user + gcp_sql_user: + name: test-user + host: 10.1.2.3 + password: secret-password + instance: "{{ instance }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that user was created + gcp_sql_user_info: + instance: "{{ instance }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/sqlservice.admin + register: results +- name: verify that command succeeded + assert: + that: + - "'test-user' in \"{{ results['resources'] | map(attribute='name') | list }}\"" +# ---------------------------------------------------------------------------- +- name: create a user that already exists + gcp_sql_user: + name: test-user + host: 10.1.2.3 + password: secret-password + instance: "{{ instance }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a user + gcp_sql_user: + name: test-user + host: 10.1.2.3 + password: secret-password + instance: "{{ instance }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that user was deleted + gcp_sql_user_info: + instance: "{{ instance }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/sqlservice.admin + register: results +- name: verify that command succeeded + assert: + that: + - "'test-user' not in \"{{ results['resources'] | map(attribute='name') | list }}\"" +# ---------------------------------------------------------------------------- +- name: delete a user that does not exist + gcp_sql_user: + name: test-user + host: 10.1.2.3 + password: secret-password + instance: "{{ instance }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a instance + gcp_sql_instance: + name: "{{resource_name}}-1" + settings: + ip_configuration: + authorized_networks: + - name: google dns server + value: 8.8.8.8/32 + tier: db-n1-standard-1 + region: us-central1 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: instance + ignore_errors: true diff --git a/test/integration/targets/gcp_sql_user/tasks/main.yml b/test/integration/targets/gcp_sql_user/tasks/main.yml index d7f6d09daf3885..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_sql_user/tasks/main.yml +++ b/test/integration/targets/gcp_sql_user/tasks/main.yml @@ -1,149 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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: create a instance - gcp_sql_instance: - name: "{{resource_name}}-1" - settings: - ip_configuration: - authorized_networks: - - name: google dns server - value: 8.8.8.8/32 - tier: db-n1-standard-1 - region: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: instance -- name: delete a user - gcp_sql_user: - name: test-user - host: 10.1.2.3 - password: secret-password - instance: "{{ instance }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a user - gcp_sql_user: - name: test-user - host: 10.1.2.3 - password: secret-password - instance: "{{ instance }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that user was created - gcp_sql_user_info: - instance: "{{ instance }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/sqlservice.admin - register: results -- name: verify that command succeeded - assert: - that: - - "'test-user' in \"{{ results['resources'] | map(attribute='name') | list }}\"" -# ---------------------------------------------------------------------------- -- name: create a user that already exists - gcp_sql_user: - name: test-user - host: 10.1.2.3 - password: secret-password - instance: "{{ instance }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a user - gcp_sql_user: - name: test-user - host: 10.1.2.3 - password: secret-password - instance: "{{ instance }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that user was deleted - gcp_sql_user_info: - instance: "{{ instance }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/sqlservice.admin - register: results -- name: verify that command succeeded - assert: - that: - - "'test-user' not in \"{{ results['resources'] | map(attribute='name') | list }}\"" -# ---------------------------------------------------------------------------- -- name: delete a user that does not exist - gcp_sql_user: - name: test-user - host: 10.1.2.3 - password: secret-password - instance: "{{ instance }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a instance - gcp_sql_instance: - name: "{{resource_name}}-1" - settings: - ip_configuration: - authorized_networks: - - name: google dns server - value: 8.8.8.8/32 - tier: db-n1-standard-1 - region: us-central1 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: instance - ignore_errors: true +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_storage_bucket/tasks/autogen.yml b/test/integration/targets/gcp_storage_bucket/tasks/autogen.yml new file mode 100644 index 00000000000000..d49ec899c1d076 --- /dev/null +++ b/test/integration/targets/gcp_storage_bucket/tasks/autogen.yml @@ -0,0 +1,74 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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 bucket + gcp_storage_bucket: + name: ansible-storage-module + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a bucket + gcp_storage_bucket: + name: ansible-storage-module + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +# ---------------------------------------------------------------------------- +- name: create a bucket that already exists + gcp_storage_bucket: + name: ansible-storage-module + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a bucket + gcp_storage_bucket: + name: ansible-storage-module + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +# ---------------------------------------------------------------------------- +- name: delete a bucket that does not exist + gcp_storage_bucket: + name: ansible-storage-module + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_storage_bucket/tasks/main.yml b/test/integration/targets/gcp_storage_bucket/tasks/main.yml index d49ec899c1d076..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_storage_bucket/tasks/main.yml +++ b/test/integration/targets/gcp_storage_bucket/tasks/main.yml @@ -1,74 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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 bucket - gcp_storage_bucket: - name: ansible-storage-module - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a bucket - gcp_storage_bucket: - name: ansible-storage-module - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -# ---------------------------------------------------------------------------- -- name: create a bucket that already exists - gcp_storage_bucket: - name: ansible-storage-module - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a bucket - gcp_storage_bucket: - name: ansible-storage-module - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -# ---------------------------------------------------------------------------- -- name: delete a bucket that does not exist - gcp_storage_bucket: - name: ansible-storage-module - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_storage_bucket_access_control/tasks/autogen.yml b/test/integration/targets/gcp_storage_bucket_access_control/tasks/autogen.yml new file mode 100644 index 00000000000000..5a78a87e7a06a8 --- /dev/null +++ b/test/integration/targets/gcp_storage_bucket_access_control/tasks/autogen.yml @@ -0,0 +1,104 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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: create a bucket + gcp_storage_bucket: + name: "{{ resource_name }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: bucket +- name: delete a bucket access control + gcp_storage_bucket_access_control: + bucket: "{{ bucket }}" + entity: user-alexstephen@google.com + role: WRITER + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a bucket access control + gcp_storage_bucket_access_control: + bucket: "{{ bucket }}" + entity: user-alexstephen@google.com + role: WRITER + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +# ---------------------------------------------------------------------------- +- name: create a bucket access control that already exists + gcp_storage_bucket_access_control: + bucket: "{{ bucket }}" + entity: user-alexstephen@google.com + role: WRITER + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a bucket access control + gcp_storage_bucket_access_control: + bucket: "{{ bucket }}" + entity: user-alexstephen@google.com + role: WRITER + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +# ---------------------------------------------------------------------------- +- name: delete a bucket access control that does not exist + gcp_storage_bucket_access_control: + bucket: "{{ bucket }}" + entity: user-alexstephen@google.com + role: WRITER + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#--------------------------------------------------------- +# Post-test teardown +# If errors happen, don't crash the playbook! +- name: delete a bucket + gcp_storage_bucket: + name: "{{ resource_name }}" + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: bucket + ignore_errors: true diff --git a/test/integration/targets/gcp_storage_bucket_access_control/tasks/main.yml b/test/integration/targets/gcp_storage_bucket_access_control/tasks/main.yml index 5a78a87e7a06a8..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_storage_bucket_access_control/tasks/main.yml +++ b/test/integration/targets/gcp_storage_bucket_access_control/tasks/main.yml @@ -1,104 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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: create a bucket - gcp_storage_bucket: - name: "{{ resource_name }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: bucket -- name: delete a bucket access control - gcp_storage_bucket_access_control: - bucket: "{{ bucket }}" - entity: user-alexstephen@google.com - role: WRITER - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a bucket access control - gcp_storage_bucket_access_control: - bucket: "{{ bucket }}" - entity: user-alexstephen@google.com - role: WRITER - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -# ---------------------------------------------------------------------------- -- name: create a bucket access control that already exists - gcp_storage_bucket_access_control: - bucket: "{{ bucket }}" - entity: user-alexstephen@google.com - role: WRITER - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a bucket access control - gcp_storage_bucket_access_control: - bucket: "{{ bucket }}" - entity: user-alexstephen@google.com - role: WRITER - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -# ---------------------------------------------------------------------------- -- name: delete a bucket access control that does not exist - gcp_storage_bucket_access_control: - bucket: "{{ bucket }}" - entity: user-alexstephen@google.com - role: WRITER - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#--------------------------------------------------------- -# Post-test teardown -# If errors happen, don't crash the playbook! -- name: delete a bucket - gcp_storage_bucket: - name: "{{ resource_name }}" - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: bucket - ignore_errors: true +- include_tasks: autogen.yml diff --git a/test/integration/targets/gcp_tpu_node/tasks/autogen.yml b/test/integration/targets/gcp_tpu_node/tasks/autogen.yml new file mode 100644 index 00000000000000..ed4803d422c638 --- /dev/null +++ b/test/integration/targets/gcp_tpu_node/tasks/autogen.yml @@ -0,0 +1,120 @@ +--- +# ---------------------------------------------------------------------------- +# +# *** 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 node + gcp_tpu_node: + name: "{{ resource_name }}" + zone: us-central1-b + accelerator_type: v3-8 + tensorflow_version: '1.11' + cidr_block: 10.2.0.0/29 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent +#---------------------------------------------------------- +- name: create a node + gcp_tpu_node: + name: "{{ resource_name }}" + zone: us-central1-b + accelerator_type: v3-8 + tensorflow_version: '1.11' + cidr_block: 10.2.0.0/29 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that node was created + gcp_tpu_node_info: + zone: us-central1-b + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/cloud-platform + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 1 +# ---------------------------------------------------------------------------- +- name: create a node that already exists + gcp_tpu_node: + name: "{{ resource_name }}" + zone: us-central1-b + accelerator_type: v3-8 + tensorflow_version: '1.11' + cidr_block: 10.2.0.0/29 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: present + register: result +- name: assert changed is false + assert: + that: + - result.changed == false +#---------------------------------------------------------- +- name: delete a node + gcp_tpu_node: + name: "{{ resource_name }}" + zone: us-central1-b + accelerator_type: v3-8 + tensorflow_version: '1.11' + cidr_block: 10.2.0.0/29 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is true + assert: + that: + - result.changed == true +- name: verify that node was deleted + gcp_tpu_node_info: + zone: us-central1-b + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + scopes: + - https://www.googleapis.com/auth/cloud-platform + register: results +- name: verify that command succeeded + assert: + that: + - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 0 +# ---------------------------------------------------------------------------- +- name: delete a node that does not exist + gcp_tpu_node: + name: "{{ resource_name }}" + zone: us-central1-b + accelerator_type: v3-8 + tensorflow_version: '1.11' + cidr_block: 10.2.0.0/29 + project: "{{ gcp_project }}" + auth_kind: "{{ gcp_cred_kind }}" + service_account_file: "{{ gcp_cred_file }}" + state: absent + register: result +- name: assert changed is false + assert: + that: + - result.changed == false diff --git a/test/integration/targets/gcp_tpu_node/tasks/main.yml b/test/integration/targets/gcp_tpu_node/tasks/main.yml index ed4803d422c638..45d6e49178c12c 100644 --- a/test/integration/targets/gcp_tpu_node/tasks/main.yml +++ b/test/integration/targets/gcp_tpu_node/tasks/main.yml @@ -1,120 +1,2 @@ --- -# ---------------------------------------------------------------------------- -# -# *** 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 node - gcp_tpu_node: - name: "{{ resource_name }}" - zone: us-central1-b - accelerator_type: v3-8 - tensorflow_version: '1.11' - cidr_block: 10.2.0.0/29 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent -#---------------------------------------------------------- -- name: create a node - gcp_tpu_node: - name: "{{ resource_name }}" - zone: us-central1-b - accelerator_type: v3-8 - tensorflow_version: '1.11' - cidr_block: 10.2.0.0/29 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that node was created - gcp_tpu_node_info: - zone: us-central1-b - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/cloud-platform - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 1 -# ---------------------------------------------------------------------------- -- name: create a node that already exists - gcp_tpu_node: - name: "{{ resource_name }}" - zone: us-central1-b - accelerator_type: v3-8 - tensorflow_version: '1.11' - cidr_block: 10.2.0.0/29 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: present - register: result -- name: assert changed is false - assert: - that: - - result.changed == false -#---------------------------------------------------------- -- name: delete a node - gcp_tpu_node: - name: "{{ resource_name }}" - zone: us-central1-b - accelerator_type: v3-8 - tensorflow_version: '1.11' - cidr_block: 10.2.0.0/29 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is true - assert: - that: - - result.changed == true -- name: verify that node was deleted - gcp_tpu_node_info: - zone: us-central1-b - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - scopes: - - https://www.googleapis.com/auth/cloud-platform - register: results -- name: verify that command succeeded - assert: - that: - - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 0 -# ---------------------------------------------------------------------------- -- name: delete a node that does not exist - gcp_tpu_node: - name: "{{ resource_name }}" - zone: us-central1-b - accelerator_type: v3-8 - tensorflow_version: '1.11' - cidr_block: 10.2.0.0/29 - project: "{{ gcp_project }}" - auth_kind: "{{ gcp_cred_kind }}" - service_account_file: "{{ gcp_cred_file }}" - state: absent - register: result -- name: assert changed is false - assert: - that: - - result.changed == false +- include_tasks: autogen.yml