Bug fixes for GCP modules (#53879)

This commit is contained in:
The Magician 2019-03-15 14:38:27 -07:00 committed by ansibot
parent e8e69bf069
commit b429ba61dc
33 changed files with 1093 additions and 1091 deletions

View file

@ -49,13 +49,14 @@ extends_documentation_fragment: gcp
'''
EXAMPLES = '''
- name: a health check facts
- name: " a health check facts"
gcp_compute_health_check_facts:
filters:
- name = test_object
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: facts
'''
RETURN = '''

View file

@ -105,20 +105,20 @@ options:
required: false
extends_documentation_fragment: gcp
notes:
- 'API Reference: U(https://cloud.google.com/compute/docs/reference/latest/httpHealthChecks)'
- 'API Reference: U(https://cloud.google.com/compute/docs/reference/v1/httpHealthChecks)'
- 'Adding Health Checks: U(https://cloud.google.com/compute/docs/load-balancing/health-checks#legacy_health_checks)'
'''
EXAMPLES = '''
- name: create a http health check
gcp_compute_http_health_check:
name: "test_object"
name: test_object
healthy_threshold: 10
port: 8080
timeout_sec: 2
unhealthy_threshold: 5
project: "test_project"
auth_kind: "serviceaccount"
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: present
'''

View file

@ -49,13 +49,14 @@ extends_documentation_fragment: gcp
'''
EXAMPLES = '''
- name: a http health check facts
- name: " a http health check facts"
gcp_compute_http_health_check_facts:
filters:
- name = test_object
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: facts
'''
RETURN = '''

View file

@ -102,20 +102,20 @@ options:
required: false
extends_documentation_fragment: gcp
notes:
- 'API Reference: U(https://cloud.google.com/compute/docs/reference/latest/httpsHealthChecks)'
- 'API Reference: U(https://cloud.google.com/compute/docs/reference/v1/httpsHealthChecks)'
- 'Adding Health Checks: U(https://cloud.google.com/compute/docs/load-balancing/health-checks#legacy_health_checks)'
'''
EXAMPLES = '''
- name: create a https health check
gcp_compute_https_health_check:
name: "test_object"
name: test_object
healthy_threshold: 10
port: 8080
timeout_sec: 2
unhealthy_threshold: 5
project: "test_project"
auth_kind: "serviceaccount"
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: present
'''

View file

@ -49,13 +49,14 @@ extends_documentation_fragment: gcp
'''
EXAMPLES = '''
- name: a https health check facts
- name: " a https health check facts"
gcp_compute_https_health_check_facts:
filters:
- name = test_object
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: facts
'''
RETURN = '''

View file

@ -106,11 +106,6 @@ options:
- Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
base64 to either encrypt or decrypt this resource.
required: false
sha256:
description:
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
key that protects this resource.
required: false
labels:
description:
- Labels to apply to this Image.
@ -173,11 +168,6 @@ options:
- Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
base64 to either encrypt or decrypt this resource.
required: false
sha256:
description:
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
key that protects this resource.
required: false
source_disk_id:
description:
- The ID value of the disk used to create this image. This value may be used to
@ -193,14 +183,14 @@ options:
- RAW
extends_documentation_fragment: gcp
notes:
- 'API Reference: U(https://cloud.google.com/compute/docs/reference/latest/images)'
- 'API Reference: U(https://cloud.google.com/compute/docs/reference/v1/images)'
- 'Official Documentation: U(https://cloud.google.com/compute/docs/images)'
'''
EXAMPLES = '''
- name: create a disk
gcp_compute_disk:
name: "disk-image"
name: disk-image
zone: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
@ -210,10 +200,10 @@ EXAMPLES = '''
- name: create a image
gcp_compute_image:
name: "test_object"
name: test_object
source_disk: "{{ disk }}"
project: "test_project"
auth_kind: "serviceaccount"
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: present
'''
@ -453,7 +443,7 @@ def main():
disk_size_gb=dict(type='int'),
family=dict(type='str'),
guest_os_features=dict(type='list', elements='dict', options=dict(type=dict(type='str', choices=['VIRTIO_SCSI_MULTIQUEUE']))),
image_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'), sha256=dict(type='str'))),
image_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'))),
labels=dict(type='dict'),
licenses=dict(type='list', elements='str'),
name=dict(required=True, type='str'),
@ -462,7 +452,7 @@ def main():
options=dict(container_type=dict(type='str', choices=['TAR']), sha1_checksum=dict(type='str'), source=dict(required=True, type='str')),
),
source_disk=dict(),
source_disk_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'), sha256=dict(type='str'))),
source_disk_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'))),
source_disk_id=dict(type='str'),
source_type=dict(type='str', choices=['RAW']),
)

View file

@ -49,13 +49,14 @@ extends_documentation_fragment: gcp
'''
EXAMPLES = '''
- name: a image facts
- name: " a image facts"
gcp_compute_image_facts:
filters:
- name = test_object
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: facts
'''
RETURN = '''

View file

@ -98,11 +98,6 @@ options:
- Specifies an RFC 4648 base64 encoded, RSA-wrapped 2048-bit customer-supplied
encryption key to either encrypt or decrypt this resource.
required: false
sha256:
description:
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
key that protects this resource.
required: false
index:
description:
- Assigns a zero-based index to this disk, where 0 is reserved for the boot
@ -156,11 +151,6 @@ options:
- Specifies a 256-bit customer-supplied encryption key, encoded in
RFC 4648 base64 to either encrypt or decrypt this resource.
required: false
sha256:
description:
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied
encryption key that protects this resource.
required: false
interface:
description:
- Specifies the disk interface to use for attaching this disk, which is either
@ -302,11 +292,6 @@ options:
from which to allocate the IP CIDR range for this alias IP range. If
left unspecified, the primary range of the subnetwork will be used.
required: false
name:
description:
- The name of the network interface, generated by the server. For network
devices, these are eth0, eth1, etc .
required: false
network:
description:
- Specifies the title of an existing network. When creating an instance, if
@ -424,7 +409,7 @@ extends_documentation_fragment: gcp
EXAMPLES = '''
- name: create a disk
gcp_compute_disk:
name: "disk-instance"
name: disk-instance
size_gb: 50
source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
zone: us-central1-a
@ -436,7 +421,7 @@ EXAMPLES = '''
- name: create a network
gcp_compute_network:
name: "network-instance"
name: network-instance
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
@ -445,7 +430,7 @@ EXAMPLES = '''
- name: create a address
gcp_compute_address:
name: "address-instance"
name: address-instance
region: us-central1
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
@ -455,11 +440,11 @@ EXAMPLES = '''
- name: create a instance
gcp_compute_instance:
name: "test_object"
name: test_object
machine_type: n1-standard-1
disks:
- auto_delete: true
boot: true
- auto_delete: 'true'
boot: 'true'
source: "{{ disk }}"
metadata:
startup-script-url: gs:://graphite-playground/bootstrap.sh
@ -471,8 +456,8 @@ EXAMPLES = '''
nat_ip: "{{ address }}"
type: ONE_TO_ONE_NAT
zone: us-central1-a
project: "test_project"
auth_kind: "serviceaccount"
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: present
'''
@ -902,7 +887,7 @@ def main():
auto_delete=dict(type='bool'),
boot=dict(type='bool'),
device_name=dict(type='str'),
disk_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'), rsa_encrypted_key=dict(type='str'), sha256=dict(type='str'))),
disk_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'), rsa_encrypted_key=dict(type='str'))),
index=dict(type='int'),
initialize_params=dict(
type='dict',
@ -911,7 +896,7 @@ def main():
disk_size_gb=dict(type='int'),
disk_type=dict(type='str'),
source_image=dict(type='str', aliases=['image', 'image_family']),
source_image_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'), sha256=dict(type='str'))),
source_image_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'))),
),
),
interface=dict(type='str', choices=['SCSI', 'NVME']),
@ -936,7 +921,6 @@ def main():
options=dict(name=dict(required=True, type='str'), nat_ip=dict(), type=dict(required=True, type='str', choices=['ONE_TO_ONE_NAT'])),
),
alias_ip_ranges=dict(type='list', elements='dict', options=dict(ip_cidr_range=dict(type='str'), subnetwork_range_name=dict(type='str'))),
name=dict(type='str'),
network=dict(),
network_ip=dict(type='str'),
subnetwork=dict(),

View file

@ -53,7 +53,7 @@ extends_documentation_fragment: gcp
'''
EXAMPLES = '''
- name: a instance facts
- name: " a instance facts"
gcp_compute_instance_facts:
zone: us-central1-a
filters:
@ -61,6 +61,7 @@ EXAMPLES = '''
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: facts
'''
RETURN = '''

View file

@ -118,7 +118,7 @@ extends_documentation_fragment: gcp
EXAMPLES = '''
- name: create a network
gcp_compute_network:
name: "network-instancegroup"
name: network-instancegroup
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
@ -127,14 +127,14 @@ EXAMPLES = '''
- name: create a instance group
gcp_compute_instance_group:
name: "test_object"
name: test_object
named_ports:
- name: ansible
port: 1234
network: "{{ network }}"
zone: us-central1-a
project: "test_project"
auth_kind: "serviceaccount"
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: present
'''

View file

@ -53,7 +53,7 @@ extends_documentation_fragment: gcp
'''
EXAMPLES = '''
- name: a instance group facts
- name: " a instance group facts"
gcp_compute_instance_group_facts:
zone: us-central1-a
filters:
@ -61,6 +61,7 @@ EXAMPLES = '''
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: facts
'''
RETURN = '''

View file

@ -117,7 +117,7 @@ extends_documentation_fragment: gcp
EXAMPLES = '''
- name: create a network
gcp_compute_network:
name: "network-instancetemplate"
name: network-instancetemplate
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
@ -126,7 +126,7 @@ EXAMPLES = '''
- name: create a address
gcp_compute_address:
name: "address-instancetemplate"
name: address-instancetemplate
region: us-west1
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
@ -139,8 +139,8 @@ EXAMPLES = '''
name: "{{ resource_name }}"
properties:
disks:
- auto_delete: true
boot: true
- auto_delete: 'true'
boot: 'true'
initialize_params:
source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
machine_type: n1-standard-1
@ -158,13 +158,13 @@ EXAMPLES = '''
- name: create a instance group manager
gcp_compute_instance_group_manager:
name: "test_object"
name: test_object
base_instance_name: test1-child
instance_template: "{{ instancetemplate }}"
target_size: 3
zone: us-west1-a
project: "test_project"
auth_kind: "serviceaccount"
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: present
'''

View file

@ -53,7 +53,7 @@ extends_documentation_fragment: gcp
'''
EXAMPLES = '''
- name: a instance group manager facts
- name: " a instance group manager facts"
gcp_compute_instance_group_manager_facts:
zone: us-west1-a
filters:
@ -61,6 +61,7 @@ EXAMPLES = '''
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: facts
'''
RETURN = '''

View file

@ -123,11 +123,6 @@ options:
- Specifies an RFC 4648 base64 encoded, RSA-wrapped 2048-bit customer-supplied
encryption key to either encrypt or decrypt this resource.
required: false
sha256:
description:
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied
encryption key that protects this resource.
required: false
index:
description:
- Assigns a zero-based index to this disk, where 0 is reserved for the
@ -179,11 +174,6 @@ options:
- Specifies a 256-bit customer-supplied encryption key, encoded
in RFC 4648 base64 to either encrypt or decrypt this resource.
required: false
sha256:
description:
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied
encryption key that protects this resource.
required: false
interface:
description:
- Specifies the disk interface to use for attaching this disk, which is
@ -315,11 +305,6 @@ options:
range. If left unspecified, the primary range of the subnetwork
will be used.
required: false
name:
description:
- The name of the network interface, generated by the server. For network
devices, these are eth0, eth1, etc .
required: false
network:
description:
- Specifies the title of an existing network. When creating an instance,
@ -418,7 +403,7 @@ extends_documentation_fragment: gcp
EXAMPLES = '''
- name: create a network
gcp_compute_network:
name: "network-instancetemplate"
name: network-instancetemplate
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
@ -427,7 +412,7 @@ EXAMPLES = '''
- name: create a address
gcp_compute_address:
name: "address-instancetemplate"
name: address-instancetemplate
region: us-west1
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
@ -437,11 +422,11 @@ EXAMPLES = '''
- name: create a instance template
gcp_compute_instance_template:
name: "test_object"
name: test_object
properties:
disks:
- auto_delete: true
boot: true
- auto_delete: 'true'
boot: 'true'
initialize_params:
source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
machine_type: n1-standard-1
@ -451,8 +436,8 @@ EXAMPLES = '''
- name: test-config
type: ONE_TO_ONE_NAT
nat_ip: "{{ address }}"
project: "test_project"
auth_kind: "serviceaccount"
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: present
'''
@ -878,9 +863,7 @@ def main():
auto_delete=dict(type='bool'),
boot=dict(type='bool'),
device_name=dict(type='str'),
disk_encryption_key=dict(
type='dict', options=dict(raw_key=dict(type='str'), rsa_encrypted_key=dict(type='str'), sha256=dict(type='str'))
),
disk_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'), rsa_encrypted_key=dict(type='str'))),
index=dict(type='int'),
initialize_params=dict(
type='dict',
@ -889,7 +872,7 @@ def main():
disk_size_gb=dict(type='int'),
disk_type=dict(type='str'),
source_image=dict(type='str'),
source_image_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'), sha256=dict(type='str'))),
source_image_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'))),
),
),
interface=dict(type='str', choices=['SCSI', 'NVME']),
@ -916,7 +899,6 @@ def main():
alias_ip_ranges=dict(
type='list', elements='dict', options=dict(ip_cidr_range=dict(type='str'), subnetwork_range_name=dict(type='str'))
),
name=dict(type='str'),
network=dict(),
network_ip=dict(type='str'),
subnetwork=dict(),

View file

@ -49,13 +49,14 @@ extends_documentation_fragment: gcp
'''
EXAMPLES = '''
- name: a instance template facts
- name: " a instance template facts"
gcp_compute_instance_template_facts:
filters:
- name = test_object
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: facts
'''
RETURN = '''

View file

@ -119,10 +119,10 @@ extends_documentation_fragment: gcp
EXAMPLES = '''
- name: create a interconnect attachment
gcp_compute_interconnect_attachment:
name: "test_object"
name: test_object
region: us-central1
project: "test_project"
auth_kind: "serviceaccount"
project: test_project
auth_kind: serviceaccount
interconnect: https://googleapis.com/compute/v1/projects/test_project/global/interconnects/...
router: https://googleapis.com/compute/v1/projects/test_project/regions/us-central1/routers/...
service_account_file: "/tmp/auth.pem"

View file

@ -53,7 +53,7 @@ extends_documentation_fragment: gcp
'''
EXAMPLES = '''
- name: a interconnect attachment facts
- name: " a interconnect attachment facts"
gcp_compute_interconnect_attachment_facts:
region: us-central1
filters:
@ -61,6 +61,7 @@ EXAMPLES = '''
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: facts
'''
RETURN = '''

View file

@ -31,18 +31,7 @@ DOCUMENTATION = '''
---
module: gcp_compute_network
description:
- Represents a Network resource.
- Your Cloud Platform Console project can contain multiple networks, and each network
can have multiple instances attached to it. A network allows you to define a gateway
IP and the network range for the instances attached to that network. Every project
is provided with a default network with preset configurations and firewall rules.
You can choose to customize the default network by adding or removing rules, or
you can create new networks in that project. Generally, most users only need one
network, although you can have up to five networks per project by default.
- A network belongs to only one project, and each instance can only belong to one
network. All Compute Engine networks use the IPv4 protocol. Compute Engine currently
does not support IPv6. However, Google is a major advocate of IPv6 and it is an
important future direction.
- Manages a VPC network or legacy network resource on GCP.
short_description: Creates a GCP Network
version_added: 2.6
author: Google Inc. (@googlecloudplatform)
@ -60,14 +49,18 @@ options:
default: present
description:
description:
- An optional description of this resource. Provide this property when you create
the resource.
- An optional description of this resource. The resource must be recreated to
modify this field.
required: false
ipv4_range:
description:
- 'The range of internal addresses that are legal on this network. This range
is a CIDR specification, for example: 192.168.0.0/16. Provided by the client
when the network is created.'
- If this field is specified, a deprecated legacy network is created.
- You will no longer be able to create a legacy network on Feb 1, 2020.
- See the [legacy network docs](U(https://cloud.google.com/vpc/docs/legacy)) for
more details.
- The range of internal addresses that are legal on this legacy network.
- 'This range is a CIDR specification, for example: `192.168.0.0/16`.'
- The resource must be recreated to modify this field.
required: false
name:
description:
@ -80,10 +73,11 @@ options:
required: true
auto_create_subnetworks:
description:
- When set to true, the network is created in "auto subnet mode". When set to
false, the network is in "custom subnet mode".
- In "auto subnet mode", a newly created network is assigned the default CIDR
of 10.128.0.0/9 and it automatically creates one subnetwork per region.
- When set to `true`, the network is created in "auto subnet mode" and it will
create a subnet for each region automatically across the `10.128.0.0/9` address
range.
- When set to `false`, the network is created in "custom subnet mode" so the user
can explicitly connect subnetwork resources.
required: false
type: bool
routing_config:
@ -95,9 +89,9 @@ options:
suboptions:
routing_mode:
description:
- The network-wide routing mode to use. If set to REGIONAL, this network's
- The network-wide routing mode to use. If set to `REGIONAL`, this network's
cloud routers will only advertise routes with subnetworks of this network
in the same region as the router. If set to GLOBAL, this network's cloud
in the same region as the router. If set to `GLOBAL`, this network's cloud
routers will advertise routes with all subnetworks of this network, across
regions.
required: true
@ -113,10 +107,10 @@ notes:
EXAMPLES = '''
- name: create a network
gcp_compute_network:
name: "test_object"
auto_create_subnetworks: true
project: "test_project"
auth_kind: "serviceaccount"
name: test_object
auto_create_subnetworks: 'true'
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: present
'''
@ -124,15 +118,14 @@ EXAMPLES = '''
RETURN = '''
description:
description:
- An optional description of this resource. Provide this property when you create
the resource.
- An optional description of this resource. The resource must be recreated to modify
this field.
returned: success
type: str
gateway_ipv4:
description:
- A gateway address for default routing to other networks. This value is read only
and is selected by the Google Compute Engine, typically as the first usable address
in the IPv4Range.
- The gateway address for default routing out of the network. This value is selected
by GCP.
returned: success
type: str
id:
@ -142,9 +135,13 @@ id:
type: int
ipv4_range:
description:
- 'The range of internal addresses that are legal on this network. This range is
a CIDR specification, for example: 192.168.0.0/16. Provided by the client when
the network is created.'
- If this field is specified, a deprecated legacy network is created.
- You will no longer be able to create a legacy network on Feb 1, 2020.
- See the [legacy network docs](U(https://cloud.google.com/vpc/docs/legacy)) for
more details.
- The range of internal addresses that are legal on this legacy network.
- 'This range is a CIDR specification, for example: `192.168.0.0/16`.'
- The resource must be recreated to modify this field.
returned: success
type: str
name:
@ -164,10 +161,10 @@ subnetworks:
type: list
autoCreateSubnetworks:
description:
- When set to true, the network is created in "auto subnet mode". When set to false,
the network is in "custom subnet mode".
- In "auto subnet mode", a newly created network is assigned the default CIDR of
10.128.0.0/9 and it automatically creates one subnetwork per region.
- When set to `true`, the network is created in "auto subnet mode" and it will create
a subnet for each region automatically across the `10.128.0.0/9` address range.
- When set to `false`, the network is created in "custom subnet mode" so the user
can explicitly connect subnetwork resources.
returned: success
type: bool
creationTimestamp:
@ -184,10 +181,11 @@ routingConfig:
contains:
routingMode:
description:
- The network-wide routing mode to use. If set to REGIONAL, this network's cloud
routers will only advertise routes with subnetworks of this network in the
same region as the router. If set to GLOBAL, this network's cloud routers
will advertise routes with all subnetworks of this network, across regions.
- The network-wide routing mode to use. If set to `REGIONAL`, this network's
cloud routers will only advertise routes with subnetworks of this network
in the same region as the router. If set to `GLOBAL`, this network's cloud
routers will advertise routes with all subnetworks of this network, across
regions.
returned: success
type: str
'''
@ -232,7 +230,7 @@ def main():
if fetch:
if state == 'present':
if is_different(module, fetch):
update(module, self_link(module), kind)
update(module, self_link(module), kind, fetch)
fetch = fetch_resource(module, self_link(module), kind)
changed = True
else:
@ -256,9 +254,22 @@ def create(module, link, kind):
return wait_for_operation(module, auth.post(link, resource_to_request(module)))
def update(module, link, kind):
def update(module, link, kind, fetch):
update_fields(module, resource_to_request(module), response_to_hash(module, fetch))
return fetch_resource(module, self_link(module), kind)
def update_fields(module, request, response):
if response.get('routingConfig') != request.get('routingConfig'):
routing_config_update(module, request, response)
def routing_config_update(module, request, response):
auth = GcpSession(module, 'compute')
return wait_for_operation(module, auth.patch(link, resource_to_request(module)))
auth.patch(
''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/global/networks/{name}"]).format(**module.params),
{u'routingConfig': NetworkRoutingconfig(module.params.get('routing_config', {}), module).to_request()},
)
def delete(module, link, kind):

View file

@ -49,13 +49,14 @@ extends_documentation_fragment: gcp
'''
EXAMPLES = '''
- name: a network facts
- name: " a network facts"
gcp_compute_network_facts:
filters:
- name = test_object
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: facts
'''
RETURN = '''
@ -66,15 +67,14 @@ items:
contains:
description:
description:
- An optional description of this resource. Provide this property when you create
the resource.
- An optional description of this resource. The resource must be recreated to
modify this field.
returned: success
type: str
gateway_ipv4:
description:
- A gateway address for default routing to other networks. This value is read
only and is selected by the Google Compute Engine, typically as the first
usable address in the IPv4Range.
- The gateway address for default routing out of the network. This value is
selected by GCP.
returned: success
type: str
id:
@ -84,9 +84,13 @@ items:
type: int
ipv4_range:
description:
- 'The range of internal addresses that are legal on this network. This range
is a CIDR specification, for example: 192.168.0.0/16. Provided by the client
when the network is created.'
- If this field is specified, a deprecated legacy network is created.
- You will no longer be able to create a legacy network on Feb 1, 2020.
- See the [legacy network docs](U(https://cloud.google.com/vpc/docs/legacy))
for more details.
- The range of internal addresses that are legal on this legacy network.
- 'This range is a CIDR specification, for example: `192.168.0.0/16`.'
- The resource must be recreated to modify this field.
returned: success
type: str
name:
@ -106,10 +110,11 @@ items:
type: list
autoCreateSubnetworks:
description:
- When set to true, the network is created in "auto subnet mode". When set to
false, the network is in "custom subnet mode".
- In "auto subnet mode", a newly created network is assigned the default CIDR
of 10.128.0.0/9 and it automatically creates one subnetwork per region.
- When set to `true`, the network is created in "auto subnet mode" and it will
create a subnet for each region automatically across the `10.128.0.0/9` address
range.
- When set to `false`, the network is created in "custom subnet mode" so the
user can explicitly connect subnetwork resources.
returned: success
type: bool
creationTimestamp:
@ -126,9 +131,9 @@ items:
contains:
routingMode:
description:
- The network-wide routing mode to use. If set to REGIONAL, this network's
- The network-wide routing mode to use. If set to `REGIONAL`, this network's
cloud routers will only advertise routes with subnetworks of this network
in the same region as the router. If set to GLOBAL, this network's cloud
in the same region as the router. If set to `GLOBAL`, this network's cloud
routers will advertise routes with all subnetworks of this network, across
regions.
returned: success

View file

@ -88,6 +88,14 @@ options:
of sizeGb must not be less than the size of the sourceImage or the size of the
snapshot.
required: false
physical_block_size_bytes:
description:
- Physical block size of the persistent disk, in bytes. If not present in a request,
a default value is used. Currently supported sizes are 4096 and 16384, other
sizes may be added in the future.
- If an unsupported value is requested, the error message will list the supported
values for the caller's project.
required: false
replica_zones:
description:
- URLs of the zones where the disk should be replicated to.
@ -118,11 +126,6 @@ options:
- Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
base64 to either encrypt or decrypt this resource.
required: false
sha256:
description:
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
key that protects this resource.
required: false
source_snapshot:
description:
- The source snapshot used to create this disk. You can provide this as a partial
@ -143,11 +146,6 @@ options:
- Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
base64 to either encrypt or decrypt this resource.
required: false
sha256:
description:
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
key that protects this resource.
required: false
extends_documentation_fragment: gcp
notes:
- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/beta/regionDisks)'
@ -157,7 +155,7 @@ notes:
EXAMPLES = '''
- name: create a region disk
gcp_compute_region_disk:
name: "test_object"
name: test_object
size_gb: 50
disk_encryption_key:
raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0=
@ -165,8 +163,8 @@ EXAMPLES = '''
replica_zones:
- https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-a
- https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-b
project: "test_project"
auth_kind: "serviceaccount"
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: present
'''
@ -240,6 +238,15 @@ users:
.'
returned: success
type: list
physicalBlockSizeBytes:
description:
- Physical block size of the persistent disk, in bytes. If not present in a request,
a default value is used. Currently supported sizes are 4096 and 16384, other sizes
may be added in the future.
- If an unsupported value is requested, the error message will list the supported
values for the caller's project.
returned: success
type: int
replicaZones:
description:
- URLs of the zones where the disk should be replicated to.
@ -342,12 +349,13 @@ def main():
licenses=dict(type='list', elements='str'),
name=dict(required=True, type='str'),
size_gb=dict(type='int'),
physical_block_size_bytes=dict(type='int'),
replica_zones=dict(required=True, type='list', elements='str'),
type=dict(type='str'),
region=dict(required=True, type='str'),
disk_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'), sha256=dict(type='str'))),
disk_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'))),
source_snapshot=dict(),
source_snapshot_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'), sha256=dict(type='str'))),
source_snapshot_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'))),
)
)
@ -430,6 +438,7 @@ def resource_to_request(module):
u'licenses': module.params.get('licenses'),
u'name': module.params.get('name'),
u'sizeGb': module.params.get('size_gb'),
u'physicalBlockSizeBytes': module.params.get('physical_block_size_bytes'),
u'replicaZones': module.params.get('replica_zones'),
u'type': region_disk_type_selflink(module.params.get('type'), module.params),
}
@ -508,6 +517,7 @@ def response_to_hash(module, response):
u'name': module.params.get('name'),
u'sizeGb': response.get(u'sizeGb'),
u'users': response.get(u'users'),
u'physicalBlockSizeBytes': response.get(u'physicalBlockSizeBytes'),
u'replicaZones': response.get(u'replicaZones'),
u'type': response.get(u'type'),
}

View file

@ -53,7 +53,7 @@ extends_documentation_fragment: gcp
'''
EXAMPLES = '''
- name: a region disk facts
- name: " a region disk facts"
gcp_compute_region_disk_facts:
region: us-central1
filters:
@ -61,6 +61,7 @@ EXAMPLES = '''
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: facts
'''
RETURN = '''
@ -137,6 +138,15 @@ items:
.'
returned: success
type: list
physicalBlockSizeBytes:
description:
- Physical block size of the persistent disk, in bytes. If not present in a
request, a default value is used. Currently supported sizes are 4096 and 16384,
other sizes may be added in the future.
- If an unsupported value is requested, the error message will list the supported
values for the caller's project.
returned: success
type: int
replicaZones:
description:
- URLs of the zones where the disk should be replicated to.

View file

@ -142,7 +142,7 @@ notes:
EXAMPLES = '''
- name: create a network
gcp_compute_network:
name: "network-route"
name: network-route
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
@ -151,15 +151,15 @@ EXAMPLES = '''
- name: create a route
gcp_compute_route:
name: "test_object"
name: test_object
dest_range: 192.168.6.0/24
next_hop_gateway: global/gateways/default-internet-gateway
network: "{{ network }}"
tags:
- backends
- databases
project: "test_project"
auth_kind: "serviceaccount"
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: present
'''

View file

@ -49,13 +49,14 @@ extends_documentation_fragment: gcp
'''
EXAMPLES = '''
- name: a route facts
- name: " a route facts"
gcp_compute_route_facts:
filters:
- name = test_object
project: test_project
auth_kind: serviceaccount
service_account_file: "/tmp/auth.pem"
state: facts
'''
RETURN = '''

View file

@ -15,7 +15,7 @@
# Pre-test setup
- name: create a disk
gcp_compute_disk:
name: "disk-image"
name: disk-image
zone: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
@ -123,7 +123,7 @@
# If errors happen, don't crash the playbook!
- name: delete a disk
gcp_compute_disk:
name: "disk-image"
name: disk-image
zone: us-central1-a
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"

View file

@ -15,7 +15,7 @@
# Pre-test setup
- name: create a disk
gcp_compute_disk:
name: "disk-instance"
name: disk-instance
size_gb: 50
source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
zone: us-central1-a
@ -26,7 +26,7 @@
register: disk
- name: create a network
gcp_compute_network:
name: "network-instance"
name: network-instance
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
@ -34,7 +34,7 @@
register: network
- name: create a address
gcp_compute_address:
name: "address-instance"
name: address-instance
region: us-central1
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
@ -46,8 +46,8 @@
name: "{{ resource_name }}"
machine_type: n1-standard-1
disks:
- auto_delete: true
boot: true
- auto_delete: 'true'
boot: 'true'
source: "{{ disk }}"
metadata:
startup-script-url: gs:://graphite-playground/bootstrap.sh
@ -69,8 +69,8 @@
name: "{{ resource_name }}"
machine_type: n1-standard-1
disks:
- auto_delete: true
boot: true
- auto_delete: 'true'
boot: 'true'
source: "{{ disk }}"
metadata:
startup-script-url: gs:://graphite-playground/bootstrap.sh
@ -113,8 +113,8 @@
name: "{{ resource_name }}"
machine_type: n1-standard-1
disks:
- auto_delete: true
boot: true
- auto_delete: 'true'
boot: 'true'
source: "{{ disk }}"
metadata:
startup-script-url: gs:://graphite-playground/bootstrap.sh
@ -142,8 +142,8 @@
name: "{{ resource_name }}"
machine_type: n1-standard-1
disks:
- auto_delete: true
boot: true
- auto_delete: 'true'
boot: 'true'
source: "{{ disk }}"
metadata:
startup-script-url: gs:://graphite-playground/bootstrap.sh
@ -186,8 +186,8 @@
name: "{{ resource_name }}"
machine_type: n1-standard-1
disks:
- auto_delete: true
boot: true
- auto_delete: 'true'
boot: 'true'
source: "{{ disk }}"
metadata:
startup-script-url: gs:://graphite-playground/bootstrap.sh
@ -214,7 +214,7 @@
# If errors happen, don't crash the playbook!
- name: delete a address
gcp_compute_address:
name: "address-instance"
name: address-instance
region: us-central1
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
@ -224,7 +224,7 @@
ignore_errors: true
- name: delete a network
gcp_compute_network:
name: "network-instance"
name: network-instance
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
@ -233,7 +233,7 @@
ignore_errors: true
- name: delete a disk
gcp_compute_disk:
name: "disk-instance"
name: disk-instance
size_gb: 50
source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
zone: us-central1-a

View file

@ -15,7 +15,7 @@
# Pre-test setup
- name: create a network
gcp_compute_network:
name: "network-instancegroup"
name: network-instancegroup
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
@ -144,7 +144,7 @@
# If errors happen, don't crash the playbook!
- name: delete a network
gcp_compute_network:
name: "network-instancegroup"
name: network-instancegroup
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"

View file

@ -15,7 +15,7 @@
# Pre-test setup
- name: create a network
gcp_compute_network:
name: "network-instancetemplate"
name: network-instancetemplate
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
@ -23,7 +23,7 @@
register: network
- name: create a address
gcp_compute_address:
name: "address-instancetemplate"
name: address-instancetemplate
region: us-west1
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
@ -35,8 +35,8 @@
name: "{{ resource_name }}"
properties:
disks:
- auto_delete: true
boot: true
- auto_delete: 'true'
boot: 'true'
initialize_params:
source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
machine_type: n1-standard-1
@ -172,8 +172,8 @@
name: "{{ resource_name }}"
properties:
disks:
- auto_delete: true
boot: true
- auto_delete: 'true'
boot: 'true'
initialize_params:
source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
machine_type: n1-standard-1
@ -191,7 +191,7 @@
ignore_errors: true
- name: delete a address
gcp_compute_address:
name: "address-instancetemplate"
name: address-instancetemplate
region: us-west1
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
@ -201,7 +201,7 @@
ignore_errors: true
- name: delete a network
gcp_compute_network:
name: "network-instancetemplate"
name: network-instancetemplate
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"

View file

@ -15,7 +15,7 @@
# Pre-test setup
- name: create a network
gcp_compute_network:
name: "network-instancetemplate"
name: network-instancetemplate
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
@ -23,7 +23,7 @@
register: network
- name: create a address
gcp_compute_address:
name: "address-instancetemplate"
name: address-instancetemplate
region: us-west1
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
@ -35,8 +35,8 @@
name: "{{ resource_name }}"
properties:
disks:
- auto_delete: true
boot: true
- auto_delete: 'true'
boot: 'true'
initialize_params:
source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
machine_type: n1-standard-1
@ -56,8 +56,8 @@
name: "{{ resource_name }}"
properties:
disks:
- auto_delete: true
boot: true
- auto_delete: 'true'
boot: 'true'
initialize_params:
source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
machine_type: n1-standard-1
@ -97,8 +97,8 @@
name: "{{ resource_name }}"
properties:
disks:
- auto_delete: true
boot: true
- auto_delete: 'true'
boot: 'true'
initialize_params:
source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
machine_type: n1-standard-1
@ -124,8 +124,8 @@
name: "{{ resource_name }}"
properties:
disks:
- auto_delete: true
boot: true
- auto_delete: 'true'
boot: 'true'
initialize_params:
source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
machine_type: n1-standard-1
@ -165,8 +165,8 @@
name: "{{ resource_name }}"
properties:
disks:
- auto_delete: true
boot: true
- auto_delete: 'true'
boot: 'true'
initialize_params:
source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
machine_type: n1-standard-1
@ -191,7 +191,7 @@
# If errors happen, don't crash the playbook!
- name: delete a address
gcp_compute_address:
name: "address-instancetemplate"
name: address-instancetemplate
region: us-west1
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
@ -201,7 +201,7 @@
ignore_errors: true
- name: delete a network
gcp_compute_network:
name: "network-instancetemplate"
name: network-instancetemplate
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"

View file

@ -16,7 +16,7 @@
- name: delete a network
gcp_compute_network:
name: "{{ resource_name }}"
auto_create_subnetworks: true
auto_create_subnetworks: 'true'
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
@ -25,7 +25,7 @@
- name: create a network
gcp_compute_network:
name: "{{ resource_name }}"
auto_create_subnetworks: true
auto_create_subnetworks: 'true'
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
@ -54,7 +54,7 @@
- name: create a network that already exists
gcp_compute_network:
name: "{{ resource_name }}"
auto_create_subnetworks: true
auto_create_subnetworks: 'true'
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
@ -69,7 +69,7 @@
- name: delete a network
gcp_compute_network:
name: "{{ resource_name }}"
auto_create_subnetworks: true
auto_create_subnetworks: 'true'
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
@ -98,7 +98,7 @@
- name: delete a network that does not exist
gcp_compute_network:
name: "{{ resource_name }}"
auto_create_subnetworks: true
auto_create_subnetworks: 'true'
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"

View file

@ -15,7 +15,7 @@
# Pre-test setup
- name: create a network
gcp_compute_network:
name: "network-route"
name: network-route
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
@ -147,7 +147,7 @@
# If errors happen, don't crash the playbook!
- name: delete a network
gcp_compute_network:
name: "network-route"
name: network-route
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"