|
|
|
@ -388,7 +388,7 @@ def webapp_to_dict(webapp):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Actions:
|
|
|
|
|
NoAction, CreateOrUpdate, UpdateAppSettings, Delete = range(4)
|
|
|
|
|
CreateOrUpdate, UpdateAppSettings, Delete = range(3)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AzureRMWebApps(AzureRMModuleBase):
|
|
|
|
@ -504,7 +504,7 @@ class AzureRMWebApps(AzureRMModuleBase):
|
|
|
|
|
id=None,
|
|
|
|
|
)
|
|
|
|
|
self.state = None
|
|
|
|
|
self.to_do = Actions.NoAction
|
|
|
|
|
self.to_do = []
|
|
|
|
|
|
|
|
|
|
self.frameworks = None
|
|
|
|
|
|
|
|
|
@ -642,7 +642,7 @@ class AzureRMWebApps(AzureRMModuleBase):
|
|
|
|
|
self.log("Web App instance doesn't exist")
|
|
|
|
|
|
|
|
|
|
to_be_updated = True
|
|
|
|
|
self.to_do = Actions.CreateOrUpdate
|
|
|
|
|
self.to_do.append(Actions.CreateOrUpdate)
|
|
|
|
|
self.site.tags = self.tags
|
|
|
|
|
|
|
|
|
|
# service plan is required for creation
|
|
|
|
@ -688,19 +688,19 @@ class AzureRMWebApps(AzureRMModuleBase):
|
|
|
|
|
# check if root level property changed
|
|
|
|
|
if self.is_updatable_property_changed(old_response):
|
|
|
|
|
to_be_updated = True
|
|
|
|
|
self.to_do = Actions.CreateOrUpdate
|
|
|
|
|
self.to_do.append(Actions.CreateOrUpdate)
|
|
|
|
|
|
|
|
|
|
# check if site_config changed
|
|
|
|
|
old_config = self.get_webapp_configuration()
|
|
|
|
|
|
|
|
|
|
if self.is_site_config_changed(old_config):
|
|
|
|
|
to_be_updated = True
|
|
|
|
|
self.to_do = Actions.CreateOrUpdate
|
|
|
|
|
self.to_do.append(Actions.CreateOrUpdate)
|
|
|
|
|
|
|
|
|
|
# check if linux_fx_version changed
|
|
|
|
|
if old_config.linux_fx_version != self.site_config.get('linux_fx_version', ''):
|
|
|
|
|
to_be_updated = True
|
|
|
|
|
self.to_do = Actions.CreateOrUpdate
|
|
|
|
|
self.to_do.append(Actions.CreateOrUpdate)
|
|
|
|
|
|
|
|
|
|
self.app_settings_strDic = self.list_app_settings()
|
|
|
|
|
|
|
|
|
@ -708,11 +708,12 @@ class AzureRMWebApps(AzureRMModuleBase):
|
|
|
|
|
if self.purge_app_settings:
|
|
|
|
|
to_be_updated = True
|
|
|
|
|
self.app_settings_strDic.properties = dict()
|
|
|
|
|
self.to_do.append(Actions.UpdateAppSettings)
|
|
|
|
|
|
|
|
|
|
# check if app settings changed
|
|
|
|
|
if self.purge_app_settings or self.is_app_settings_changed():
|
|
|
|
|
to_be_updated = True
|
|
|
|
|
self.to_do = Actions.CreateOrUpdate
|
|
|
|
|
self.to_do.append(Actions.UpdateAppSettings)
|
|
|
|
|
|
|
|
|
|
if self.app_settings:
|
|
|
|
|
for key in self.app_settings.keys():
|
|
|
|
@ -740,11 +741,15 @@ class AzureRMWebApps(AzureRMModuleBase):
|
|
|
|
|
if self.check_mode:
|
|
|
|
|
return self.results
|
|
|
|
|
|
|
|
|
|
if self.to_do == Actions.CreateOrUpdate:
|
|
|
|
|
if Actions.CreateOrUpdate in self.to_do:
|
|
|
|
|
response = self.create_update_webapp()
|
|
|
|
|
|
|
|
|
|
self.results['id'] = response['id']
|
|
|
|
|
|
|
|
|
|
if Actions.UpdateAppSettings in self.to_do:
|
|
|
|
|
update_response = self.update_app_settings()
|
|
|
|
|
self.results['id'] = update_response.id
|
|
|
|
|
|
|
|
|
|
webapp = None
|
|
|
|
|
if old_response:
|
|
|
|
|
webapp = old_response
|
|
|
|
@ -785,13 +790,11 @@ class AzureRMWebApps(AzureRMModuleBase):
|
|
|
|
|
# comparing existing app setting with input, determine whether it's changed
|
|
|
|
|
def is_app_settings_changed(self):
|
|
|
|
|
if self.app_settings:
|
|
|
|
|
if len(self.app_settings_strDic.properties) != len(self.app_settings):
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
elif self.app_settings_strDic.properties and len(self.app_settings_strDic.properties) > 0:
|
|
|
|
|
if self.app_settings_strDic.properties:
|
|
|
|
|
for key in self.app_settings.keys():
|
|
|
|
|
if not self.app_settings_strDic.properties.get(key) \
|
|
|
|
|
or self.app_settings[key] != self.app_settings_strDic.properties[key]:
|
|
|
|
|
if self.app_settings[key] != self.app_settings_strDic.properties.get(key, None):
|
|
|
|
|
return True
|
|
|
|
|
else:
|
|
|
|
|
return True
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
@ -943,10 +946,8 @@ class AzureRMWebApps(AzureRMModuleBase):
|
|
|
|
|
|
|
|
|
|
return response
|
|
|
|
|
except CloudError as ex:
|
|
|
|
|
self.log("Failed to list application settings for web app {0} in resource group {1}".format(
|
|
|
|
|
self.name, self.resource_group))
|
|
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
self.fail("Failed to list application settings for web app {0} in resource group {1}: {2}".format(
|
|
|
|
|
self.name, self.resource_group, str(ex)))
|
|
|
|
|
|
|
|
|
|
def update_app_settings(self):
|
|
|
|
|
'''
|
|
|
|
@ -960,12 +961,10 @@ class AzureRMWebApps(AzureRMModuleBase):
|
|
|
|
|
resource_group_name=self.resource_group, name=self.name, app_settings=self.app_settings_strDic)
|
|
|
|
|
self.log("Response : {0}".format(response))
|
|
|
|
|
|
|
|
|
|
return response.as_dict()
|
|
|
|
|
return response
|
|
|
|
|
except CloudError as ex:
|
|
|
|
|
self.log("Failed to update application settings for web app {0} in resource group {1}".format(
|
|
|
|
|
self.name, self.resource_group))
|
|
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
self.fail("Failed to update application settings for web app {0} in resource group {1}: {2}".format(
|
|
|
|
|
self.name, self.resource_group, str(ex)))
|
|
|
|
|
|
|
|
|
|
def create_or_update_source_control(self):
|
|
|
|
|
'''
|
|
|
|
|