mirror of
https://github.com/ansible-collections/google.cloud.git
synced 2025-04-07 11:20:28 -07:00
Add sslPolicy to a few resources.
This commit is contained in:
parent
72cc27fec1
commit
7655f34bc6
4 changed files with 88 additions and 6 deletions
|
@ -80,6 +80,18 @@ options:
|
||||||
between users and the load balancer. Currently, exactly one SSL certificate
|
between users and the load balancer. Currently, exactly one SSL certificate
|
||||||
must be specified.
|
must be specified.
|
||||||
required: true
|
required: true
|
||||||
|
ssl_policy:
|
||||||
|
description:
|
||||||
|
- A reference to the SslPolicy resource that will be associated with the TargetHttpsProxy
|
||||||
|
resource. If not set, the TargetHttpsProxy resource will not have any SSL policy
|
||||||
|
configured.
|
||||||
|
- 'This field represents a link to a SslPolicy resource in GCP. It can be specified
|
||||||
|
in two ways. You can add `register: name-of-resource` to a gcp_compute_ssl_policy
|
||||||
|
task and then set this ssl_policy field to "{{ name-of-resource }}" Alternatively,
|
||||||
|
you can set this ssl_policy to a dictionary with the selfLink key where the
|
||||||
|
value is the selfLink of your SslPolicy'
|
||||||
|
required: false
|
||||||
|
version_added: 2.8
|
||||||
url_map:
|
url_map:
|
||||||
description:
|
description:
|
||||||
- A reference to the UrlMap resource that defines the mapping from URL to the
|
- A reference to the UrlMap resource that defines the mapping from URL to the
|
||||||
|
@ -219,6 +231,13 @@ sslCertificates:
|
||||||
users and the load balancer. Currently, exactly one SSL certificate must be specified.
|
users and the load balancer. Currently, exactly one SSL certificate must be specified.
|
||||||
returned: success
|
returned: success
|
||||||
type: list
|
type: list
|
||||||
|
sslPolicy:
|
||||||
|
description:
|
||||||
|
- A reference to the SslPolicy resource that will be associated with the TargetHttpsProxy
|
||||||
|
resource. If not set, the TargetHttpsProxy resource will not have any SSL policy
|
||||||
|
configured.
|
||||||
|
returned: success
|
||||||
|
type: dict
|
||||||
urlMap:
|
urlMap:
|
||||||
description:
|
description:
|
||||||
- A reference to the UrlMap resource that defines the mapping from URL to the BackendService.
|
- A reference to the UrlMap resource that defines the mapping from URL to the BackendService.
|
||||||
|
@ -250,7 +269,7 @@ def main():
|
||||||
quic_override=dict(type='str', choices=['NONE', 'ENABLE', 'DISABLE']),
|
quic_override=dict(type='str', choices=['NONE', 'ENABLE', 'DISABLE']),
|
||||||
ssl_certificates=dict(required=True, type='list', elements='dict'),
|
ssl_certificates=dict(required=True, type='list', elements='dict'),
|
||||||
ssl_policy=dict(type='dict'),
|
ssl_policy=dict(type='dict'),
|
||||||
url_map=dict(required=True, type='dict'),
|
url_map=dict(required=True, type='dict')
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -301,6 +320,8 @@ def update_fields(module, request, response):
|
||||||
quic_override_update(module, request, response)
|
quic_override_update(module, request, response)
|
||||||
if response.get('sslCertificates') != request.get('sslCertificates'):
|
if response.get('sslCertificates') != request.get('sslCertificates'):
|
||||||
ssl_certificates_update(module, request, response)
|
ssl_certificates_update(module, request, response)
|
||||||
|
if response.get('sslPolicy') != request.get('sslPolicy'):
|
||||||
|
ssl_policy_update(module, request, response)
|
||||||
if response.get('urlMap') != request.get('urlMap'):
|
if response.get('urlMap') != request.get('urlMap'):
|
||||||
url_map_update(module, request, response)
|
url_map_update(module, request, response)
|
||||||
|
|
||||||
|
@ -331,6 +352,19 @@ def ssl_certificates_update(module, request, response):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def ssl_policy_update(module, request, response):
|
||||||
|
auth = GcpSession(module, 'compute')
|
||||||
|
auth.post(
|
||||||
|
''.join([
|
||||||
|
"https://www.googleapis.com/compute/v1/",
|
||||||
|
"projects/{project}/global/targetHttpsProxies/{name}/setSslPolicy"
|
||||||
|
]).format(**module.params),
|
||||||
|
{
|
||||||
|
u'sslPolicy': replace_resource_dict(module.params.get(u'ssl_policy', {}), 'selfLink')
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def url_map_update(module, request, response):
|
def url_map_update(module, request, response):
|
||||||
auth = GcpSession(module, 'compute')
|
auth = GcpSession(module, 'compute')
|
||||||
auth.post(
|
auth.post(
|
||||||
|
@ -357,7 +391,7 @@ def resource_to_request(module):
|
||||||
u'quicOverride': module.params.get('quic_override'),
|
u'quicOverride': module.params.get('quic_override'),
|
||||||
u'sslCertificates': replace_resource_dict(module.params.get('ssl_certificates', []), 'selfLink'),
|
u'sslCertificates': replace_resource_dict(module.params.get('ssl_certificates', []), 'selfLink'),
|
||||||
u'sslPolicy': replace_resource_dict(module.params.get(u'ssl_policy', {}), 'selfLink'),
|
u'sslPolicy': replace_resource_dict(module.params.get(u'ssl_policy', {}), 'selfLink'),
|
||||||
u'urlMap': replace_resource_dict(module.params.get(u'url_map', {}), 'selfLink'),
|
u'urlMap': replace_resource_dict(module.params.get(u'url_map', {}), 'selfLink')
|
||||||
}
|
}
|
||||||
return_vals = {}
|
return_vals = {}
|
||||||
for k, v in request.items():
|
for k, v in request.items():
|
||||||
|
@ -430,7 +464,7 @@ def response_to_hash(module, response):
|
||||||
u'quicOverride': response.get(u'quicOverride'),
|
u'quicOverride': response.get(u'quicOverride'),
|
||||||
u'sslCertificates': response.get(u'sslCertificates'),
|
u'sslCertificates': response.get(u'sslCertificates'),
|
||||||
u'sslPolicy': response.get(u'sslPolicy'),
|
u'sslPolicy': response.get(u'sslPolicy'),
|
||||||
u'urlMap': response.get(u'urlMap'),
|
u'urlMap': response.get(u'urlMap')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -105,6 +105,13 @@ items:
|
||||||
must be specified.
|
must be specified.
|
||||||
returned: success
|
returned: success
|
||||||
type: list
|
type: list
|
||||||
|
sslPolicy:
|
||||||
|
description:
|
||||||
|
- A reference to the SslPolicy resource that will be associated with the TargetHttpsProxy
|
||||||
|
resource. If not set, the TargetHttpsProxy resource will not have any SSL
|
||||||
|
policy configured.
|
||||||
|
returned: success
|
||||||
|
type: dict
|
||||||
urlMap:
|
urlMap:
|
||||||
description:
|
description:
|
||||||
- A reference to the UrlMap resource that defines the mapping from URL to the
|
- A reference to the UrlMap resource that defines the mapping from URL to the
|
||||||
|
|
|
@ -84,6 +84,18 @@ options:
|
||||||
between users and the load balancer. Currently, exactly one SSL certificate
|
between users and the load balancer. Currently, exactly one SSL certificate
|
||||||
must be specified.
|
must be specified.
|
||||||
required: true
|
required: true
|
||||||
|
ssl_policy:
|
||||||
|
description:
|
||||||
|
- A reference to the SslPolicy resource that will be associated with the TargetSslProxy
|
||||||
|
resource. If not set, the TargetSslProxy resource will not have any SSL policy
|
||||||
|
configured.
|
||||||
|
- 'This field represents a link to a SslPolicy resource in GCP. It can be specified
|
||||||
|
in two ways. You can add `register: name-of-resource` to a gcp_compute_ssl_policy
|
||||||
|
task and then set this ssl_policy field to "{{ name-of-resource }}" Alternatively,
|
||||||
|
you can set this ssl_policy to a dictionary with the selfLink key where the
|
||||||
|
value is the selfLink of your SslPolicy'
|
||||||
|
required: false
|
||||||
|
version_added: 2.8
|
||||||
extends_documentation_fragment: gcp
|
extends_documentation_fragment: gcp
|
||||||
notes:
|
notes:
|
||||||
- 'API Reference: U(https://cloud.google.com/compute/docs/reference/latest/targetSslProxies)'
|
- 'API Reference: U(https://cloud.google.com/compute/docs/reference/latest/targetSslProxies)'
|
||||||
|
@ -209,6 +221,13 @@ sslCertificates:
|
||||||
users and the load balancer. Currently, exactly one SSL certificate must be specified.
|
users and the load balancer. Currently, exactly one SSL certificate must be specified.
|
||||||
returned: success
|
returned: success
|
||||||
type: list
|
type: list
|
||||||
|
sslPolicy:
|
||||||
|
description:
|
||||||
|
- A reference to the SslPolicy resource that will be associated with the TargetSslProxy
|
||||||
|
resource. If not set, the TargetSslProxy resource will not have any SSL policy
|
||||||
|
configured.
|
||||||
|
returned: success
|
||||||
|
type: dict
|
||||||
'''
|
'''
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -235,7 +254,7 @@ def main():
|
||||||
proxy_header=dict(type='str', choices=['NONE', 'PROXY_V1']),
|
proxy_header=dict(type='str', choices=['NONE', 'PROXY_V1']),
|
||||||
service=dict(required=True, type='dict'),
|
service=dict(required=True, type='dict'),
|
||||||
ssl_certificates=dict(required=True, type='list', elements='dict'),
|
ssl_certificates=dict(required=True, type='list', elements='dict'),
|
||||||
ssl_policy=dict(type='dict'),
|
ssl_policy=dict(type='dict')
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -288,6 +307,8 @@ def update_fields(module, request, response):
|
||||||
service_update(module, request, response)
|
service_update(module, request, response)
|
||||||
if response.get('sslCertificates') != request.get('sslCertificates'):
|
if response.get('sslCertificates') != request.get('sslCertificates'):
|
||||||
ssl_certificates_update(module, request, response)
|
ssl_certificates_update(module, request, response)
|
||||||
|
if response.get('sslPolicy') != request.get('sslPolicy'):
|
||||||
|
ssl_policy_update(module, request, response)
|
||||||
|
|
||||||
|
|
||||||
def proxy_header_update(module, request, response):
|
def proxy_header_update(module, request, response):
|
||||||
|
@ -329,6 +350,19 @@ def ssl_certificates_update(module, request, response):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def ssl_policy_update(module, request, response):
|
||||||
|
auth = GcpSession(module, 'compute')
|
||||||
|
auth.post(
|
||||||
|
''.join([
|
||||||
|
"https://www.googleapis.com/compute/v1/",
|
||||||
|
"projects/{project}/global/targetSslProxies/{name}/setSslPolicy"
|
||||||
|
]).format(**module.params),
|
||||||
|
{
|
||||||
|
u'sslPolicy': replace_resource_dict(module.params.get(u'ssl_policy', {}), 'selfLink')
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def delete(module, link, kind):
|
def delete(module, link, kind):
|
||||||
auth = GcpSession(module, 'compute')
|
auth = GcpSession(module, 'compute')
|
||||||
return wait_for_operation(module, auth.delete(link))
|
return wait_for_operation(module, auth.delete(link))
|
||||||
|
@ -342,7 +376,7 @@ def resource_to_request(module):
|
||||||
u'proxyHeader': module.params.get('proxy_header'),
|
u'proxyHeader': module.params.get('proxy_header'),
|
||||||
u'service': replace_resource_dict(module.params.get(u'service', {}), 'selfLink'),
|
u'service': replace_resource_dict(module.params.get(u'service', {}), 'selfLink'),
|
||||||
u'sslCertificates': replace_resource_dict(module.params.get('ssl_certificates', []), 'selfLink'),
|
u'sslCertificates': replace_resource_dict(module.params.get('ssl_certificates', []), 'selfLink'),
|
||||||
u'sslPolicy': replace_resource_dict(module.params.get(u'ssl_policy', {}), 'selfLink'),
|
u'sslPolicy': replace_resource_dict(module.params.get(u'ssl_policy', {}), 'selfLink')
|
||||||
}
|
}
|
||||||
return_vals = {}
|
return_vals = {}
|
||||||
for k, v in request.items():
|
for k, v in request.items():
|
||||||
|
@ -415,7 +449,7 @@ def response_to_hash(module, response):
|
||||||
u'proxyHeader': response.get(u'proxyHeader'),
|
u'proxyHeader': response.get(u'proxyHeader'),
|
||||||
u'service': response.get(u'service'),
|
u'service': response.get(u'service'),
|
||||||
u'sslCertificates': response.get(u'sslCertificates'),
|
u'sslCertificates': response.get(u'sslCertificates'),
|
||||||
u'sslPolicy': response.get(u'sslPolicy'),
|
u'sslPolicy': response.get(u'sslPolicy')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -107,6 +107,13 @@ items:
|
||||||
must be specified.
|
must be specified.
|
||||||
returned: success
|
returned: success
|
||||||
type: list
|
type: list
|
||||||
|
sslPolicy:
|
||||||
|
description:
|
||||||
|
- A reference to the SslPolicy resource that will be associated with the TargetSslProxy
|
||||||
|
resource. If not set, the TargetSslProxy resource will not have any SSL policy
|
||||||
|
configured.
|
||||||
|
returned: success
|
||||||
|
type: dict
|
||||||
'''
|
'''
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
Loading…
Add table
Reference in a new issue