add publish url in webapp facts output (#45131)

* add publish url in webapp facts output

* update name

* fix test
pull/41949/merge
Yunge Zhu 6 years ago committed by Zim Kalinowski
parent 4173a30941
commit 2955d7cd1b

@ -126,6 +126,10 @@ webapps:
outbound_ip_addresses:
description: Outbound ip address of the web app.
type: str
ftp_publish_url:
description: Publishing url of the web app when depeloyment type is FTP.
type: str
sample: ftp://xxxx.ftp.azurewebsites.windows.net
state:
description: State of the web app. eg. running.
type: str
@ -275,6 +279,34 @@ class AzureRMWebAppFacts(AzureRMModuleBase):
self.fail('Error getting web app {0} publishing credentials - {1}'.format(request_id, str(ex)))
return response
def get_webapp_ftp_publish_url(self, resource_group, name):
import xmltodict
self.log('Get web app {0} app publish profile'.format(name))
url = None
try:
content = self.web_client.web_apps.list_publishing_profile_xml_with_secrets(resource_group_name=resource_group, name=name)
if not content:
return url
full_xml = ''
for f in content:
full_xml += f.decode()
profiles = xmltodict.parse(full_xml, xml_attribs=True)['publishData']['publishProfile']
if not profiles:
return url
for profile in profiles:
if profile['@publishMethod'] == 'FTP':
url = profile['@publishUrl']
except CloudError as ex:
self.fail('Error getting web app {0} app settings'.format(name))
return url
def get_curated_webapp(self, resource_group, name, webapp):
pip = self.serialize_obj(webapp, AZURE_OBJECT_CLASS)
@ -282,15 +314,23 @@ class AzureRMWebAppFacts(AzureRMModuleBase):
site_config = self.list_webapp_configuration(resource_group, name)
app_settings = self.list_webapp_appsettings(resource_group, name)
publish_cred = self.get_publish_credentials(resource_group, name)
ftp_publish_url = self.get_webapp_ftp_publish_url(resource_group, name)
except CloudError as ex:
pass
return self.construct_curated_webapp(webapp=pip,
configuration=site_config,
app_settings=app_settings,
deployment_slot=None,
ftp_publish_url=ftp_publish_url,
publish_credentials=publish_cred)
def construct_curated_webapp(self, webapp, configuration=None, app_settings=None, deployment_slot=None, publish_credentials=None):
def construct_curated_webapp(self,
webapp,
configuration=None,
app_settings=None,
deployment_slot=None,
ftp_publish_url=None,
publish_credentials=None):
curated_output = dict()
curated_output['id'] = webapp['id']
curated_output['name'] = webapp['name']
@ -346,6 +386,10 @@ class AzureRMWebAppFacts(AzureRMModuleBase):
if deployment_slot:
curated_output['deployment_slot'] = deployment_slot
# ftp_publish_url
if ftp_publish_url:
curated_output['ftp_publish_url'] = ftp_publish_url
# curated publish credentials
if publish_credentials and self.return_publish_profile:
curated_output['publishing_username'] = publish_credentials.publishing_user_name

@ -316,3 +316,15 @@
- name: Assert the web app was created
assert:
that: output.changed
- name: Get facts with publish profile
azure_rm_webapp_facts:
resource_group: "{{ resource_group }}"
name: "{{ win_app_name }}13"
no_log: true
register: facts
- name: Assert publish profile returned
assert:
that:
- facts.webapps[0].ftp_publish_url != ''
Loading…
Cancel
Save