mirror of
https://github.com/ansible-collections/google.cloud.git
synced 2025-07-24 13:50:30 -07:00
Bug fixes for GCP modules (as of 2019-01-09T15:35:45-08:00) (#50786)
This commit is contained in:
parent
73abff2b5a
commit
899cc535cf
18 changed files with 142 additions and 119 deletions
|
@ -15,7 +15,7 @@
|
|||
# Pre-test setup
|
||||
- name: create a instance
|
||||
gcp_sql_instance:
|
||||
name: "instance-database"
|
||||
name: "{{resource_name}}-3"
|
||||
settings:
|
||||
ip_configuration:
|
||||
authorized_networks:
|
||||
|
@ -54,13 +54,18 @@
|
|||
- result.changed == true
|
||||
- "result.kind == 'sql#database'"
|
||||
- name: verify that database was created
|
||||
shell: |
|
||||
gcloud sql databases describe --instance='instance-database' --project="{{ gcp_project}}" "{{ resource_name }}"
|
||||
gcp_sql_database_facts:
|
||||
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:
|
||||
- results.rc == 0
|
||||
- "\"{{resource_name}}\" in \"{{ results['items'] | map(attribute='name') | list }}\""
|
||||
# ----------------------------------------------------------------------------
|
||||
- name: create a database that already exists
|
||||
gcp_sql_database:
|
||||
|
@ -94,15 +99,18 @@
|
|||
- result.changed == true
|
||||
- result.has_key('kind') == False
|
||||
- name: verify that database was deleted
|
||||
shell: |
|
||||
gcloud sql databases describe --instance='instance-database' --project="{{ gcp_project}}" "{{ resource_name }}"
|
||||
gcp_sql_database_facts:
|
||||
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
|
||||
failed_when: results.rc == 0
|
||||
- name: verify that command succeeded
|
||||
assert:
|
||||
that:
|
||||
- results.rc == 1
|
||||
- "\"(gcloud.sql.databases.describe) HTTPError 404: Not Found\" in results.stderr"
|
||||
- "\"{{resource_name}}\" not in \"{{ results['items'] | map(attribute='name') | list }}\""
|
||||
# ----------------------------------------------------------------------------
|
||||
- name: delete a database that does not exist
|
||||
gcp_sql_database:
|
||||
|
@ -121,9 +129,10 @@
|
|||
- result.has_key('kind') == False
|
||||
#---------------------------------------------------------
|
||||
# Post-test teardown
|
||||
# If errors happen, don't crash the playbook!
|
||||
- name: delete a instance
|
||||
gcp_sql_instance:
|
||||
name: "instance-database"
|
||||
name: "{{resource_name}}-3"
|
||||
settings:
|
||||
ip_configuration:
|
||||
authorized_networks:
|
||||
|
@ -136,3 +145,4 @@
|
|||
service_account_file: "{{ gcp_cred_file }}"
|
||||
state: absent
|
||||
register: instance
|
||||
ignore_errors: true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue