|
|
@ -286,7 +286,7 @@ from ansible.module_utils.azure_rm_common import AzureRMModuleBase
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
from msrestazure.azure_exceptions import CloudError
|
|
|
|
from msrestazure.azure_exceptions import CloudError
|
|
|
|
from msrestazure.azure_operation import AzureOperationPoller
|
|
|
|
from msrest.polling import LROPoller
|
|
|
|
from msrest.serialization import Model
|
|
|
|
from msrest.serialization import Model
|
|
|
|
from azure.mgmt.web.models import (
|
|
|
|
from azure.mgmt.web.models import (
|
|
|
|
site_config, app_service_plan, Site,
|
|
|
|
site_config, app_service_plan, Site,
|
|
|
@ -671,7 +671,7 @@ class AzureRMWebApps(AzureRMModuleBase):
|
|
|
|
if self.app_settings:
|
|
|
|
if self.app_settings:
|
|
|
|
app_settings = []
|
|
|
|
app_settings = []
|
|
|
|
for key in self.app_settings.keys():
|
|
|
|
for key in self.app_settings.keys():
|
|
|
|
app_settings.append(NameValuePair(key, self.app_settings[key]))
|
|
|
|
app_settings.append(NameValuePair(name=key, value=self.app_settings[key]))
|
|
|
|
|
|
|
|
|
|
|
|
self.site_config['app_settings'] = app_settings
|
|
|
|
self.site_config['app_settings'] = app_settings
|
|
|
|
else:
|
|
|
|
else:
|
|
|
@ -707,7 +707,7 @@ class AzureRMWebApps(AzureRMModuleBase):
|
|
|
|
# purge existing app_settings:
|
|
|
|
# purge existing app_settings:
|
|
|
|
if self.purge_app_settings:
|
|
|
|
if self.purge_app_settings:
|
|
|
|
to_be_updated = True
|
|
|
|
to_be_updated = True
|
|
|
|
self.app_settings_strDic.properties = dict()
|
|
|
|
self.app_settings_strDic = dict()
|
|
|
|
self.to_do.append(Actions.UpdateAppSettings)
|
|
|
|
self.to_do.append(Actions.UpdateAppSettings)
|
|
|
|
|
|
|
|
|
|
|
|
# check if app settings changed
|
|
|
|
# check if app settings changed
|
|
|
@ -717,7 +717,7 @@ class AzureRMWebApps(AzureRMModuleBase):
|
|
|
|
|
|
|
|
|
|
|
|
if self.app_settings:
|
|
|
|
if self.app_settings:
|
|
|
|
for key in self.app_settings.keys():
|
|
|
|
for key in self.app_settings.keys():
|
|
|
|
self.app_settings_strDic.properties[key] = self.app_settings[key]
|
|
|
|
self.app_settings_strDic[key] = self.app_settings[key]
|
|
|
|
|
|
|
|
|
|
|
|
elif self.state == 'absent':
|
|
|
|
elif self.state == 'absent':
|
|
|
|
if old_response:
|
|
|
|
if old_response:
|
|
|
@ -772,7 +772,8 @@ class AzureRMWebApps(AzureRMModuleBase):
|
|
|
|
# compare existing web app with input, determine weather it's update operation
|
|
|
|
# compare existing web app with input, determine weather it's update operation
|
|
|
|
def is_updatable_property_changed(self, existing_webapp):
|
|
|
|
def is_updatable_property_changed(self, existing_webapp):
|
|
|
|
for property_name in self.updatable_properties:
|
|
|
|
for property_name in self.updatable_properties:
|
|
|
|
if hasattr(self, property_name) and getattr(self, property_name) != existing_webapp.get(property_name, None):
|
|
|
|
if hasattr(self, property_name) and getattr(self, property_name) is not None and \
|
|
|
|
|
|
|
|
getattr(self, property_name) != existing_webapp.get(property_name, None):
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
return False
|
|
|
|
return False
|
|
|
@ -790,9 +791,9 @@ class AzureRMWebApps(AzureRMModuleBase):
|
|
|
|
# comparing existing app setting with input, determine whether it's changed
|
|
|
|
# comparing existing app setting with input, determine whether it's changed
|
|
|
|
def is_app_settings_changed(self):
|
|
|
|
def is_app_settings_changed(self):
|
|
|
|
if self.app_settings:
|
|
|
|
if self.app_settings:
|
|
|
|
if self.app_settings_strDic.properties:
|
|
|
|
if self.app_settings_strDic:
|
|
|
|
for key in self.app_settings.keys():
|
|
|
|
for key in self.app_settings.keys():
|
|
|
|
if self.app_settings[key] != self.app_settings_strDic.properties.get(key, None):
|
|
|
|
if self.app_settings[key] != self.app_settings_strDic.get(key, None):
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return True
|
|
|
|
return True
|
|
|
@ -831,7 +832,7 @@ class AzureRMWebApps(AzureRMModuleBase):
|
|
|
|
skip_custom_domain_verification=self.skip_custom_domain_verification,
|
|
|
|
skip_custom_domain_verification=self.skip_custom_domain_verification,
|
|
|
|
force_dns_registration=force_dns_registration,
|
|
|
|
force_dns_registration=force_dns_registration,
|
|
|
|
ttl_in_seconds=self.ttl_in_seconds)
|
|
|
|
ttl_in_seconds=self.ttl_in_seconds)
|
|
|
|
if isinstance(response, AzureOperationPoller):
|
|
|
|
if isinstance(response, LROPoller):
|
|
|
|
response = self.get_poller_result(response)
|
|
|
|
response = self.get_poller_result(response)
|
|
|
|
|
|
|
|
|
|
|
|
except CloudError as exc:
|
|
|
|
except CloudError as exc:
|
|
|
@ -872,13 +873,17 @@ class AzureRMWebApps(AzureRMModuleBase):
|
|
|
|
response = self.web_client.web_apps.get(resource_group_name=self.resource_group,
|
|
|
|
response = self.web_client.web_apps.get(resource_group_name=self.resource_group,
|
|
|
|
name=self.name)
|
|
|
|
name=self.name)
|
|
|
|
|
|
|
|
|
|
|
|
self.log("Response : {0}".format(response))
|
|
|
|
# Newer SDK versions (0.40.0+) seem to return None if it doesn't exist instead of raising CloudError
|
|
|
|
self.log("Web App instance : {0} found".format(response.name))
|
|
|
|
if response is not None:
|
|
|
|
return webapp_to_dict(response)
|
|
|
|
self.log("Response : {0}".format(response))
|
|
|
|
|
|
|
|
self.log("Web App instance : {0} found".format(response.name))
|
|
|
|
|
|
|
|
return webapp_to_dict(response)
|
|
|
|
|
|
|
|
|
|
|
|
except CloudError as ex:
|
|
|
|
except CloudError as ex:
|
|
|
|
self.log("Didn't find web app {0} in resource group {1}".format(
|
|
|
|
pass
|
|
|
|
self.name, self.resource_group))
|
|
|
|
|
|
|
|
|
|
|
|
self.log("Didn't find web app {0} in resource group {1}".format(
|
|
|
|
|
|
|
|
self.name, self.resource_group))
|
|
|
|
|
|
|
|
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
@ -891,14 +896,20 @@ class AzureRMWebApps(AzureRMModuleBase):
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
response = self.web_client.app_service_plans.get(
|
|
|
|
response = self.web_client.app_service_plans.get(
|
|
|
|
self.plan['resource_group'], self.plan['name'])
|
|
|
|
resource_group_name=self.plan['resource_group'],
|
|
|
|
self.log("Response : {0}".format(response))
|
|
|
|
name=self.plan['name'])
|
|
|
|
self.log("App Service Plan : {0} found".format(response.name))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return appserviceplan_to_dict(response)
|
|
|
|
# Newer SDK versions (0.40.0+) seem to return None if it doesn't exist instead of raising CloudError
|
|
|
|
|
|
|
|
if response is not None:
|
|
|
|
|
|
|
|
self.log("Response : {0}".format(response))
|
|
|
|
|
|
|
|
self.log("App Service Plan : {0} found".format(response.name))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return appserviceplan_to_dict(response)
|
|
|
|
except CloudError as ex:
|
|
|
|
except CloudError as ex:
|
|
|
|
self.log("Didn't find app service plan {0} in resource group {1}".format(
|
|
|
|
pass
|
|
|
|
self.plan['name'], self.plan['resource_group']))
|
|
|
|
|
|
|
|
|
|
|
|
self.log("Didn't find app service plan {0} in resource group {1}".format(
|
|
|
|
|
|
|
|
self.plan['name'], self.plan['resource_group']))
|
|
|
|
|
|
|
|
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
@ -921,7 +932,7 @@ class AzureRMWebApps(AzureRMModuleBase):
|
|
|
|
poller = self.web_client.app_service_plans.create_or_update(
|
|
|
|
poller = self.web_client.app_service_plans.create_or_update(
|
|
|
|
self.plan['resource_group'], self.plan['name'], plan_def)
|
|
|
|
self.plan['resource_group'], self.plan['name'], plan_def)
|
|
|
|
|
|
|
|
|
|
|
|
if isinstance(poller, AzureOperationPoller):
|
|
|
|
if isinstance(poller, LROPoller):
|
|
|
|
response = self.get_poller_result(poller)
|
|
|
|
response = self.get_poller_result(poller)
|
|
|
|
|
|
|
|
|
|
|
|
self.log("Response : {0}".format(response))
|
|
|
|
self.log("Response : {0}".format(response))
|
|
|
@ -944,7 +955,7 @@ class AzureRMWebApps(AzureRMModuleBase):
|
|
|
|
resource_group_name=self.resource_group, name=self.name)
|
|
|
|
resource_group_name=self.resource_group, name=self.name)
|
|
|
|
self.log("Response : {0}".format(response))
|
|
|
|
self.log("Response : {0}".format(response))
|
|
|
|
|
|
|
|
|
|
|
|
return response
|
|
|
|
return response.properties
|
|
|
|
except CloudError as ex:
|
|
|
|
except CloudError as ex:
|
|
|
|
self.fail("Failed to list application settings for web app {0} in resource group {1}: {2}".format(
|
|
|
|
self.fail("Failed to list application settings for web app {0} in resource group {1}: {2}".format(
|
|
|
|
self.name, self.resource_group, str(ex)))
|
|
|
|
self.name, self.resource_group, str(ex)))
|
|
|
@ -958,7 +969,7 @@ class AzureRMWebApps(AzureRMModuleBase):
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
response = self.web_client.web_apps.update_application_settings(
|
|
|
|
response = self.web_client.web_apps.update_application_settings(
|
|
|
|
resource_group_name=self.resource_group, name=self.name, app_settings=self.app_settings_strDic)
|
|
|
|
resource_group_name=self.resource_group, name=self.name, properties=self.app_settings_strDic)
|
|
|
|
self.log("Response : {0}".format(response))
|
|
|
|
self.log("Response : {0}".format(response))
|
|
|
|
|
|
|
|
|
|
|
|
return response
|
|
|
|
return response
|
|
|
|