From f16bb4daf4eaf3d6bcd4532d5336859341816096 Mon Sep 17 00:00:00 2001 From: Zim Kalinowski Date: Tue, 16 Oct 2018 00:57:03 +0800 Subject: [PATCH] =?UTF-8?q?Fixing=20assigning=20ssl=20certificate=20to=20h?= =?UTF-8?q?ttp=20listener=20in=20app=20gateway=20(#45=E2=80=A6=20(#46027)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fixing assigning ssl certificate to http listener in app gateway (#45830) * fixed ssl certificate reference * modified test (cherry picked from commit 83645963fb8eeda6dccc53a838b5a529de20de04) * added chagelog --- .../45830-fixed-assigning-ssl-certificate.yaml | 4 ++++ .../modules/cloud/azure/azure_rm_appgateway.py | 16 ++++++++++++++++ .../targets/azure_rm_appgateway/tasks/main.yml | 8 ++++++++ 3 files changed, 28 insertions(+) create mode 100644 changelogs/fragments/45830-fixed-assigning-ssl-certificate.yaml diff --git a/changelogs/fragments/45830-fixed-assigning-ssl-certificate.yaml b/changelogs/fragments/45830-fixed-assigning-ssl-certificate.yaml new file mode 100644 index 0000000000..2751fb64ba --- /dev/null +++ b/changelogs/fragments/45830-fixed-assigning-ssl-certificate.yaml @@ -0,0 +1,4 @@ +bugfixes: +- "Fixed: Appropriate code to expand value was missing so assigning SSL + certificate is not working as described in the documentation. + https://github.com/ansible/ansible/pull/45830" diff --git a/lib/ansible/modules/cloud/azure/azure_rm_appgateway.py b/lib/ansible/modules/cloud/azure/azure_rm_appgateway.py index 886599b853..0368f355b2 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_appgateway.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_appgateway.py @@ -577,6 +577,12 @@ class AzureRMApplicationGateways(AzureRMModuleBase): kwargs['name'], item['frontend_port']) item['frontend_port'] = {'id': id} + if 'ssl_certificate' in item: + id = ssl_certificate_id(self.subscription_id, + kwargs['resource_group'], + kwargs['name'], + item['ssl_certificate']) + item['ssl_certificate'] = {'id': id} if 'protocol' in item: item['protocol'] = _snake_to_camel(item['protocol'], True) ev[i] = item @@ -781,6 +787,16 @@ def frontend_port_id(subscription_id, resource_group_name, appgateway_name, name ) +def ssl_certificate_id(subscription_id, resource_group_name, ssl_certificate_name, name): + """Generate the id for a frontend port""" + return '/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Network/applicationGateways/{2}/sslCertificates/{3}'.format( + subscription_id, + resource_group_name, + ssl_certificate_name, + name + ) + + def backend_address_pool_id(subscription_id, resource_group_name, appgateway_name, name): """Generate the id for an address pool""" return '/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Network/applicationGateways/{2}/backendAddressPools/{3}'.format( diff --git a/test/integration/targets/azure_rm_appgateway/tasks/main.yml b/test/integration/targets/azure_rm_appgateway/tasks/main.yml index f05117f93e..a1e14ebe55 100644 --- a/test/integration/targets/azure_rm_appgateway/tasks/main.yml +++ b/test/integration/targets/azure_rm_appgateway/tasks/main.yml @@ -66,6 +66,8 @@ http_listeners: - frontend_ip_configuration: sample_gateway_frontend_ip_config frontend_port: ag_frontend_port + protocol: https + ssl_certificate: cert2 name: sample_http_listener request_routing_rules: - rule_type: basic @@ -129,6 +131,8 @@ http_listeners: - frontend_ip_configuration: sample_gateway_frontend_ip_config frontend_port: ag_frontend_port + protocol: https + ssl_certificate: cert2 name: sample_http_listener request_routing_rules: - rule_type: Basic @@ -187,6 +191,8 @@ http_listeners: - frontend_ip_configuration: sample_gateway_frontend_ip_config frontend_port: ag_frontend_port + protocol: https + ssl_certificate: cert2 name: sample_http_listener request_routing_rules: - rule_type: Basic @@ -245,6 +251,8 @@ http_listeners: - frontend_ip_configuration: sample_gateway_frontend_ip_config frontend_port: ag_frontend_port + protocol: https + ssl_certificate: cert2 name: sample_http_listener request_routing_rules: - rule_type: Basic