mirror of
https://github.com/ansible-collections/google.cloud.git
synced 2025-06-04 16:09:10 -07:00
GCP MagicModules bug fixes (#47285)
Closes: #46930 #46929 #46928 #46927 #46926 #46925 #46924 #46923 #46922 #46921 #46920 #46919 #46918 #46917 #46916 #46915 #46914 #46913 #46912 #46911 #46910 #46909 #46908 #46907 #46906 #46905 #46903 #46902 #46901 #46900 #46899 #46898 #46897 #46896 #46895 #46894 #46893 #46892 #46891 #46890 #46889 #46888 #46887 #46886 #46885 #46884 #46883 #46882 #46881 #46880 #46879 #46878 #46877 #46876 #46875 #46874 #46873 #46872 #46871 #46870 #46869 #46868 #46867 #46866 #46865 #46864 #46863 #46862 #46861 #46860 #46859 #46858 #46857 #46856 #46855 #46854 #46853 #46852
This commit is contained in:
parent
84f0e2c5b2
commit
5c97cc1da0
78 changed files with 2531 additions and 1137 deletions
|
@ -67,6 +67,11 @@ options:
|
|||
description:
|
||||
- The instance template that is specified for this managed instance group. The group
|
||||
uses this template to create all new instances in the managed instance group.
|
||||
- 'This field represents a link to a InstanceTemplate resource in GCP. It can be specified
|
||||
in two ways. You can add `register: name-of-resource` to a gcp_compute_instance_template
|
||||
task and then set this instance_template field to "{{ name-of-resource }}" Alternatively,
|
||||
you can set this instance_template to a dictionary with the selfLink key where the
|
||||
value is the selfLink of your InstanceTemplate.'
|
||||
required: true
|
||||
name:
|
||||
description:
|
||||
|
@ -156,13 +161,13 @@ EXAMPLES = '''
|
|||
target_size: 3
|
||||
zone: us-west1-a
|
||||
project: "test_project"
|
||||
auth_kind: "service_account"
|
||||
auth_kind: "serviceaccount"
|
||||
service_account_file: "/tmp/auth.pem"
|
||||
state: present
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
base_instance_name:
|
||||
baseInstanceName:
|
||||
description:
|
||||
- The base instance name to use for instances in this group. The value must be 1-58
|
||||
characters long. Instances are named by appending a hyphen and a random four-character
|
||||
|
@ -170,12 +175,12 @@ RETURN = '''
|
|||
- The base instance name must comply with RFC1035.
|
||||
returned: success
|
||||
type: str
|
||||
creation_timestamp:
|
||||
creationTimestamp:
|
||||
description:
|
||||
- The creation timestamp for this managed instance group in RFC3339 text format.
|
||||
returned: success
|
||||
type: str
|
||||
current_actions:
|
||||
currentActions:
|
||||
description:
|
||||
- The list of instance actions and the number of instances in this managed instance
|
||||
group that are scheduled for each of those actions.
|
||||
|
@ -198,7 +203,7 @@ RETURN = '''
|
|||
the creatingWithoutRetries field will be populated.
|
||||
returned: success
|
||||
type: int
|
||||
creating_without_retries:
|
||||
creatingWithoutRetries:
|
||||
description:
|
||||
- The number of instances that the managed instance group will attempt to create.
|
||||
The group attempts to create each instance only once. If the group fails to create
|
||||
|
@ -249,12 +254,12 @@ RETURN = '''
|
|||
- A unique identifier for this resource.
|
||||
returned: success
|
||||
type: int
|
||||
instance_group:
|
||||
instanceGroup:
|
||||
description:
|
||||
- The instance group being managed.
|
||||
returned: success
|
||||
type: dict
|
||||
instance_template:
|
||||
instanceTemplate:
|
||||
description:
|
||||
- The instance template that is specified for this managed instance group. The group
|
||||
uses this template to create all new instances in the managed instance group.
|
||||
|
@ -266,7 +271,7 @@ RETURN = '''
|
|||
comply with RFC1035.
|
||||
returned: success
|
||||
type: str
|
||||
named_ports:
|
||||
namedPorts:
|
||||
description:
|
||||
- Named ports configured for the Instance Groups complementary to this Instance Group
|
||||
Manager.
|
||||
|
@ -289,14 +294,14 @@ RETURN = '''
|
|||
- The region this managed instance group resides (for regional resources).
|
||||
returned: success
|
||||
type: str
|
||||
target_pools:
|
||||
targetPools:
|
||||
description:
|
||||
- TargetPool resources to which instances in the instanceGroup field are added. The
|
||||
target pools automatically apply to all of the instances in the managed instance
|
||||
group.
|
||||
returned: success
|
||||
type: list
|
||||
target_size:
|
||||
targetSize:
|
||||
description:
|
||||
- The target number of running instances for this managed instance group. Deleting
|
||||
or abandoning instances reduces this number. Resizing the group changes this number.
|
||||
|
@ -355,7 +360,8 @@ def main():
|
|||
if fetch:
|
||||
if state == 'present':
|
||||
if is_different(module, fetch):
|
||||
fetch = update(module, self_link(module), kind)
|
||||
update(module, self_link(module), kind)
|
||||
fetch = fetch_resource(module, self_link(module), kind)
|
||||
changed = True
|
||||
else:
|
||||
delete(module, self_link(module), kind)
|
||||
|
@ -407,9 +413,9 @@ def resource_to_request(module):
|
|||
return return_vals
|
||||
|
||||
|
||||
def fetch_resource(module, link, kind):
|
||||
def fetch_resource(module, link, kind, allow_not_found=True):
|
||||
auth = GcpSession(module, 'compute')
|
||||
return return_if_object(module, auth.get(link), kind)
|
||||
return return_if_object(module, auth.get(link), kind, allow_not_found)
|
||||
|
||||
|
||||
def self_link(module):
|
||||
|
@ -420,9 +426,9 @@ def collection(module):
|
|||
return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers".format(**module.params)
|
||||
|
||||
|
||||
def return_if_object(module, response, kind):
|
||||
def return_if_object(module, response, kind, allow_not_found=False):
|
||||
# If not found, return nothing.
|
||||
if response.status_code == 404:
|
||||
if allow_not_found and response.status_code == 404:
|
||||
return None
|
||||
|
||||
# If no content, return nothing.
|
||||
|
@ -437,8 +443,6 @@ def return_if_object(module, response, kind):
|
|||
|
||||
if navigate_hash(result, ['error', 'errors']):
|
||||
module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
|
||||
if result['kind'] != kind:
|
||||
module.fail_json(msg="Incorrect result: {kind}".format(**result))
|
||||
|
||||
return result
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue