Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
Merge pull request #134 from modular-magician/codegen-pr-952
Browse files Browse the repository at this point in the history
Add sslPolicy to a few resources.
  • Loading branch information
danawillow authored Dec 7, 2018
2 parents 3395f14 + c0cb734 commit 807b879
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 3 deletions.
37 changes: 37 additions & 0 deletions lib/ansible/modules/cloud/google/gcp_compute_target_https_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@
between users and the load balancer. Currently, exactly one SSL certificate
must be specified.
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:
description:
- A reference to the UrlMap resource that defines the mapping from URL to the
Expand Down Expand Up @@ -232,6 +244,13 @@
users and the load balancer. Currently, exactly one SSL certificate must be specified.
returned: success
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:
description:
- A reference to the UrlMap resource that defines the mapping from URL to the BackendService.
Expand Down Expand Up @@ -262,6 +281,7 @@ def main():
name=dict(required=True, type='str'),
quic_override=dict(type='str', choices=['NONE', 'ENABLE', 'DISABLE']),
ssl_certificates=dict(required=True, type='list', elements='dict'),
ssl_policy=dict(type='dict'),
url_map=dict(required=True, type='dict')
)
)
Expand Down Expand Up @@ -313,6 +333,8 @@ def update_fields(module, request, response):
quic_override_update(module, request, response)
if response.get('sslCertificates') != request.get('sslCertificates'):
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'):
url_map_update(module, request, response)

Expand Down Expand Up @@ -343,6 +365,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):
auth = GcpSession(module, 'compute')
auth.post(
Expand All @@ -368,6 +403,7 @@ def resource_to_request(module):
u'name': module.params.get('name'),
u'quicOverride': module.params.get('quic_override'),
u'sslCertificates': replace_resource_dict(module.params.get('ssl_certificates', []), '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')
}
return_vals = {}
Expand Down Expand Up @@ -440,6 +476,7 @@ def response_to_hash(module, response):
u'name': module.params.get('name'),
u'quicOverride': response.get(u'quicOverride'),
u'sslCertificates': response.get(u'sslCertificates'),
u'sslPolicy': response.get(u'sslPolicy'),
u'urlMap': response.get(u'urlMap')
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@
must be specified.
returned: success
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:
description:
- A reference to the UrlMap resource that defines the mapping from URL to the
Expand Down
43 changes: 40 additions & 3 deletions lib/ansible/modules/cloud/google/gcp_compute_target_ssl_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,18 @@
between users and the load balancer. Currently, exactly one SSL certificate
must be specified.
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
notes:
- 'API Reference: U(https://cloud.google.com/compute/docs/reference/latest/targetSslProxies)'
Expand Down Expand Up @@ -222,6 +234,13 @@
users and the load balancer. Currently, exactly one SSL certificate must be specified.
returned: success
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
'''

################################################################################
Expand All @@ -247,7 +266,8 @@ def main():
name=dict(required=True, type='str'),
proxy_header=dict(type='str', choices=['NONE', 'PROXY_V1']),
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')
)
)

Expand Down Expand Up @@ -300,6 +320,8 @@ def update_fields(module, request, response):
service_update(module, request, response)
if response.get('sslCertificates') != request.get('sslCertificates'):
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):
Expand Down Expand Up @@ -341,6 +363,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):
auth = GcpSession(module, 'compute')
return wait_for_operation(module, auth.delete(link))
Expand All @@ -353,7 +388,8 @@ def resource_to_request(module):
u'name': module.params.get('name'),
u'proxyHeader': module.params.get('proxy_header'),
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')
}
return_vals = {}
for k, v in request.items():
Expand Down Expand Up @@ -425,7 +461,8 @@ def response_to_hash(module, response):
u'name': module.params.get('name'),
u'proxyHeader': response.get(u'proxyHeader'),
u'service': response.get(u'service'),
u'sslCertificates': response.get(u'sslCertificates')
u'sslCertificates': response.get(u'sslCertificates'),
u'sslPolicy': response.get(u'sslPolicy')
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@
must be specified.
returned: success
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
'''

################################################################################
Expand Down
2 changes: 2 additions & 0 deletions test/integration/targets/gcp_storage_object/aliases
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cloud/gcp
unsupported
3 changes: 3 additions & 0 deletions test/integration/targets/gcp_storage_object/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
# defaults file
resource_name: '{{resource_prefix}}'
Empty file.

0 comments on commit 807b879

Please sign in to comment.