Bug fixes for GCP modules (#58900)
This commit is contained in:
parent
70db07fa82
commit
5cd0e2f19f
11 changed files with 28 additions and 31 deletions
|
@ -165,6 +165,11 @@ class GcpSession(object):
|
||||||
self.module.fail_json(msg="Credential type '%s' not implemented" % cred_type)
|
self.module.fail_json(msg="Credential type '%s' not implemented" % cred_type)
|
||||||
|
|
||||||
def _headers(self):
|
def _headers(self):
|
||||||
|
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 {
|
return {
|
||||||
'User-Agent': "Google-Ansible-MM-{0}".format(self.product)
|
'User-Agent': "Google-Ansible-MM-{0}".format(self.product)
|
||||||
}
|
}
|
||||||
|
@ -189,7 +194,7 @@ class GcpModule(AnsibleModule):
|
||||||
type='str',
|
type='str',
|
||||||
fallback=(env_fallback, ['GCP_PROJECT'])),
|
fallback=(env_fallback, ['GCP_PROJECT'])),
|
||||||
auth_kind=dict(
|
auth_kind=dict(
|
||||||
required=False,
|
required=True,
|
||||||
fallback=(env_fallback, ['GCP_AUTH_KIND']),
|
fallback=(env_fallback, ['GCP_AUTH_KIND']),
|
||||||
choices=['machineaccount', 'serviceaccount', 'application'],
|
choices=['machineaccount', 'serviceaccount', 'application'],
|
||||||
type='str'),
|
type='str'),
|
||||||
|
@ -208,7 +213,11 @@ class GcpModule(AnsibleModule):
|
||||||
scopes=dict(
|
scopes=dict(
|
||||||
required=False,
|
required=False,
|
||||||
fallback=(env_fallback, ['GCP_SCOPES']),
|
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:
|
description:
|
||||||
- Array of scopes to be used.
|
- Array of scopes to be used.
|
||||||
type: list
|
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:
|
notes:
|
||||||
- For authentication, you can set service_account_file using the
|
- for authentication, you can set service_account_file using the
|
||||||
C(GCP_SERVICE_ACCOUNT_FILE) env variable.
|
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
|
- For authentication, you can set service_account_email using the
|
||||||
C(GCP_SERVICE_ACCOUNT_EMAIL) env variable.
|
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
|
- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env
|
||||||
variable.
|
variable.
|
||||||
- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
|
- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
- name: verify that command succeeded
|
- name: verify that command succeeded
|
||||||
assert:
|
assert:
|
||||||
that:
|
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
|
- name: create a dataset that already exists
|
||||||
gcp_bigquery_dataset:
|
gcp_bigquery_dataset:
|
||||||
|
@ -81,7 +81,6 @@
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- result.changed == true
|
- result.changed == true
|
||||||
- result.has_key('kind') == False
|
|
||||||
- name: verify that dataset was deleted
|
- name: verify that dataset was deleted
|
||||||
gcp_bigquery_dataset_facts:
|
gcp_bigquery_dataset_facts:
|
||||||
project: "{{ gcp_project }}"
|
project: "{{ gcp_project }}"
|
||||||
|
@ -93,7 +92,7 @@
|
||||||
- name: verify that command succeeded
|
- name: verify that command succeeded
|
||||||
assert:
|
assert:
|
||||||
that:
|
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
|
- name: delete a dataset that does not exist
|
||||||
gcp_bigquery_dataset:
|
gcp_bigquery_dataset:
|
||||||
|
@ -109,4 +108,3 @@
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- result.changed == false
|
- result.changed == false
|
||||||
- result.has_key('kind') == False
|
|
||||||
|
|
|
@ -66,7 +66,7 @@
|
||||||
- name: verify that command succeeded
|
- name: verify that command succeeded
|
||||||
assert:
|
assert:
|
||||||
that:
|
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
|
- name: create a table that already exists
|
||||||
gcp_bigquery_table:
|
gcp_bigquery_table:
|
||||||
|
@ -104,7 +104,6 @@
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- result.changed == true
|
- result.changed == true
|
||||||
- result.has_key('kind') == False
|
|
||||||
- name: verify that table was deleted
|
- name: verify that table was deleted
|
||||||
gcp_bigquery_table_facts:
|
gcp_bigquery_table_facts:
|
||||||
dataset: example_dataset
|
dataset: example_dataset
|
||||||
|
@ -117,7 +116,7 @@
|
||||||
- name: verify that command succeeded
|
- name: verify that command succeeded
|
||||||
assert:
|
assert:
|
||||||
that:
|
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
|
- name: delete a table that does not exist
|
||||||
gcp_bigquery_table:
|
gcp_bigquery_table:
|
||||||
|
@ -136,7 +135,6 @@
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- result.changed == false
|
- result.changed == false
|
||||||
- result.has_key('kind') == False
|
|
||||||
#---------------------------------------------------------
|
#---------------------------------------------------------
|
||||||
# Post-test teardown
|
# Post-test teardown
|
||||||
# If errors happen, don't crash the playbook!
|
# If errors happen, don't crash the playbook!
|
||||||
|
|
|
@ -80,7 +80,6 @@
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- result.changed == true
|
- result.changed == true
|
||||||
- result.has_key('kind') == False
|
|
||||||
- name: verify that address was deleted
|
- name: verify that address was deleted
|
||||||
gcp_compute_address_facts:
|
gcp_compute_address_facts:
|
||||||
filters:
|
filters:
|
||||||
|
@ -110,4 +109,3 @@
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- result.changed == false
|
- result.changed == false
|
||||||
- result.has_key('kind') == False
|
|
||||||
|
|
|
@ -95,7 +95,6 @@
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- result.changed == true
|
- result.changed == true
|
||||||
- result.has_key('kind') == False
|
|
||||||
- name: verify that backend_bucket was deleted
|
- name: verify that backend_bucket was deleted
|
||||||
gcp_compute_backend_bucket_facts:
|
gcp_compute_backend_bucket_facts:
|
||||||
filters:
|
filters:
|
||||||
|
@ -126,7 +125,6 @@
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- result.changed == false
|
- result.changed == false
|
||||||
- result.has_key('kind') == False
|
|
||||||
#---------------------------------------------------------
|
#---------------------------------------------------------
|
||||||
# Post-test teardown
|
# Post-test teardown
|
||||||
# If errors happen, don't crash the playbook!
|
# If errors happen, don't crash the playbook!
|
||||||
|
|
|
@ -116,7 +116,6 @@
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- result.changed == true
|
- result.changed == true
|
||||||
- result.has_key('kind') == False
|
|
||||||
- name: verify that backend_service was deleted
|
- name: verify that backend_service was deleted
|
||||||
gcp_compute_backend_service_facts:
|
gcp_compute_backend_service_facts:
|
||||||
filters:
|
filters:
|
||||||
|
@ -149,7 +148,6 @@
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- result.changed == false
|
- result.changed == false
|
||||||
- result.has_key('kind') == False
|
|
||||||
#---------------------------------------------------------
|
#---------------------------------------------------------
|
||||||
# Post-test teardown
|
# Post-test teardown
|
||||||
# If errors happen, don't crash the playbook!
|
# If errors happen, don't crash the playbook!
|
||||||
|
|
|
@ -92,7 +92,6 @@
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- result.changed == true
|
- result.changed == true
|
||||||
- result.has_key('kind') == False
|
|
||||||
- name: verify that disk was deleted
|
- name: verify that disk was deleted
|
||||||
gcp_compute_disk_facts:
|
gcp_compute_disk_facts:
|
||||||
filters:
|
filters:
|
||||||
|
@ -125,4 +124,3 @@
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- result.changed == false
|
- result.changed == false
|
||||||
- result.has_key('kind') == False
|
|
||||||
|
|
|
@ -111,7 +111,6 @@
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- result.changed == true
|
- result.changed == true
|
||||||
- result.has_key('kind') == False
|
|
||||||
- name: verify that firewall was deleted
|
- name: verify that firewall was deleted
|
||||||
gcp_compute_firewall_facts:
|
gcp_compute_firewall_facts:
|
||||||
filters:
|
filters:
|
||||||
|
@ -148,4 +147,3 @@
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- result.changed == false
|
- result.changed == false
|
||||||
- result.has_key('kind') == False
|
|
||||||
|
|
|
@ -114,7 +114,6 @@
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- result.changed == true
|
- result.changed == true
|
||||||
- result.has_key('kind') == False
|
|
||||||
- name: verify that forwarding_rule was deleted
|
- name: verify that forwarding_rule was deleted
|
||||||
gcp_compute_forwarding_rule_facts:
|
gcp_compute_forwarding_rule_facts:
|
||||||
filters:
|
filters:
|
||||||
|
@ -148,7 +147,6 @@
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- result.changed == false
|
- result.changed == false
|
||||||
- result.has_key('kind') == False
|
|
||||||
#---------------------------------------------------------
|
#---------------------------------------------------------
|
||||||
# Post-test teardown
|
# Post-test teardown
|
||||||
# If errors happen, don't crash the playbook!
|
# If errors happen, don't crash the playbook!
|
||||||
|
|
|
@ -75,7 +75,6 @@
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- result.changed == true
|
- result.changed == true
|
||||||
- result.has_key('kind') == False
|
|
||||||
- name: verify that global_address was deleted
|
- name: verify that global_address was deleted
|
||||||
gcp_compute_global_address_facts:
|
gcp_compute_global_address_facts:
|
||||||
filters:
|
filters:
|
||||||
|
@ -103,4 +102,3 @@
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- result.changed == false
|
- result.changed == false
|
||||||
- result.has_key('kind') == False
|
|
||||||
|
|
Loading…
Reference in a new issue