Skip to content

Commit

Permalink
Bug fixes for GCP modules
Browse files Browse the repository at this point in the history
  • Loading branch information
modular-magician committed Aug 5, 2019
1 parent aecdfd3 commit 8e4574f
Show file tree
Hide file tree
Showing 24 changed files with 20 additions and 33 deletions.
2 changes: 1 addition & 1 deletion lib/ansible/module_utils/gcp_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def _credentials(self):
cred = json.loads(self.module.params.get('service_account_contents'))
except json.decoder.JSONDecodeError as e:
self.module.fail_json(
msg="Unable to decode service_account_contents as JSON : %s" % to_native(e)
msg="Unable to decode service_account_contents as JSON"
)
return service_account.Credentials.from_service_account_info(cred).with_scopes(self.module.params['scopes'])
elif cred_type == 'machineaccount':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: facts
'''

RETURN = '''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: facts
'''

RETURN = '''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: facts
'''

RETURN = '''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: facts
'''

RETURN = '''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: facts
'''

RETURN = '''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: facts
'''

RETURN = '''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: facts
'''

RETURN = '''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: facts
'''

RETURN = '''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: facts
'''

RETURN = '''
Expand Down
14 changes: 14 additions & 0 deletions lib/ansible/modules/cloud/google/gcp_compute_instance_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,12 @@
- 'Some valid choices include: "SCRATCH", "PERSISTENT"'
required: false
type: str
labels:
description:
- Labels to apply to this address. A list of key->value pairs.
required: false
type: dict
version_added: 2.9
machine_type:
description:
- The machine type to use in the VM instance template.
Expand Down Expand Up @@ -673,6 +679,11 @@
the default is PERSISTENT.
returned: success
type: str
labels:
description:
- Labels to apply to this address. A list of key->value pairs.
returned: success
type: dict
machineType:
description:
- The machine type to use in the VM instance template.
Expand Down Expand Up @@ -921,6 +932,7 @@ def main():
type=dict(type='str'),
),
),
labels=dict(type='dict'),
machine_type=dict(required=True, type='str'),
min_cpu_platform=dict(type='str'),
metadata=dict(type='dict'),
Expand Down Expand Up @@ -1190,6 +1202,7 @@ def to_request(self):
u'canIpForward': self.request.get('can_ip_forward'),
u'description': self.request.get('description'),
u'disks': InstanceTemplateDisksArray(self.request.get('disks', []), self.module).to_request(),
u'labels': self.request.get('labels'),
u'machineType': self.request.get('machine_type'),
u'minCpuPlatform': self.request.get('min_cpu_platform'),
u'metadata': self.request.get('metadata'),
Expand All @@ -1207,6 +1220,7 @@ def from_response(self):
u'canIpForward': self.request.get(u'canIpForward'),
u'description': self.request.get(u'description'),
u'disks': InstanceTemplateDisksArray(self.request.get(u'disks', []), self.module).from_response(),
u'labels': self.request.get(u'labels'),
u'machineType': self.request.get(u'machineType'),
u'minCpuPlatform': self.request.get(u'minCpuPlatform'),
u'metadata': self.request.get(u'metadata'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: facts
'''

RETURN = '''
Expand Down Expand Up @@ -258,6 +257,11 @@
specified, the default is PERSISTENT.
returned: success
type: str
labels:
description:
- Labels to apply to this address. A list of key->value pairs.
returned: success
type: dict
machineType:
description:
- The machine type to use in the VM instance template.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: facts
'''

RETURN = '''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: facts
'''

RETURN = '''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@
assert:
that:
- result.changed == true
- "result.kind == 'compute#forwardingRule'"
- name: verify that global_forwarding_rule was created
gcp_compute_global_forwarding_rule_facts:
filters:
Expand Down Expand Up @@ -133,7 +132,6 @@
assert:
that:
- result.changed == false
- "result.kind == 'compute#forwardingRule'"
#----------------------------------------------------------
- name: delete a global forwarding rule
gcp_compute_global_forwarding_rule:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
assert:
that:
- result.changed == true
- "result.kind == 'compute#healthCheck'"
- name: verify that health_check was created
gcp_compute_health_check_facts:
filters:
Expand Down Expand Up @@ -85,7 +84,6 @@
assert:
that:
- result.changed == false
- "result.kind == 'compute#healthCheck'"
#----------------------------------------------------------
- name: delete a health check
gcp_compute_health_check:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
assert:
that:
- result.changed == true
- "result.kind == 'compute#httpHealthCheck'"
- name: verify that http_health_check was created
gcp_compute_http_health_check_facts:
filters:
Expand Down Expand Up @@ -73,7 +72,6 @@
assert:
that:
- result.changed == false
- "result.kind == 'compute#httpHealthCheck'"
#----------------------------------------------------------
- name: delete a http health check
gcp_compute_http_health_check:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
assert:
that:
- result.changed == true
- "result.kind == 'compute#httpsHealthCheck'"
- name: verify that https_health_check was created
gcp_compute_https_health_check_facts:
filters:
Expand Down Expand Up @@ -73,7 +72,6 @@
assert:
that:
- result.changed == false
- "result.kind == 'compute#httpsHealthCheck'"
#----------------------------------------------------------
- name: delete a https health check
gcp_compute_https_health_check:
Expand Down
2 changes: 0 additions & 2 deletions test/integration/targets/gcp_compute_image/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
assert:
that:
- result.changed == true
- "result.kind == 'compute#image'"
- name: verify that image was created
gcp_compute_image_facts:
filters:
Expand Down Expand Up @@ -73,7 +72,6 @@
assert:
that:
- result.changed == false
- "result.kind == 'compute#image'"
#----------------------------------------------------------
- name: delete a image
gcp_compute_image:
Expand Down
2 changes: 0 additions & 2 deletions test/integration/targets/gcp_compute_instance/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@
assert:
that:
- result.changed == true
- "result.kind == 'compute#instance'"
- name: verify that instance was created
gcp_compute_instance_facts:
filters:
Expand Down Expand Up @@ -141,7 +140,6 @@
assert:
that:
- result.changed == false
- "result.kind == 'compute#instance'"
#----------------------------------------------------------
- name: delete a instance
gcp_compute_instance:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
assert:
that:
- result.changed == true
- "result.kind == 'compute#instanceGroup'"
- name: verify that instance_group was created
gcp_compute_instance_group_facts:
filters:
Expand Down Expand Up @@ -85,7 +84,6 @@
assert:
that:
- result.changed == false
- "result.kind == 'compute#instanceGroup'"
#----------------------------------------------------------
- name: delete a instance group
gcp_compute_instance_group:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
assert:
that:
- result.changed == true
- "result.kind == 'compute#instanceGroupManager'"
- name: verify that instance_group_manager was created
gcp_compute_instance_group_manager_facts:
filters:
Expand Down Expand Up @@ -112,7 +111,6 @@
assert:
that:
- result.changed == false
- "result.kind == 'compute#instanceGroupManager'"
#----------------------------------------------------------
- name: delete a instance group manager
gcp_compute_instance_group_manager:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
assert:
that:
- result.changed == true
- "result.kind == 'compute#instanceTemplate'"
- name: verify that instance_template was created
gcp_compute_instance_template_facts:
filters:
Expand Down Expand Up @@ -117,7 +116,6 @@
assert:
that:
- result.changed == false
- "result.kind == 'compute#instanceTemplate'"
#----------------------------------------------------------
- name: delete a instance template
gcp_compute_instance_template:
Expand Down
2 changes: 0 additions & 2 deletions test/integration/targets/gcp_compute_network/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
assert:
that:
- result.changed == true
- "result.kind == 'compute#network'"
- name: verify that network was created
gcp_compute_network_facts:
filters:
Expand Down Expand Up @@ -64,7 +63,6 @@
assert:
that:
- result.changed == false
- "result.kind == 'compute#network'"
#----------------------------------------------------------
- name: delete a network
gcp_compute_network:
Expand Down

0 comments on commit 8e4574f

Please sign in to comment.