The Last of the Facts Modules

<!-- This change is generated by MagicModules. -->
/cc @rambleraptor
This commit is contained in:
The Magician 2018-10-16 14:26:12 -07:00 committed by Alex Stephen
commit 748132a695
18 changed files with 1195 additions and 1210 deletions

View file

@ -276,7 +276,7 @@ extends_documentation_fragment: gcp
EXAMPLES = ''' EXAMPLES = '''
- name: create a cluster - name: create a cluster
gcp_container_cluster: gcp_container_cluster:
name: "test_object" name: my-cluster
initial_node_count: 2 initial_node_count: 2
master_auth: master_auth:
username: cluster_admin username: cluster_admin

View file

@ -18,47 +18,43 @@
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
################################################################################ ################################################################################
# Documentation # Documentation
################################################################################ ################################################################################
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'} ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ["preview"],
'supported_by': 'community'}
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
module: gcp_container_cluster_facts module: gcp_container_cluster_facts
description: description:
- Gather facts for GCP Cluster - Gather facts for GCP Cluster
short_description: Gather facts for GCP Cluster short_description: Gather facts for GCP Cluster
version_added: 2.8 version_added: 2.8
author: Google Inc. (@googlecloudplatform) author: Google Inc. (@googlecloudplatform)
requirements: requirements:
- python >= 2.6 - python >= 2.6
- requests >= 2.18.4 - requests >= 2.18.4
- google-auth >= 1.3.0 - google-auth >= 1.3.0
options: options:
location: zone:
description: description:
- The location where the cluster is deployed. - The zone where the cluster is deployed.
required: true required: true
aliases:
- region
- zone
version_added: 2.8
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: " a cluster facts" - name: a cluster facts
gcp_container_cluster_facts: gcp_container_cluster_facts:
location: us-central1-a zone: us-central1-a
project: test_project project: test_project
auth_kind: serviceaccount auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: facts
''' '''
RETURN = ''' RETURN = '''
@ -69,9 +65,9 @@ items:
contains: contains:
name: name:
description: description:
- The name of this cluster. The name must be unique within this project and - The name of this cluster. The name must be unique within this project and zone,
location, and can be up to 40 characters. Must be Lowercase letters, numbers, and can be up to 40 characters. Must be Lowercase letters, numbers, and hyphens
and hyphens only. Must start with a letter. Must end with a number or a letter. only. Must start with a letter. Must end with a number or a letter.
returned: success returned: success
type: str type: str
description: description:
@ -82,22 +78,21 @@ items:
initialNodeCount: initialNodeCount:
description: description:
- The number of nodes to create in this cluster. You must ensure that your Compute - The number of nodes to create in this cluster. You must ensure that your Compute
Engine resource quota is sufficient for this number of instances. You must Engine resource quota is sufficient for this number of instances. You must also
also have available firewall and routes quota. For requests, this field should have available firewall and routes quota. For requests, this field should only be
only be used in lieu of a "nodePool" object, since this configuration (along used in lieu of a "nodePool" object, since this configuration (along with the "nodeConfig")
with the "nodeConfig") will be used to create a "NodePool" object with an will be used to create a "NodePool" object with an auto-generated name. Do not use
auto-generated name. Do not use this and a nodePool at the same time. this and a nodePool at the same time.
returned: success returned: success
type: int type: int
nodeConfig: nodeConfig:
description: description:
- Parameters used in creating the cluster's nodes. - Parameters used in creating the cluster's nodes.
- For requests, this field should only be used in lieu of a "nodePool" object, - For requests, this field should only be used in lieu of a "nodePool" object, since
since this configuration (along with the "initialNodeCount") will be used this configuration (along with the "initialNodeCount") will be used to create a
to create a "NodePool" object with an auto-generated name. Do not use this "NodePool" object with an auto-generated name. Do not use this and a nodePool at
and a nodePool at the same time. For responses, this field will be populated the same time. For responses, this field will be populated with the node configuration
with the node configuration of the first node pool. If unspecified, the defaults of the first node pool. If unspecified, the defaults are used.
are used.
returned: success returned: success
type: complex type: complex
contains: contains:
@ -109,40 +104,39 @@ items:
type: str type: str
diskSizeGb: diskSizeGb:
description: description:
- Size of the disk attached to each node, specified in GB. The smallest - Size of the disk attached to each node, specified in GB. The smallest allowed disk
allowed disk size is 10GB. If unspecified, the default disk size is 100GB. size is 10GB. If unspecified, the default disk size is 100GB.
returned: success returned: success
type: int type: int
oauthScopes: oauthScopes:
description: description:
- The set of Google API scopes to be made available on all of the node VMs - The set of Google API scopes to be made available on all of the node VMs under the
under the "default" service account. "default" service account.
- 'The following scopes are recommended, but not required, and by default - 'The following scopes are recommended, but not required, and by default are not
are not included: U(https://www.googleapis.com/auth/compute) is required included: U(https://www.googleapis.com/auth/compute) is required for mounting persistent
for mounting persistent storage on your nodes.' storage on your nodes.'
- U(https://www.googleapis.com/auth/devstorage.read_only) is required for - U(https://www.googleapis.com/auth/devstorage.read_only) is required for communicating
communicating with gcr.io (the Google Container Registry). with gcr.io (the Google Container Registry).
- If unspecified, no scopes are added, unless Cloud Logging or Cloud Monitoring - If unspecified, no scopes are added, unless Cloud Logging or Cloud Monitoring are
are enabled, in which case their required scopes will be added. enabled, in which case their required scopes will be added.
returned: success returned: success
type: list type: list
serviceAccount: serviceAccount:
description: description:
- The Google Cloud Platform Service Account to be used by the node VMs. - The Google Cloud Platform Service Account to be used by the node VMs. If no Service
If no Service Account is specified, the "default" service account is used. Account is specified, the "default" service account is used.
returned: success returned: success
type: str type: str
metadata: metadata:
description: description:
- The metadata key/value pairs assigned to instances in the cluster. - The metadata key/value pairs assigned to instances in the cluster.
- 'Keys must conform to the regexp [a-zA-Z0-9-_]+ and be less than 128 bytes - 'Keys must conform to the regexp [a-zA-Z0-9-_]+ and be less than 128 bytes in length.
in length. These are reflected as part of a URL in the metadata server. These are reflected as part of a URL in the metadata server. Additionally, to avoid
Additionally, to avoid ambiguity, keys must not conflict with any other ambiguity, keys must not conflict with any other metadata keys for the project or
metadata keys for the project or be one of the four reserved keys: "instance-template", be one of the four reserved keys: "instance-template", "kube-env", "startup-script",
"kube-env", "startup-script", and "user-data" Values are free-form strings, and "user-data" Values are free-form strings, and only have meaning as interpreted
and only have meaning as interpreted by the image running in the instance. by the image running in the instance. The only restriction placed on them is that
The only restriction placed on them is that each value''s size must be each value''s size must be less than or equal to 32 KB.'
less than or equal to 32 KB.'
- The total size of all keys and values must be less than 512 KB. - The total size of all keys and values must be less than 512 KB.
- 'An object containing a list of "key": value pairs.' - 'An object containing a list of "key": value pairs.'
- 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.' - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.'
@ -150,42 +144,42 @@ items:
type: dict type: dict
imageType: imageType:
description: description:
- The image type to use for this node. Note that for a given image type, - The image type to use for this node. Note that for a given image type, the latest
the latest version of it will be used. version of it will be used.
returned: success returned: success
type: str type: str
labels: labels:
description: description:
- 'The map of Kubernetes labels (key/value pairs) to be applied to each - 'The map of Kubernetes labels (key/value pairs) to be applied to each node.
node. These will added in addition to any default label(s) that Kubernetes These will added in addition to any default label(s) that Kubernetes may apply
may apply to the node. In case of conflict in label keys, the applied to the node. In case of conflict in label keys, the applied set may differ
set may differ depending on the Kubernetes version -- it''s best to assume depending on the Kubernetes version -- it''s best to assume the behavior is
the behavior is undefined and conflicts should be avoided. For more information, undefined and conflicts should be avoided. For more information, including
including usage and the valid values, see: U(http://kubernetes.io/v1.1/docs/user-guide/labels.html) usage and the valid values, see:
An object containing a list of "key": value pairs.' U(http://kubernetes.io/v1.1/docs/user-guide/labels.html) An object containing
a list of "key": value pairs.'
- 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.' - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.'
returned: success returned: success
type: dict type: dict
localSsdCount: localSsdCount:
description: description:
- The number of local SSD disks to be attached to the node. - The number of local SSD disks to be attached to the node.
- 'The limit for this value is dependant upon the maximum number of disks - 'The limit for this value is dependant upon the maximum number of disks available
available on a machine per zone. See: U(https://cloud.google.com/compute/docs/disks/local-ssd#local_ssd_limits) on a machine per zone. See: U(https://cloud.google.com/compute/docs/disks/local-ssd#local_ssd_limits) for
for more information.' more information.'
returned: success returned: success
type: int type: int
tags: tags:
description: description:
- The list of instance tags applied to all nodes. Tags are used to identify - The list of instance tags applied to all nodes. Tags are used to identify valid
valid sources or targets for network firewalls and are specified by the sources or targets for network firewalls and are specified by the client during
client during cluster or node pool creation. Each tag within the list cluster or node pool creation. Each tag within the list must comply with RFC1035.
must comply with RFC1035.
returned: success returned: success
type: list type: list
preemptible: preemptible:
description: description:
- 'Whether the nodes are created as preemptible VM instances. See: U(https://cloud.google.com/compute/docs/instances/preemptible) - 'Whether the nodes are created as preemptible VM instances. See: U(https://cloud.google.com/compute/docs/instances/preemptible)
for more information about preemptible VM instances.' for more inforamtion about preemptible VM instances.'
returned: success returned: success
type: bool type: bool
masterAuth: masterAuth:
@ -201,9 +195,8 @@ items:
type: str type: str
password: password:
description: description:
- The password to use for HTTP basic authentication to the master endpoint. - The password to use for HTTP basic authentication to the master endpoint. Because
Because the master endpoint is open to the Internet, you should create the master endpoint is open to the Internet, you should create a strong password.
a strong password.
returned: success returned: success
type: str type: str
clusterCaCertificate: clusterCaCertificate:
@ -213,20 +206,19 @@ items:
type: str type: str
clientCertificate: clientCertificate:
description: description:
- Base64-encoded public certificate used by clients to authenticate to the - Base64-encoded public certificate used by clients to authenticate to the cluster
cluster endpoint. endpoint.
returned: success returned: success
type: str type: str
clientKey: clientKey:
description: description:
- Base64-encoded private key used by clients to authenticate to the cluster - Base64-encoded private key used by clients to authenticate to the cluster endpoint.
endpoint.
returned: success returned: success
type: str type: str
loggingService: loggingService:
description: description:
- 'The logging service the cluster should use to write logs. Currently available - 'The logging service the cluster should use to write logs. Currently available options: logging.googleapis.com
options: logging.googleapis.com - the Google Cloud Logging service.' - the Google Cloud Logging service.'
- none - no logs will be exported from the cluster. - none - no logs will be exported from the cluster.
- if left as an empty string,logging.googleapis.com will be used. - if left as an empty string,logging.googleapis.com will be used.
returned: success returned: success
@ -234,8 +226,8 @@ items:
monitoringService: monitoringService:
description: description:
- The monitoring service the cluster should use to write metrics. - The monitoring service the cluster should use to write metrics.
- 'Currently available options: monitoring.googleapis.com - the Google Cloud - 'Currently available options: monitoring.googleapis.com - the Google Cloud Monitoring
Monitoring service.' service.'
- none - no metrics will be exported from the cluster. - none - no metrics will be exported from the cluster.
- if left as an empty string, monitoring.googleapis.com will be used. - if left as an empty string, monitoring.googleapis.com will be used.
returned: success returned: success
@ -244,49 +236,15 @@ items:
description: description:
- The name of the Google Compute Engine network to which the cluster is connected. - The name of the Google Compute Engine network to which the cluster is connected.
If left unspecified, the default network will be used. If left unspecified, the default network will be used.
returned: success - To ensure it exists and it is operations, configure the network using 'gcompute_network'
type: str resource.
privateClusterConfig:
description:
- Configuration for a private cluster.
returned: success
type: complex
contains:
enablePrivateNodes:
description:
- Whether nodes have internal IP addresses only. If enabled, all nodes are
given only RFC 1918 private addresses and communicate with the master
via private networking.
returned: success
type: bool
enablePrivateEndpoint:
description:
- Whether the master's internal IP address is used as the cluster endpoint.
returned: success
type: bool
masterIpv4CidrBlock:
description:
- The IP range in CIDR notation to use for the hosted master network. This
range will be used for assigning internal IP addresses to the master or
set of masters, as well as the ILB VIP. This range must not overlap with
any other ranges in use within the cluster's network.
returned: success
type: str
privateEndpoint:
description:
- The internal IP address of this cluster's master endpoint.
returned: success
type: str
publicEndpoint:
description:
- The external IP address of this cluster's master endpoint.
returned: success returned: success
type: str type: str
clusterIpv4Cidr: clusterIpv4Cidr:
description: description:
- The IP address range of the container pods in this cluster, in CIDR notation - The IP address range of the container pods in this cluster, in CIDR notation (e.g.
(e.g. 10.96.0.0/14). Leave blank to have one automatically chosen or specify 10.96.0.0/14). Leave blank to have one automatically chosen or specify a /14 block
a /14 block in 10.0.0.0/8. in 10.0.0.0/8.
returned: success returned: success
type: str type: str
addonsConfig: addonsConfig:
@ -297,31 +255,30 @@ items:
contains: contains:
httpLoadBalancing: httpLoadBalancing:
description: description:
- Configuration for the HTTP (L7) load balancing controller addon, which - Configuration for the HTTP (L7) load balancing controller addon, which makes it
makes it easy to set up HTTP load balancers for services in a cluster. easy to set up HTTP load balancers for services in a cluster.
returned: success returned: success
type: complex type: complex
contains: contains:
disabled: disabled:
description: description:
- Whether the HTTP Load Balancing controller is enabled in the cluster. - Whether the HTTP Load Balancing controller is enabled in the cluster. When enabled,
When enabled, it runs a small pod in the cluster that manages the it runs a small pod in the cluster that manages the load balancers.
load balancers.
returned: success returned: success
type: bool type: bool
horizontalPodAutoscaling: horizontalPodAutoscaling:
description: description:
- Configuration for the horizontal pod autoscaling feature, which increases - Configuration for the horizontal pod autoscaling feature, which increases or decreases
or decreases the number of replica pods a replication controller has based the number of replica pods a replication controller has based on the resource usage
on the resource usage of the existing pods. of the existing pods.
returned: success returned: success
type: complex type: complex
contains: contains:
disabled: disabled:
description: description:
- Whether the Horizontal Pod Autoscaling feature is enabled in the cluster. - Whether the Horizontal Pod Autoscaling feature is enabled in the cluster. When enabled,
When enabled, it ensures that a Heapster pod is running in the cluster, it ensures that a Heapster pod is running in the cluster, which is also used by
which is also used by the Cloud Monitoring service. the Cloud Monitoring service.
returned: success returned: success
type: bool type: bool
subnetwork: subnetwork:
@ -329,17 +286,23 @@ items:
- The name of the Google Compute Engine subnetwork to which the cluster is connected. - The name of the Google Compute Engine subnetwork to which the cluster is connected.
returned: success returned: success
type: str type: str
location:
description:
- The list of Google Compute Engine locations in which the cluster's nodes should
be located.
returned: success
type: list
endpoint: endpoint:
description: description:
- The IP address of this cluster's master endpoint. - The IP address of this cluster's master endpoint.
- The endpoint can be accessed from the internet at https://username:password@endpoint/ - The endpoint can be accessed from the internet at https://username:password@endpoint/ See
See the masterAuth property of this resource for username and password information. the masterAuth property of this resource for username and password information.
returned: success returned: success
type: str type: str
initialClusterVersion: initialClusterVersion:
description: description:
- The software version of the master endpoint and kubelets used in the cluster - The software version of the master endpoint and kubelets used in the cluster when
when it was first created. The version can be upgraded over time. it was first created. The version can be upgraded over time.
returned: success returned: success
type: str type: str
currentMasterVersion: currentMasterVersion:
@ -349,9 +312,9 @@ items:
type: str type: str
currentNodeVersion: currentNodeVersion:
description: description:
- The current version of the node software components. If they are currently - The current version of the node software components. If they are currently at multiple
at multiple versions because they're in the process of being upgraded, this versions because they're in the process of being upgraded, this reflects the minimum
reflects the minimum version of all nodes. version of all nodes.
returned: success returned: success
type: str type: str
createTime: createTime:
@ -368,8 +331,8 @@ items:
servicesIpv4Cidr: servicesIpv4Cidr:
description: description:
- The IP address range of the Kubernetes services in this cluster, in CIDR notation - The IP address range of the Kubernetes services in this cluster, in CIDR notation
(e.g. 1.2.3.4/29). Service addresses are typically put in the last /16 from (e.g. 1.2.3.4/29). Service addresses are typically put in the last /16 from the
the container CIDR. container CIDR.
returned: success returned: success
type: str type: str
currentNodeCount: currentNodeCount:
@ -382,9 +345,9 @@ items:
- The time the cluster will be automatically deleted in RFC3339 text format. - The time the cluster will be automatically deleted in RFC3339 text format.
returned: success returned: success
type: str type: str
location: zone:
description: description:
- The location where the cluster is deployed. - The zone where the cluster is deployed.
returned: success returned: success
type: str type: str
''' '''
@ -401,9 +364,13 @@ import json
def main(): def main():
module = GcpModule(argument_spec=dict(location=dict(required=True, type='str', aliases=['region', 'zone']))) module = GcpModule(
argument_spec=dict(
zone=dict(required=True, type='str')
)
)
if not module.params['scopes']: if 'scopes' not in module.params:
module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform'] module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
items = fetch_list(module, collection(module)) items = fetch_list(module, collection(module))
@ -411,12 +378,14 @@ def main():
items = items.get('clusters') items = items.get('clusters')
else: else:
items = [] items = []
return_value = {'items': items} return_value = {
'items': items
}
module.exit_json(**return_value) module.exit_json(**return_value)
def collection(module): def collection(module):
return "https://container.googleapis.com/v1/projects/{project}/locations/{location}/clusters".format(**module.params) return "https://container.googleapis.com/v1/projects/{project}/zones/{zone}/clusters".format(**module.params)
def fetch_list(module, link): def fetch_list(module, link):

View file

@ -226,7 +226,7 @@ EXAMPLES = '''
- name: create a node pool - name: create a node pool
gcp_container_node_pool: gcp_container_node_pool:
name: "test_object" name: my-pool
initial_node_count: 4 initial_node_count: 4
cluster: "{{ cluster }}" cluster: "{{ cluster }}"
zone: us-central1-a zone: us-central1-a

View file

@ -18,57 +18,53 @@
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
################################################################################ ################################################################################
# Documentation # Documentation
################################################################################ ################################################################################
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'} ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ["preview"],
'supported_by': 'community'}
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
module: gcp_container_node_pool_facts module: gcp_container_node_pool_facts
description: description:
- Gather facts for GCP NodePool - Gather facts for GCP NodePool
short_description: Gather facts for GCP NodePool short_description: Gather facts for GCP NodePool
version_added: 2.8 version_added: 2.8
author: Google Inc. (@googlecloudplatform) author: Google Inc. (@googlecloudplatform)
requirements: requirements:
- python >= 2.6 - python >= 2.6
- requests >= 2.18.4 - requests >= 2.18.4
- google-auth >= 1.3.0 - google-auth >= 1.3.0
options: options:
location: zone:
description: description:
- The location where the node pool is deployed. - The zone where the node pool is deployed.
required: true required: true
aliases:
- region
- zone
version_added: 2.8
cluster: cluster:
description: description:
- The cluster this node pool belongs to. - The cluster this node pool belongs to.
- 'This field represents a link to a Cluster resource in GCP. It can be specified - 'This field represents a link to a Cluster resource in GCP. It can be specified
in two ways. First, you can place a dictionary with key ''name'' and value of in two ways. You can add `register: name-of-resource` to a gcp_container_cluster
your resource''s name Alternatively, you can add `register: name-of-resource` task and then set this cluster field to "{{ name-of-resource }}" Alternatively,
to a gcp_container_cluster task and then set this cluster field to "{{ name-of-resource you can set this cluster to a dictionary with the name key where the value is the
}}"' name of your Cluster.'
required: true required: true
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: " a node pool facts" - name: a node pool facts
gcp_container_node_pool_facts: gcp_container_node_pool_facts:
cluster: "{{ cluster }}" cluster: "{{ cluster }}"
location: us-central1-a zone: us-central1-a
project: test_project project: test_project
auth_kind: serviceaccount auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: facts
''' '''
RETURN = ''' RETURN = '''
@ -96,40 +92,39 @@ items:
type: str type: str
diskSizeGb: diskSizeGb:
description: description:
- Size of the disk attached to each node, specified in GB. The smallest - Size of the disk attached to each node, specified in GB. The smallest allowed disk
allowed disk size is 10GB. If unspecified, the default disk size is 100GB. size is 10GB. If unspecified, the default disk size is 100GB.
returned: success returned: success
type: int type: int
oauthScopes: oauthScopes:
description: description:
- The set of Google API scopes to be made available on all of the node VMs - The set of Google API scopes to be made available on all of the node VMs under the
under the "default" service account. "default" service account.
- 'The following scopes are recommended, but not required, and by default - 'The following scopes are recommended, but not required, and by default are not
are not included: U(https://www.googleapis.com/auth/compute) is required included: U(https://www.googleapis.com/auth/compute) is required for mounting persistent
for mounting persistent storage on your nodes.' storage on your nodes.'
- U(https://www.googleapis.com/auth/devstorage.read_only) is required for - U(https://www.googleapis.com/auth/devstorage.read_only) is required for communicating
communicating with gcr.io (the Google Container Registry). with gcr.io (the Google Container Registry).
- If unspecified, no scopes are added, unless Cloud Logging or Cloud Monitoring - If unspecified, no scopes are added, unless Cloud Logging or Cloud Monitoring are
are enabled, in which case their required scopes will be added. enabled, in which case their required scopes will be added.
returned: success returned: success
type: list type: list
serviceAccount: serviceAccount:
description: description:
- The Google Cloud Platform Service Account to be used by the node VMs. - The Google Cloud Platform Service Account to be used by the node VMs. If no Service
If no Service Account is specified, the "default" service account is used. Account is specified, the "default" service account is used.
returned: success returned: success
type: str type: str
metadata: metadata:
description: description:
- The metadata key/value pairs assigned to instances in the cluster. - The metadata key/value pairs assigned to instances in the cluster.
- 'Keys must conform to the regexp [a-zA-Z0-9-_]+ and be less than 128 bytes - 'Keys must conform to the regexp [a-zA-Z0-9-_]+ and be less than 128 bytes in length.
in length. These are reflected as part of a URL in the metadata server. These are reflected as part of a URL in the metadata server. Additionally, to avoid
Additionally, to avoid ambiguity, keys must not conflict with any other ambiguity, keys must not conflict with any other metadata keys for the project or
metadata keys for the project or be one of the four reserved keys: "instance-template", be one of the four reserved keys: "instance-template", "kube-env", "startup-script",
"kube-env", "startup-script", and "user-data" Values are free-form strings, and "user-data" Values are free-form strings, and only have meaning as interpreted
and only have meaning as interpreted by the image running in the instance. by the image running in the instance. The only restriction placed on them is that
The only restriction placed on them is that each value''s size must be each value''s size must be less than or equal to 32 KB.'
less than or equal to 32 KB.'
- The total size of all keys and values must be less than 512 KB. - The total size of all keys and values must be less than 512 KB.
- 'An object containing a list of "key": value pairs.' - 'An object containing a list of "key": value pairs.'
- 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.' - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.'
@ -137,49 +132,49 @@ items:
type: dict type: dict
imageType: imageType:
description: description:
- The image type to use for this node. Note that for a given image type, - The image type to use for this node. Note that for a given image type, the latest
the latest version of it will be used. version of it will be used.
returned: success returned: success
type: str type: str
labels: labels:
description: description:
- 'The map of Kubernetes labels (key/value pairs) to be applied to each - 'The map of Kubernetes labels (key/value pairs) to be applied to each node.
node. These will added in addition to any default label(s) that Kubernetes These will added in addition to any default label(s) that Kubernetes may apply
may apply to the node. In case of conflict in label keys, the applied to the node. In case of conflict in label keys, the applied set may differ
set may differ depending on the Kubernetes version -- it''s best to assume depending on the Kubernetes version -- it''s best to assume the behavior is
the behavior is undefined and conflicts should be avoided. For more information, undefined and conflicts should be avoided. For more information, including
including usage and the valid values, see: U(http://kubernetes.io/v1.1/docs/user-guide/labels.html) usage and the valid values, see:
An object containing a list of "key": value pairs.' U(http://kubernetes.io/v1.1/docs/user-guide/labels.html) An object containing
a list of "key": value pairs.'
- 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.' - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.'
returned: success returned: success
type: dict type: dict
localSsdCount: localSsdCount:
description: description:
- The number of local SSD disks to be attached to the node. - The number of local SSD disks to be attached to the node.
- 'The limit for this value is dependant upon the maximum number of disks - 'The limit for this value is dependant upon the maximum number of disks available
available on a machine per zone. See: U(https://cloud.google.com/compute/docs/disks/local-ssd#local_ssd_limits) on a machine per zone. See: U(https://cloud.google.com/compute/docs/disks/local-ssd#local_ssd_limits) for
for more information.' more information.'
returned: success returned: success
type: int type: int
tags: tags:
description: description:
- The list of instance tags applied to all nodes. Tags are used to identify - The list of instance tags applied to all nodes. Tags are used to identify valid
valid sources or targets for network firewalls and are specified by the sources or targets for network firewalls and are specified by the client during
client during cluster or node pool creation. Each tag within the list cluster or node pool creation. Each tag within the list must comply with RFC1035.
must comply with RFC1035.
returned: success returned: success
type: list type: list
preemptible: preemptible:
description: description:
- 'Whether the nodes are created as preemptible VM instances. See: U(https://cloud.google.com/compute/docs/instances/preemptible) - 'Whether the nodes are created as preemptible VM instances. See: U(https://cloud.google.com/compute/docs/instances/preemptible)
for more information about preemptible VM instances.' for more inforamtion about preemptible VM instances.'
returned: success returned: success
type: bool type: bool
initialNodeCount: initialNodeCount:
description: description:
- The initial node count for the pool. You must ensure that your Compute Engine - The initial node count for the pool. You must ensure that your Compute Engine resource
resource quota is sufficient for this number of instances. You must also have quota is sufficient for this number of instances. You must also have available firewall
available firewall and routes quota. and routes quota.
returned: success returned: success
type: int type: int
version: version:
@ -189,8 +184,8 @@ items:
type: str type: str
autoscaling: autoscaling:
description: description:
- Autoscaler configuration for this NodePool. Autoscaler is enabled only if - Autoscaler configuration for this NodePool. Autoscaler is enabled only if a valid
a valid configuration is present. configuration is present.
returned: success returned: success
type: complex type: complex
contains: contains:
@ -218,17 +213,16 @@ items:
contains: contains:
autoUpgrade: autoUpgrade:
description: description:
- A flag that specifies whether node auto-upgrade is enabled for the node - A flag that specifies whether node auto-upgrade is enabled for the node pool. If
pool. If enabled, node auto-upgrade helps keep the nodes in your node enabled, node auto-upgrade helps keep the nodes in your node pool up to date with
pool up to date with the latest release version of Kubernetes. the latest release version of Kubernetes.
returned: success returned: success
type: bool type: bool
autoRepair: autoRepair:
description: description:
- A flag that specifies whether the node auto-repair is enabled for the - A flag that specifies whether the node auto-repair is enabled for the node pool.
node pool. If enabled, the nodes in this node pool will be monitored and, If enabled, the nodes in this node pool will be monitored and, if they fail health
if they fail health checks too many times, an automatic repair action checks too many times, an automatic repair action will be triggered.
will be triggered.
returned: success returned: success
type: bool type: bool
upgradeOptions: upgradeOptions:
@ -239,14 +233,14 @@ items:
contains: contains:
autoUpgradeStartTime: autoUpgradeStartTime:
description: description:
- This field is set when upgrades are about to commence with the approximate - This field is set when upgrades are about to commence with the approximate start
start time for the upgrades, in RFC3339 text format. time for the upgrades, in RFC3339 text format.
returned: success returned: success
type: str type: str
description: description:
description: description:
- This field is set when upgrades are about to commence with the description - This field is set when upgrades are about to commence with the description of the
of the upgrade. upgrade.
returned: success returned: success
type: str type: str
cluster: cluster:
@ -254,9 +248,9 @@ items:
- The cluster this node pool belongs to. - The cluster this node pool belongs to.
returned: success returned: success
type: dict type: dict
location: zone:
description: description:
- The location where the node pool is deployed. - The zone where the node pool is deployed.
returned: success returned: success
type: str type: str
''' '''
@ -273,9 +267,14 @@ import json
def main(): def main():
module = GcpModule(argument_spec=dict(location=dict(required=True, type='str', aliases=['region', 'zone']), cluster=dict(required=True, type='dict'))) module = GcpModule(
argument_spec=dict(
zone=dict(required=True, type='str'),
cluster=dict(required=True, type='dict')
)
)
if not module.params['scopes']: if 'scopes' not in module.params:
module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform'] module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
items = fetch_list(module, collection(module)) items = fetch_list(module, collection(module))
@ -283,13 +282,19 @@ def main():
items = items.get('nodePools') items = items.get('nodePools')
else: else:
items = [] items = []
return_value = {'items': items} return_value = {
'items': items
}
module.exit_json(**return_value) module.exit_json(**return_value)
def collection(module): def collection(module):
res = {'project': module.params['project'], 'location': module.params['location'], 'cluster': replace_resource_dict(module.params['cluster'], 'name')} res = {
return "https://container.googleapis.com/v1/projects/{project}/zones/{location}/clusters/{cluster}/nodePools".format(**res) 'project': module.params['project'],
'zone': module.params['zone'],
'cluster': replace_resource_dict(module.params['cluster'], 'name')
}
return "https://container.googleapis.com/v1/projects/{project}/zones/{zone}/clusters/{cluster}/nodePools".format(**res)
def fetch_list(module, link): def fetch_list(module, link):

View file

@ -18,68 +18,68 @@
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
################################################################################ ################################################################################
# Documentation # Documentation
################################################################################ ################################################################################
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'} ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ["preview"],
'supported_by': 'community'}
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
module: gcp_spanner_database_facts module: gcp_spanner_database_facts
description: description:
- Gather facts for GCP Database - Gather facts for GCP Database
short_description: Gather facts for GCP Database short_description: Gather facts for GCP Database
version_added: 2.8 version_added: 2.8
author: Google Inc. (@googlecloudplatform) author: Google Inc. (@googlecloudplatform)
requirements: requirements:
- python >= 2.6 - python >= 2.6
- requests >= 2.18.4 - requests >= 2.18.4
- google-auth >= 1.3.0 - google-auth >= 1.3.0
options: options:
instance: instance:
description: description:
- The instance to create the database on. - The instance to create the database on.
- 'This field represents a link to a Instance resource in GCP. It can be specified - 'This field represents a link to a Instance resource in GCP. It can be specified
in two ways. First, you can place a dictionary with key ''name'' and value of in two ways. You can add `register: name-of-resource` to a gcp_spanner_instance
your resource''s name Alternatively, you can add `register: name-of-resource` task and then set this instance field to "{{ name-of-resource }}" Alternatively,
to a gcp_spanner_instance task and then set this instance field to "{{ name-of-resource you can set this instance to a dictionary with the name key where the value is the
}}"' name of your Instance.'
required: true required: true
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: " a database facts" - name: a database facts
gcp_spanner_database_facts: gcp_spanner_database_facts:
instance: "{{ instance }}" instance: "{{ instance }}"
project: test_project project: test_project
auth_kind: serviceaccount auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: facts
''' '''
RETURN = ''' RETURN = '''
resources: items:
description: List of resources description: List of items
returned: always returned: always
type: complex type: complex
contains: contains:
name: name:
description: description:
- A unique identifier for the database, which cannot be changed after the instance - A unique identifier for the database, which cannot be changed after the instance
is created. Values are of the form [a-z][-a-z0-9]*[a-z0-9]. is created. Values are of the form projects/<project>/instances/[a-z][-a-z0-9]*[a-z0-9].
The final segment of the name must be between 6 and 30 characters in length.
returned: success returned: success
type: str type: str
extraStatements: extraStatements:
description: description:
- 'An optional list of DDL statements to run inside the newly created database. - 'An optional list of DDL statements to run inside the newly created database. Statements
Statements can create tables, indexes, etc. These statements execute atomically can create tables, indexes, etc. These statements execute atomically with the creation
with the creation of the database: if there is an error in any statement, of the database: if there is an error in any statement, the database is not created.'
the database is not created.'
returned: success returned: success
type: list type: list
instance: instance:
@ -101,9 +101,13 @@ import json
def main(): def main():
module = GcpModule(argument_spec=dict(instance=dict(required=True, type='dict'))) module = GcpModule(
argument_spec=dict(
instance=dict(required=True, type='dict')
)
)
if not module.params['scopes']: if 'scopes' not in module.params:
module.params['scopes'] = ['https://www.googleapis.com/auth/spanner.admin'] module.params['scopes'] = ['https://www.googleapis.com/auth/spanner.admin']
items = fetch_list(module, collection(module)) items = fetch_list(module, collection(module))
@ -111,12 +115,17 @@ def main():
items = items.get('databases') items = items.get('databases')
else: else:
items = [] items = []
return_value = {'resources': items} return_value = {
'items': items
}
module.exit_json(**return_value) module.exit_json(**return_value)
def collection(module): def collection(module):
res = {'project': module.params['project'], 'instance': replace_resource_dict(module.params['instance'], 'name')} res = {
'project': module.params['project'],
'instance': replace_resource_dict(module.params['instance'], 'name')
}
return "https://spanner.googleapis.com/v1/projects/{project}/instances/{instance}/databases".format(**res) return "https://spanner.googleapis.com/v1/projects/{project}/instances/{instance}/databases".format(**res)

View file

@ -18,66 +18,61 @@
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
################################################################################ ################################################################################
# Documentation # Documentation
################################################################################ ################################################################################
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'} ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ["preview"],
'supported_by': 'community'}
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
module: gcp_spanner_instance_facts module: gcp_spanner_instance_facts
description: description:
- Gather facts for GCP Instance - Gather facts for GCP Instance
short_description: Gather facts for GCP Instance short_description: Gather facts for GCP Instance
version_added: 2.8 version_added: 2.8
author: Google Inc. (@googlecloudplatform) author: Google Inc. (@googlecloudplatform)
requirements: requirements:
- python >= 2.6 - python >= 2.6
- requests >= 2.18.4 - requests >= 2.18.4
- google-auth >= 1.3.0 - google-auth >= 1.3.0
options: {}
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: " a instance facts" - name: a instance facts
gcp_spanner_instance_facts: gcp_spanner_instance_facts:
project: test_project project: test_project
auth_kind: serviceaccount auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: facts
''' '''
RETURN = ''' RETURN = '''
resources: items:
description: List of resources description: List of items
returned: always returned: always
type: complex type: complex
contains: contains:
name: name:
description: description:
- A unique identifier for the instance, which cannot be changed after the instance - A unique identifier for the instance, which cannot be changed after the instance
is created. The name must be between 6 and 30 characters in length. is created. Values are of the form projects/<project>/instances/[a-z][-a-z0-9]*[a-z0-9].
The final segment of the name must be between 6 and 30 characters in length.
returned: success returned: success
type: str type: str
config: config:
description: description:
- The name of the instance's configuration (similar but not quite the same as - A reference to the instance configuration.
a region) which defines defines the geographic placement and replication of
your databases in this instance. It determines where your data is stored.
Values are typically of the form `regional-europe-west1` , `us-central` etc.
- In order to obtain a valid list please consult the [Configuration section
of the docs](U(https://cloud.google.com/spanner/docs/instances).)
returned: success returned: success
type: str type: str
displayName: displayName:
description: description:
- The descriptive name for this instance as it appears in UIs. Must be unique - The descriptive name for this instance as it appears in UIs. Must be unique per
per project and between 4 and 30 characters in length. project and between 4 and 30 characters in length.
returned: success returned: success
type: str type: str
nodeCount: nodeCount:
@ -87,6 +82,22 @@ resources:
type: int type: int
labels: labels:
description: description:
- Cloud Labels are a flexible and lightweight mechanism for organizing cloud resources
into groups that reflect a customer's organizational needs and deployment strategies.
Cloud Labels can be used to filter collections of resources. They can be used to
control how resource metrics are aggregated. And they can be used as arguments to
policy management rules (e.g. route, firewall, load balancing, etc.).
- 'Label keys must be between 1 and 63 characters long and must conform to the following
regular expression: `[a-z]([-a-z0-9]*[a-z0-9])?`.'
- Label values must be between 0 and 63 characters long and must conform to the regular
expression `([a-z]([-a-z0-9]*[a-z0-9])?)?`.
- No more than 64 labels can be associated with a given resource.
- See U(https://goo.gl/xmQnxf) for more information on and examples of labels.
- 'If you plan to use labels in your own code, please note that additional characters
may be allowed in the future. And so you are advised to use an internal label representation,
such as JSON, which doesn''t rely upon specific characters being disallowed. For
example, representing labels as the string: name + "_" + value would prove problematic
if we were to allow "_" in a future release.'
- 'An object containing a list of "key": value pairs.' - 'An object containing a list of "key": value pairs.'
- 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.' - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.'
returned: success returned: success
@ -105,9 +116,12 @@ import json
def main(): def main():
module = GcpModule(argument_spec=dict()) module = GcpModule(
argument_spec=dict(
)
)
if not module.params['scopes']: if 'scopes' not in module.params:
module.params['scopes'] = ['https://www.googleapis.com/auth/spanner.admin'] module.params['scopes'] = ['https://www.googleapis.com/auth/spanner.admin']
items = fetch_list(module, collection(module)) items = fetch_list(module, collection(module))
@ -115,7 +129,9 @@ def main():
items = items.get('instances') items = items.get('instances')
else: else:
items = [] items = []
return_value = {'resources': items} return_value = {
'items': items
}
module.exit_json(**return_value) module.exit_json(**return_value)

View file

@ -18,48 +18,53 @@
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
################################################################################ ################################################################################
# Documentation # Documentation
################################################################################ ################################################################################
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'} ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ["preview"],
'supported_by': 'community'}
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
module: gcp_sql_database_facts module: gcp_sql_database_facts
description: description:
- Gather facts for GCP Database - Gather facts for GCP Database
short_description: Gather facts for GCP Database short_description: Gather facts for GCP Database
version_added: 2.8 version_added: 2.8
author: Google Inc. (@googlecloudplatform) author: Google Inc. (@googlecloudplatform)
requirements: requirements:
- python >= 2.6 - python >= 2.6
- requests >= 2.18.4 - requests >= 2.18.4
- google-auth >= 1.3.0 - google-auth >= 1.3.0
options: options:
instance: instance:
description: description:
- The name of the Cloud SQL instance. This does not include the project ID. - The name of the Cloud SQL instance. This does not include the project ID.
- 'This field represents a link to a Instance resource in GCP. It can be specified
in two ways. You can add `register: name-of-resource` to a gcp_sql_instance task
and then set this instance field to "{{ name-of-resource }}" Alternatively, you
can set this instance to a dictionary with the name key where the value is the name
of your Instance.'
required: true required: true
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: " a database facts" - name: a database facts
gcp_sql_database_facts: gcp_sql_database_facts:
instance: "{{ instance }}" instance: "{{ instance }}"
project: test_project project: test_project
auth_kind: serviceaccount auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: facts
''' '''
RETURN = ''' RETURN = '''
resources: items:
description: List of resources description: List of items
returned: always returned: always
type: complex type: complex
contains: contains:
@ -83,13 +88,13 @@ resources:
description: description:
- The name of the Cloud SQL instance. This does not include the project ID. - The name of the Cloud SQL instance. This does not include the project ID.
returned: success returned: success
type: str type: dict
''' '''
################################################################################ ################################################################################
# Imports # Imports
################################################################################ ################################################################################
from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
import json import json
################################################################################ ################################################################################
@ -98,9 +103,13 @@ import json
def main(): def main():
module = GcpModule(argument_spec=dict(instance=dict(required=True, type='str'))) module = GcpModule(
argument_spec=dict(
instance=dict(required=True, type='dict')
)
)
if not module.params['scopes']: if 'scopes' not in module.params:
module.params['scopes'] = ['https://www.googleapis.com/auth/sqlservice.admin'] module.params['scopes'] = ['https://www.googleapis.com/auth/sqlservice.admin']
items = fetch_list(module, collection(module)) items = fetch_list(module, collection(module))
@ -108,12 +117,18 @@ def main():
items = items.get('items') items = items.get('items')
else: else:
items = [] items = []
return_value = {'resources': items} return_value = {
'items': items
}
module.exit_json(**return_value) module.exit_json(**return_value)
def collection(module): def collection(module):
return "https://www.googleapis.com/sql/v1beta4/projects/{project}/instances/{instance}/databases".format(**module.params) res = {
'project': module.params['project'],
'instance': replace_resource_dict(module.params['instance'], 'name')
}
return "https://www.googleapis.com/sql/v1beta4/projects/{project}/instances/{instance}/databases".format(**res)
def fetch_list(module, link): def fetch_list(module, link):

View file

@ -18,43 +18,42 @@
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
################################################################################ ################################################################################
# Documentation # Documentation
################################################################################ ################################################################################
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'} ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ["preview"],
'supported_by': 'community'}
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
module: gcp_sql_instance_facts module: gcp_sql_instance_facts
description: description:
- Gather facts for GCP Instance - Gather facts for GCP Instance
short_description: Gather facts for GCP Instance short_description: Gather facts for GCP Instance
version_added: 2.8 version_added: 2.8
author: Google Inc. (@googlecloudplatform) author: Google Inc. (@googlecloudplatform)
requirements: requirements:
- python >= 2.6 - python >= 2.6
- requests >= 2.18.4 - requests >= 2.18.4
- google-auth >= 1.3.0 - google-auth >= 1.3.0
options: {}
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: " a instance facts" - name: a instance facts
gcp_sql_instance_facts: gcp_sql_instance_facts:
project: test_project project: test_project
auth_kind: serviceaccount auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: facts
''' '''
RETURN = ''' RETURN = '''
resources: items:
description: List of resources description: List of items
returned: always returned: always
type: complex type: complex
contains: contains:
@ -72,40 +71,38 @@ resources:
type: str type: str
databaseVersion: databaseVersion:
description: description:
- The database engine type and version. For First Generation instances, can - The database engine type and version. For First Generation instances, can be MYSQL_5_5,
be MYSQL_5_5, or MYSQL_5_6. For Second Generation instances, can be MYSQL_5_6 or MYSQL_5_6. For Second Generation instances, can be MYSQL_5_6 or MYSQL_5_7. Defaults
or MYSQL_5_7. Defaults to MYSQL_5_6. to MYSQL_5_6.
- 'PostgreSQL instances: POSTGRES_9_6 The databaseVersion property can not be - 'PostgreSQL instances: POSTGRES_9_6 The databaseVersion property can not be changed
changed after instance creation.' after instance creation.'
returned: success returned: success
type: str type: str
failoverReplica: failoverReplica:
description: description:
- The name and status of the failover replica. This property is applicable only - The name and status of the failover replica. This property is applicable only to
to Second Generation instances. Second Generation instances.
returned: success returned: success
type: complex type: complex
contains: contains:
available: available:
description: description:
- The availability status of the failover replica. A false status indicates - The availability status of the failover replica. A false status indicates that the
that the failover replica is out of sync. The master can only failover failover replica is out of sync. The master can only failover to the falover replica
to the failover replica when the status is true. when the status is true.
returned: success returned: success
type: bool type: bool
name: name:
description: description:
- The name of the failover replica. If specified at instance creation, a - The name of the failover replica. If specified at instance creation, a failover
failover replica is created for the instance. The name doesn't include replica is created for the instance. The name doesn't include the project ID. This
the project ID. This property is applicable only to Second Generation property is applicable only to Second Generation instances.
instances.
returned: success returned: success
type: str type: str
instanceType: instanceType:
description: description:
- The instance type. This can be one of the following. - The instance type. This can be one of the following.
- "* CLOUD_SQL_INSTANCE: A Cloud SQL instance that is not replicating from a - "* CLOUD_SQL_INSTANCE: A Cloud SQL instance that is not replicating from a master."
master."
- "* ON_PREMISES_INSTANCE: An instance running on the customer's premises." - "* ON_PREMISES_INSTANCE: An instance running on the customer's premises."
- "* READ_REPLICA_INSTANCE: A Cloud SQL instance configured as a read-replica." - "* READ_REPLICA_INSTANCE: A Cloud SQL instance configured as a read-replica."
returned: success returned: success
@ -123,22 +120,21 @@ resources:
type: str type: str
timeToRetire: timeToRetire:
description: description:
- The due time for this IP to be retired in RFC 3339 format, for example - The due time for this IP to be retired in RFC 3339 format, for example 2012-11-15T16:19:00.094Z.
2012-11-15T16:19:00.094Z. This field is only available when the IP is This field is only available when the IP is scheduled to be retired.
scheduled to be retired.
returned: success returned: success
type: str type: str
type: type:
description: description:
- The type of this IP address. A PRIMARY address is an address that can - The type of this IP address. A PRIMARY address is an address that can accept incoming
accept incoming connections. An OUTGOING address is the source address connections. An OUTGOING address is the source address of connections originating
of connections originating from the instance, if supported. from the instance, if supported.
returned: success returned: success
type: str type: str
ipv6Address: ipv6Address:
description: description:
- The IPv6 address assigned to the instance. This property is applicable only - The IPv6 address assigned to the instance. This property is applicable only to First
to First Generation instances. Generation instances.
returned: success returned: success
type: str type: str
masterInstanceName: masterInstanceName:
@ -158,8 +154,8 @@ resources:
type: str type: str
region: region:
description: description:
- The geographical region. Defaults to us-central or us-central1 depending on - The geographical region. Defaults to us-central or us-central1 depending on the
the instance type (First Generation or Second Generation/PostgreSQL). instance type (First Generation or Second Generation/PostgreSQL).
returned: success returned: success
type: str type: str
replicaConfiguration: replicaConfiguration:
@ -170,21 +166,21 @@ resources:
contains: contains:
failoverTarget: failoverTarget:
description: description:
- Specifies if the replica is the failover target. If the field is set to - Specifies if the replica is the failover target. If the field is set to true the
true the replica will be designated as a failover replica. replica will be designated as a failover replica.
- In case the master instance fails, the replica instance will be promoted - In case the master instance fails, the replica instance will be promoted as the
as the new master instance. new master instance.
- Only one replica can be specified as failover target, and the replica - Only one replica can be specified as failover target, and the replica has to be
has to be in different zone with the master instance. in different zone with the master instance.
returned: success returned: success
type: bool type: bool
mysqlReplicaConfiguration: mysqlReplicaConfiguration:
description: description:
- MySQL specific configuration when replicating from a MySQL on-premises - MySQL specific configuration when replicating from a MySQL on-premises master. Replication
master. Replication configuration information such as the username, password, configuration information such as the username, password, certificates, and keys
certificates, and keys are not stored in the instance metadata. The configuration are not stored in the instance metadata. The configuration information is used
information is used only to set up the replication connection and is stored only to set up the replication connection and is stored by MySQL in a file named
by MySQL in a file named master.info in the data directory. master.info in the data directory.
returned: success returned: success
type: complex type: complex
contains: contains:
@ -200,8 +196,8 @@ resources:
type: str type: str
clientKey: clientKey:
description: description:
- PEM representation of the slave's private key. The corresponding public - PEM representation of the slave's private key. The corresponsing public key is encoded
key is encoded in the client's certificate. in the client's asf asd certificate.
returned: success returned: success
type: str type: str
connectRetryInterval: connectRetryInterval:
@ -211,11 +207,11 @@ resources:
type: int type: int
dumpFilePath: dumpFilePath:
description: description:
- Path to a SQL dump file in Google Cloud Storage from which the slave - Path to a SQL dump file in Google Cloud Storage from which the slave instance is
instance is to be created. The URI is in the form gs://bucketName/fileName. to be created. The URI is in the form gs://bucketName/fileName. Compressed gzip
Compressed gzip files (.gz) are also supported. Dumps should have files (.gz) are also supported. Dumps should have the binlog co-ordinates from which
the binlog co-ordinates from which replication should begin. This replication should begin. This can be accomplished by setting --master-data to 1
can be accomplished by setting --master-data to 1 when using mysqldump. when using mysqldump.
returned: success returned: success
type: str type: str
masterHeartbeatPeriod: masterHeartbeatPeriod:
@ -240,8 +236,8 @@ resources:
type: str type: str
verifyServerCertificate: verifyServerCertificate:
description: description:
- Whether or not to check the master's Common Name value in the certificate - Whether or not to check the master's Common Name value in the certificate that it
that it sends during the SSL handshake. sends during the SSL handshake.
returned: success returned: success
type: bool type: bool
replicaNames: replicaNames:
@ -251,8 +247,8 @@ resources:
type: list type: list
serviceAccountEmailAddress: serviceAccountEmailAddress:
description: description:
- The service account email address assigned to the instance. This property - The service account email address assigned to the instance. This property is applicable
is applicable only to Second Generation instances. only to Second Generation instances.
returned: success returned: success
type: str type: str
settings: settings:
@ -263,9 +259,9 @@ resources:
contains: contains:
ipConfiguration: ipConfiguration:
description: description:
- The settings for IP Management. This allows to enable or disable the instance - The settings for IP Management. This allows to enable or disable the instance IP
IP and manage which external networks can connect to the instance. The and manage which external networks can connect to the instance. The IPv4 address
IPv4 address cannot be disabled for Second Generation instances. cannot be disabled for Second Generation instances.
returned: success returned: success
type: complex type: complex
contains: contains:
@ -276,16 +272,15 @@ resources:
type: bool type: bool
authorizedNetworks: authorizedNetworks:
description: description:
- The list of external networks that are allowed to connect to the instance - The list of external networks that are allowed to connect to the instance using
using the IP. In CIDR notation, also known as 'slash' notation (e.g. the IP. In CIDR notation, also known as 'slash' notation (e.g. 192.168.100.0/24).
192.168.100.0/24).
returned: success returned: success
type: complex type: complex
contains: contains:
expirationTime: expirationTime:
description: description:
- The time when this access control entry expires in RFC 3339 format, - The time when this access control entry expires in RFC 3339 format, for example
for example 2012-11-15T16:19:00.094Z. 2012-11-15T16:19:00.094Z.
returned: success returned: success
type: str type: str
name: name:
@ -295,58 +290,28 @@ resources:
type: str type: str
value: value:
description: description:
- The whitelisted value for the access control list. For example, - The whitelisted value for the access control list. For example, to grant access
to grant access to a client from an external IP (IPv4 or IPv6) to a client from an external IP (IPv4 or IPv6) address or subnet, use that address
address or subnet, use that address or subnet here. or subnet here.
returned: success returned: success
type: str type: str
requireSsl: requireSsl:
description: description:
- Whether the mysqld should default to 'REQUIRE X509' for users connecting - Whether the mysqld should default to 'REQUIRE X509' for users connecting over IP.
over IP.
returned: success returned: success
type: bool type: bool
tier: tier:
description: description:
- The tier or machine type for this instance, for example db-n1-standard-1. - The tier or machine type for this instance, for example db-n1-standard-1. For MySQL
For MySQL instances, this field determines whether the instance is Second instances, this field determines whether the instance is Second Generation (recommended)
Generation (recommended) or First Generation. or First Generation.
returned: success
type: str
availabilityType:
description:
- The availabilityType define if your postgres instance is run zonal or
regional.
returned: success
type: str
backupConfiguration:
description:
- The daily backup configuration for the instance.
returned: success
type: complex
contains:
enabled:
description:
- Enable Autobackup for your instance.
returned: success
type: bool
binaryLogEnabled:
description:
- Whether binary log is enabled. If backup configuration is disabled,
binary log must be disabled as well. MySQL only.
returned: success
type: bool
startTime:
description:
- Define the backup start time in UTC (HH:MM) .
returned: success returned: success
type: str type: str
settingsVersion: settingsVersion:
description: description:
- The version of instance settings. This is a required field for update - The version of instance settings. This is a required field for update method to
method to make sure concurrent updates are handled properly. During update, make sure concurrent updates are handled properly. During update, use the most
use the most recent settingsVersion value for this instance and do not recent settingsVersion value for this instance and do not try to update this value.
try to update this value.
returned: success returned: success
type: int type: int
''' '''
@ -363,9 +328,12 @@ import json
def main(): def main():
module = GcpModule(argument_spec=dict()) module = GcpModule(
argument_spec=dict(
)
)
if not module.params['scopes']: if 'scopes' not in module.params:
module.params['scopes'] = ['https://www.googleapis.com/auth/sqlservice.admin'] module.params['scopes'] = ['https://www.googleapis.com/auth/sqlservice.admin']
items = fetch_list(module, collection(module)) items = fetch_list(module, collection(module))
@ -373,7 +341,9 @@ def main():
items = items.get('items') items = items.get('items')
else: else:
items = [] items = []
return_value = {'resources': items} return_value = {
'items': items
}
module.exit_json(**return_value) module.exit_json(**return_value)

View file

@ -18,61 +18,61 @@
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
################################################################################ ################################################################################
# Documentation # Documentation
################################################################################ ################################################################################
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'} ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ["preview"],
'supported_by': 'community'}
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
module: gcp_sql_user_facts module: gcp_sql_user_facts
description: description:
- Gather facts for GCP User - Gather facts for GCP User
short_description: Gather facts for GCP User short_description: Gather facts for GCP User
version_added: 2.8 version_added: 2.8
author: Google Inc. (@googlecloudplatform) author: Google Inc. (@googlecloudplatform)
requirements: requirements:
- python >= 2.6 - python >= 2.6
- requests >= 2.18.4 - requests >= 2.18.4
- google-auth >= 1.3.0 - google-auth >= 1.3.0
options: options:
instance: instance:
description: description:
- The name of the Cloud SQL instance. This does not include the project ID. - The name of the Cloud SQL instance. This does not include the project ID.
- 'This field represents a link to a Instance resource in GCP. It can be specified - 'This field represents a link to a Instance resource in GCP. It can be specified
in two ways. First, you can place a dictionary with key ''name'' and value of in two ways. You can add `register: name-of-resource` to a gcp_sql_instance task
your resource''s name Alternatively, you can add `register: name-of-resource` and then set this instance field to "{{ name-of-resource }}" Alternatively, you
to a gcp_sql_instance task and then set this instance field to "{{ name-of-resource can set this instance to a dictionary with the name key where the value is the name
}}"' of your Instance.'
required: true required: true
extends_documentation_fragment: gcp extends_documentation_fragment: gcp
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: " a user facts" - name: a user facts
gcp_sql_user_facts: gcp_sql_user_facts:
instance: "{{ instance }}" instance: "{{ instance }}"
project: test_project project: test_project
auth_kind: serviceaccount auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem" service_account_file: "/tmp/auth.pem"
state: facts
''' '''
RETURN = ''' RETURN = '''
resources: items:
description: List of resources description: List of items
returned: always returned: always
type: complex type: complex
contains: contains:
host: host:
description: description:
- The host name from which the user can connect. For insert operations, host - The host name from which the user can connect. For insert operations, host defaults
defaults to an empty string. For update operations, host is specified as part to an empty string. For update operations, host is specified as part of the request
of the request URL. The host name cannot be updated after insertion. URL. The host name cannot be updated after insertion.
returned: success returned: success
type: str type: str
name: name:
@ -104,9 +104,13 @@ import json
def main(): def main():
module = GcpModule(argument_spec=dict(instance=dict(required=True, type='dict'))) module = GcpModule(
argument_spec=dict(
instance=dict(required=True, type='dict')
)
)
if not module.params['scopes']: if 'scopes' not in module.params:
module.params['scopes'] = ['https://www.googleapis.com/auth/sqlservice.admin'] module.params['scopes'] = ['https://www.googleapis.com/auth/sqlservice.admin']
items = fetch_list(module, collection(module)) items = fetch_list(module, collection(module))
@ -114,12 +118,17 @@ def main():
items = items.get('items') items = items.get('items')
else: else:
items = [] items = []
return_value = {'resources': items} return_value = {
'items': items
}
module.exit_json(**return_value) module.exit_json(**return_value)
def collection(module): def collection(module):
res = {'project': module.params['project'], 'instance': replace_resource_dict(module.params['instance'], 'name')} res = {
'project': module.params['project'],
'instance': replace_resource_dict(module.params['instance'], 'name')
}
return "https://www.googleapis.com/sql/v1beta4/projects/{project}/instances/{instance}/users".format(**res) return "https://www.googleapis.com/sql/v1beta4/projects/{project}/instances/{instance}/users".format(**res)

View file

@ -23,7 +23,7 @@
node_config: node_config:
machine_type: n1-standard-4 machine_type: n1-standard-4
disk_size_gb: 500 disk_size_gb: 500
location: us-central1-a zone: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
@ -39,7 +39,7 @@
node_config: node_config:
machine_type: n1-standard-4 machine_type: n1-standard-4
disk_size_gb: 500 disk_size_gb: 500
location: us-central1-a zone: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
@ -51,7 +51,7 @@
- result.changed == true - result.changed == true
- name: verify that cluster was created - name: verify that cluster was created
gcp_container_cluster_facts: gcp_container_cluster_facts:
location: us-central1-a zone: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
@ -61,7 +61,7 @@
- name: verify that command succeeded - name: verify that command succeeded
assert: assert:
that: that:
- "'my-cluster' in \"{{ results['items'] | map(attribute='name') | list }}\"" - results['items'] | length >= 1
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
- name: create a cluster that already exists - name: create a cluster that already exists
gcp_container_cluster: gcp_container_cluster:
@ -73,7 +73,7 @@
node_config: node_config:
machine_type: n1-standard-4 machine_type: n1-standard-4
disk_size_gb: 500 disk_size_gb: 500
location: us-central1-a zone: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
@ -94,7 +94,7 @@
node_config: node_config:
machine_type: n1-standard-4 machine_type: n1-standard-4
disk_size_gb: 500 disk_size_gb: 500
location: us-central1-a zone: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
@ -106,7 +106,7 @@
- result.changed == true - result.changed == true
- name: verify that cluster was deleted - name: verify that cluster was deleted
gcp_container_cluster_facts: gcp_container_cluster_facts:
location: us-central1-a zone: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
@ -116,7 +116,7 @@
- name: verify that command succeeded - name: verify that command succeeded
assert: assert:
that: that:
- "'my-cluster' not in \"{{ results['items'] | map(attribute='name') | list }}\"" - results['items'] | length == 0
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
- name: delete a cluster that does not exist - name: delete a cluster that does not exist
gcp_container_cluster: gcp_container_cluster:
@ -128,7 +128,7 @@
node_config: node_config:
machine_type: n1-standard-4 machine_type: n1-standard-4
disk_size_gb: 500 disk_size_gb: 500
location: us-central1-a zone: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"

View file

@ -28,7 +28,7 @@
name: my-pool name: my-pool
initial_node_count: 4 initial_node_count: 4
cluster: "{{ cluster }}" cluster: "{{ cluster }}"
location: us-central1-a zone: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
@ -39,7 +39,7 @@
name: my-pool name: my-pool
initial_node_count: 4 initial_node_count: 4
cluster: "{{ cluster }}" cluster: "{{ cluster }}"
location: us-central1-a zone: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
@ -51,8 +51,6 @@
- result.changed == true - result.changed == true
- name: verify that node_pool was created - name: verify that node_pool was created
gcp_container_node_pool_facts: gcp_container_node_pool_facts:
filters:
- name = {{ resource_name }}
cluster: "{{ cluster }}" cluster: "{{ cluster }}"
zone: us-central1-a zone: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
@ -64,14 +62,14 @@
- name: verify that command succeeded - name: verify that command succeeded
assert: assert:
that: that:
- "'my-pool' in \"{{ results['items'] | map(attribute='name') | list }}\"" - results['items'] | length >= 1
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
- name: create a node pool that already exists - name: create a node pool that already exists
gcp_container_node_pool: gcp_container_node_pool:
name: my-pool name: my-pool
initial_node_count: 4 initial_node_count: 4
cluster: "{{ cluster }}" cluster: "{{ cluster }}"
location: us-central1-a zone: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
@ -87,7 +85,7 @@
name: my-pool name: my-pool
initial_node_count: 4 initial_node_count: 4
cluster: "{{ cluster }}" cluster: "{{ cluster }}"
location: us-central1-a zone: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"
@ -99,8 +97,6 @@
- result.changed == true - result.changed == true
- name: verify that node_pool was deleted - name: verify that node_pool was deleted
gcp_container_node_pool_facts: gcp_container_node_pool_facts:
filters:
- name = {{ resource_name }}
cluster: "{{ cluster }}" cluster: "{{ cluster }}"
zone: us-central1-a zone: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
@ -119,7 +115,7 @@
name: my-pool name: my-pool
initial_node_count: 4 initial_node_count: 4
cluster: "{{ cluster }}" cluster: "{{ cluster }}"
location: us-central1-a zone: us-central1-a
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}" service_account_file: "{{ gcp_cred_file }}"

View file

@ -56,7 +56,7 @@
- name: verify that command succeeded - name: verify that command succeeded
assert: assert:
that: that:
- results['items'] | length == 1 - results['items'] | length >= 1
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
- name: create a subscription that already exists - name: create a subscription that already exists
gcp_pubsub_subscription: gcp_pubsub_subscription:

View file

@ -44,7 +44,7 @@
- name: verify that command succeeded - name: verify that command succeeded
assert: assert:
that: that:
- results['items'] | length == 1 - results['items'] | length >= 1
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
- name: create a topic that already exists - name: create a topic that already exists
gcp_pubsub_topic: gcp_pubsub_topic:

View file

@ -60,7 +60,7 @@
- name: verify that command succeeded - name: verify that command succeeded
assert: assert:
that: that:
- "'webstore' in \"{{ results['items'] | map(attribute='name') | list }}\"" - results['items'] | length >= 1
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
- name: create a database that already exists - name: create a database that already exists
gcp_spanner_database: gcp_spanner_database:
@ -101,7 +101,7 @@
- name: verify that command succeeded - name: verify that command succeeded
assert: assert:
that: that:
- "'webstore' not in \"{{ results['items'] | map(attribute='name') | list }}\"" - results['items'] | length == 0
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
- name: delete a database that does not exist - name: delete a database that does not exist
gcp_spanner_database: gcp_spanner_database:

View file

@ -54,7 +54,7 @@
- name: verify that command succeeded - name: verify that command succeeded
assert: assert:
that: that:
- "\"{{resource_name}}\" in \"{{ results['items'] | map(attribute='name') | list }}\"" - results['items'] | length >= 1
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
- name: create a instance that already exists - name: create a instance that already exists
gcp_spanner_instance: gcp_spanner_instance:
@ -102,7 +102,7 @@
- name: verify that command succeeded - name: verify that command succeeded
assert: assert:
that: that:
- "\"{{resource_name}}\" not in \"{{ results['items'] | map(attribute='name') | list }}\"" - results['items'] | length == 0
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
- name: delete a instance that does not exist - name: delete a instance that does not exist
gcp_spanner_instance: gcp_spanner_instance:

View file

@ -65,7 +65,7 @@
- name: verify that command succeeded - name: verify that command succeeded
assert: assert:
that: that:
- "\"{{resource_name}}\" in \"{{ results['items'] | map(attribute='name') | list }}\"" - results['items'] | length >= 1
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
- name: create a database that already exists - name: create a database that already exists
gcp_sql_database: gcp_sql_database:
@ -110,7 +110,7 @@
- name: verify that command succeeded - name: verify that command succeeded
assert: assert:
that: that:
- "\"{{resource_name}}\" not in \"{{ results['items'] | map(attribute='name') | list }}\"" - results['items'] | length == 0
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
- name: delete a database that does not exist - name: delete a database that does not exist
gcp_sql_database: gcp_sql_database:

View file

@ -59,7 +59,7 @@
- name: verify that command succeeded - name: verify that command succeeded
assert: assert:
that: that:
- results['resources'] | length >= 1 - results['items'] | length >= 1
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
- name: create a instance that already exists - name: create a instance that already exists
gcp_sql_instance: gcp_sql_instance:
@ -113,7 +113,7 @@
- name: verify that command succeeded - name: verify that command succeeded
assert: assert:
that: that:
- results['resources'] | length == 0 - results['items'] | length == 0
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
- name: delete a instance that does not exist - name: delete a instance that does not exist
gcp_sql_instance: gcp_sql_instance:

View file

@ -57,8 +57,6 @@
- "result.kind == 'sql#user'" - "result.kind == 'sql#user'"
- name: verify that user was created - name: verify that user was created
gcp_sql_user_facts: gcp_sql_user_facts:
filters:
- name = test-user
instance: "{{ instance }}" instance: "{{ instance }}"
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"
@ -69,7 +67,7 @@
- name: verify that command succeeded - name: verify that command succeeded
assert: assert:
that: that:
- "'test-user' in \"{{ results['items'] | map(attribute='name') | list }}\"" - results['items'] | length >= 1
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
- name: create a user that already exists - name: create a user that already exists
gcp_sql_user: gcp_sql_user:
@ -106,8 +104,6 @@
- result.has_key('kind') == False - result.has_key('kind') == False
- name: verify that user was deleted - name: verify that user was deleted
gcp_sql_user_facts: gcp_sql_user_facts:
filters:
- name = test-user
instance: "{{ instance }}" instance: "{{ instance }}"
project: "{{ gcp_project }}" project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}" auth_kind: "{{ gcp_cred_kind }}"