Bug fixes for GCP modules (#58900)

pull/59049/head
The Magician 5 years ago committed by ansibot
parent 70db07fa82
commit 5cd0e2f19f

@ -165,9 +165,14 @@ class GcpSession(object):
self.module.fail_json(msg="Credential type '%s' not implemented" % cred_type)
def _headers(self):
return {
'User-Agent': "Google-Ansible-MM-{0}".format(self.product)
}
if self.module.params.get('env_type'):
return {
'User-Agent': "Google-Ansible-MM-{0}-{1}".format(self.product, self.module.params.get('env_type'))
}
else:
return {
'User-Agent': "Google-Ansible-MM-{0}".format(self.product)
}
def _merge_dictionaries(self, a, b):
new = a.copy()
@ -189,7 +194,7 @@ class GcpModule(AnsibleModule):
type='str',
fallback=(env_fallback, ['GCP_PROJECT'])),
auth_kind=dict(
required=False,
required=True,
fallback=(env_fallback, ['GCP_AUTH_KIND']),
choices=['machineaccount', 'serviceaccount', 'application'],
type='str'),
@ -208,7 +213,11 @@ class GcpModule(AnsibleModule):
scopes=dict(
required=False,
fallback=(env_fallback, ['GCP_SCOPES']),
type='list')
type='list'),
env_type=dict(
required=False,
fallback=(env_fallback, ['GCP_ENV_TYPE']),
type='str')
)
)

@ -37,13 +37,19 @@ options:
description:
- Array of scopes to be used.
type: list
env_type:
description:
- Specifies which Ansible environment you're running this module within.
- This should not be set unless you know what you're doing.
- This only alters the User Agent string for any API requests.
type: str
notes:
- For authentication, you can set service_account_file using the
C(GCP_SERVICE_ACCOUNT_FILE) env variable.
- for authentication, you can set service_account_file using the
c(gcp_service_account_file) env variable.
- for authentication, you can set service_account_contents using the
c(GCP_SERVICE_ACCOUNT_CONTENTS) env variable.
- For authentication, you can set service_account_email using the
C(GCP_SERVICE_ACCOUNT_EMAIL) env variable.
- For authentication, you can set service_account_contents using the
C(GCP_SERVICE_ACCOUNT_CONTENTS) env variable.
- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env
variable.
- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.

@ -49,7 +49,7 @@
- name: verify that command succeeded
assert:
that:
- results['resources'] | map(attribute='name') | select("match", ".*my_example_dataset.*") | list | length == 1
- 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:
@ -81,7 +81,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that dataset was deleted
gcp_bigquery_dataset_facts:
project: "{{ gcp_project }}"
@ -93,7 +92,7 @@
- name: verify that command succeeded
assert:
that:
- results['resources'] | map(attribute='name') | select("match", ".*my_example_dataset.*") | list | length == 0
- 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:
@ -109,4 +108,3 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False

@ -66,7 +66,7 @@
- name: verify that command succeeded
assert:
that:
- results['resources'] | map(attribute='name') | select("match", ".*example_table.*") | list | length == 1
- 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:
@ -104,7 +104,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that table was deleted
gcp_bigquery_table_facts:
dataset: example_dataset
@ -117,7 +116,7 @@
- name: verify that command succeeded
assert:
that:
- results['resources'] | map(attribute='name') | select("match", ".*example_table.*") | list | length == 0
- 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:
@ -136,7 +135,6 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!

@ -80,7 +80,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that address was deleted
gcp_compute_address_facts:
filters:
@ -110,4 +109,3 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False

@ -95,7 +95,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that backend_bucket was deleted
gcp_compute_backend_bucket_facts:
filters:
@ -126,7 +125,6 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!

@ -116,7 +116,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that backend_service was deleted
gcp_compute_backend_service_facts:
filters:
@ -149,7 +148,6 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!

@ -92,7 +92,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that disk was deleted
gcp_compute_disk_facts:
filters:
@ -125,4 +124,3 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False

@ -111,7 +111,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that firewall was deleted
gcp_compute_firewall_facts:
filters:
@ -148,4 +147,3 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False

@ -114,7 +114,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that forwarding_rule was deleted
gcp_compute_forwarding_rule_facts:
filters:
@ -148,7 +147,6 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!

@ -75,7 +75,6 @@
assert:
that:
- result.changed == true
- result.has_key('kind') == False
- name: verify that global_address was deleted
gcp_compute_global_address_facts:
filters:
@ -103,4 +102,3 @@
assert:
that:
- result.changed == false
- result.has_key('kind') == False

Loading…
Cancel
Save