Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azure_rm_webapp framework support #1124

Closed
watsonb opened this issue Mar 23, 2023 · 4 comments · Fixed by #1128
Closed

azure_rm_webapp framework support #1124

watsonb opened this issue Mar 23, 2023 · 4 comments · Fixed by #1128
Labels
bug Something isn't working has_pr PR fixes have been made medium_priority Medium priority

Comments

@watsonb
Copy link
Contributor

watsonb commented Mar 23, 2023

SUMMARY

Cannot deploy an Azure WebApp running in a Linux App Service Plan with a python framework. Moreover, the versions of Python supported by the Azure WebApp Frameworks seem to be incorrect.

The module documentation and behavior seem to be opposite of the experience used when using portal.azure.com GUI. In the GUI, Linux is the only platform that supports Python, but this module's doc/behavior indicate that Windows is the only platform that supports Python.

GUI User Experience
image

Ansible Doc Experience
image

Ansible Doc Python version oddity
image

I would expect Python versions to be 2.x/3.x. It seems the documentation has a typo.

Line 553 in azure_rm_webapp.py seems to confirm my issue.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

azure_rm_webapp

ANSIBLE VERSION
ansible [core 2.11.2] 
  config file = /home/ben/workspace/kiewit/ansible/playbooks/ap_azure/ansible.cfg
  configured module search path = ['/home/ben/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ben/venv3_ansible-4.2.0/lib/python3.8/site-packages/ansible
  ansible collection location = /home/ben/workspace/kiewit/ansible/playbooks/ap_azure/collections:/home/ben/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/ben/venv3_ansible-4.2.0/bin/ansible
  python version = 3.8.10 (default, Mar 13 2023, 10:26:41) [GCC 9.4.0]
  jinja version = 3.0.1
  libyaml = True
COLLECTION VERSION
# /home/ben/workspace/kiewit/ansible/playbooks/ap_azure/collections/ansible_collections
Collection         Version
------------------ -------
azure.azcollection 1.11.0

However documentation/code from 1.15.0 and dev branch remain the same.

CONFIGURATION
ANSIBLE_NOCOWS(/home/ben/workspace/kiewit/ansible/playbooks/ap_azure/ansible.cfg) = True
CACHE_PLUGIN(/home/ben/workspace/kiewit/ansible/playbooks/ap_azure/ansible.cfg) = jsonfile
CACHE_PLUGIN_CONNECTION(/home/ben/workspace/kiewit/ansible/playbooks/ap_azure/ansible.cfg) = $HOME/ansible/facts
CACHE_PLUGIN_TIMEOUT(/home/ben/workspace/kiewit/ansible/playbooks/ap_azure/ansible.cfg) = 600
COLLECTIONS_PATHS(/home/ben/workspace/kiewit/ansible/playbooks/ap_azure/ansible.cfg) = ['/home/ben/workspace/kiewit/ansible/playbooks/ap_azure/collections', '/home/ben/.
ansible/collections', '/usr/share/ansible/collections']
DEFAULT_FORKS(/home/ben/workspace/kiewit/ansible/playbooks/ap_azure/ansible.cfg) = 20
DEFAULT_GATHERING(/home/ben/workspace/kiewit/ansible/playbooks/ap_azure/ansible.cfg) = smart
DEFAULT_INVENTORY_PLUGIN_PATH(/home/ben/workspace/kiewit/ansible/playbooks/ap_azure/ansible.cfg) = ['/home/ben/workspace/kiewit/ansible/playbooks/ap_azure/plugins/invent
ory', '/home/ben/.ansible/plugins/inventory', '/usr/share/ansible/plugins/inventory']
DEFAULT_LOAD_CALLBACK_PLUGINS(/home/ben/workspace/kiewit/ansible/playbooks/ap_azure/ansible.cfg) = True
DEFAULT_ROLES_PATH(/home/ben/workspace/kiewit/ansible/playbooks/ap_azure/ansible.cfg) = ['/home/ben/workspace/kiewit/ansible/playbooks/ap_azure/roles', '/home/ben/.ansib
le/roles', '/usr/share/ansible/roles', '/etc/ansible/roles']
DEFAULT_STDOUT_CALLBACK(/home/ben/workspace/kiewit/ansible/playbooks/ap_azure/ansible.cfg) = yaml
DEFAULT_VAULT_IDENTITY_LIST(/home/ben/workspace/kiewit/ansible/playbooks/ap_azure/ansible.cfg) = ['vcenter@~/workspace/kiewit/ansible_vaults/vcenter', 'azure@~/workspace
/kiewit/ansible_vaults/azure', 'ansible_user@~/workspace/kiewit/ansible_vaults/ansible_user', 'kiewitadmin_user@~/workspace/kiewit/ansible_vaults/kiewitadmin_user', 'sno
w@~/workspace/kiewit/ansible_vaults/snow', 'awx@~/workspace/kiewit/ansible_vaults/awx']
GALAXY_SERVER_LIST(/home/ben/workspace/kiewit/ansible/playbooks/ap_azure/ansible.cfg) = ['kiewit_published', 'kiewit_community', 'galaxy']
HOST_KEY_CHECKING(/home/ben/workspace/kiewit/ansible/playbooks/ap_azure/ansible.cfg) = False
INVENTORY_ENABLED(/home/ben/workspace/kiewit/ansible/playbooks/ap_azure/ansible.cfg) = ['host_list', 'script', 'auto', 'yaml', 'ini', 'toml', 'vmware_vm_inventory', 'azu
re_rm', 'kiewit.content.ldap_inventory']
RETRY_FILES_ENABLED(/home/ben/workspace/kiewit/ansible/playbooks/ap_azure/ansible.cfg) = True
VARIABLE_PRECEDENCE(/home/ben/workspace/kiewit/ansible/playbooks/ap_azure/ansible.cfg) = ['all_plugins_inventory', 'groups_plugins_inventory', 'all_inventory', 'groups_i
nventory', 'all_plugins_play', 'groups_plugins_play']

OS / ENVIRONMENT

Running from Ubuntu 20.04 and targeting Azure.

STEPS TO REPRODUCE
- name: AZURE_RM_WEBAPP | Create (or update) Web App
  azure.azcollection.azure_rm_webapp:
    # common
    ad_user: "{{ azure_ad_user | default(omit) }}"
    adfs_authority_url: "{{ azure_adfs_authority_url | default(omit) }}"
    api_profile: "{{ azure_api_profile | default(omit) }}"
    append_tags: "{{ azure_append_tags | default(omit) }}"
    auth_source: "{{ azure_auth_source | default(omit) }}"
    cert_validation_mode: "{{ azure_cert_validation_mode | default(omit) }}"
    client_id: "{{ azure_client_id | default(omit) }}"
    cloud_environment: "{{ azure_cloud_environment | default(omit) }}"
    password: "{{ azure_ad_password | default(omit) }}"
    profile: "{{ azure_profile | default(omit) }}"
    secret: "{{ azure_secret | default(omit) }}"
    subscription_id: "{{ azure_subscription_id }}"
    tags: "{{ azure_tags | default(omit) }}"
    tenant: "{{ azure_tenant | default(omit) }}"
    # module-specific
    app_settings: "{{ azure_webapp_app_settings | default(omit) }}"
    app_state: "{{ azure_webapp_app_state | default(omit) }}"
    client_affinity_enabled: "{{ azure_webapp_client_affinity_enabled | default(omit) }}"
    container_settings: "{{ azure_webapp_container_settings | default(omit) }}"
    deployment_source: "{{ azure_webapp_deployment_source | default(omit) }}"
    dns_registration: "{{ azure_webapp_dns_registration | default(omit) }}"
    frameworks: "{{ azure_webapp_frameworks | default(omit) }}"
    https_only: "{{ azure_webapp_https_only | default(omit) }}"
    location: "{{ azure_location_normalized | default('southcentralus') }}"
    name: "{{ azure_webapp_name }}"
    plan: "{{ azure_webapp_plan | default(omit) }}"
    purge_app_settings: "{{ azure_webapp_purge_app_settings | default(omit) }}"
    resource_group: "{{ azure_resource_group_name }}"
    scm_type: "{{ azure_webapp_scm_type | default(omit) }}"
    skip_custom_domain_verification: "{{ azure_webapp_skip_custom_domain_verification | default(omit) }}"
    startup_file: "{{ azure_webapp_startup_file | default(omit) }}"
    state: "{{ azure_webapp_state | default('present') }}"
    ttl_in_seconds: "{{ azure_webapp_ttl_in_seconds | default(omit) }}"
EXPECTED RESULTS

I expect to be able to deploy a web app to a Linux App Service Plan with Python framework support that is consistent with the Azure Portal GUI experience.

ACTUAL RESULTS
TASK [AZURE_RM_WEBAPP | Create (or update) Web App] *********************************************************************************************************************
task path: /home/ben/workspace/kiewit/ansible/playbooks/ap_azure/plays/tasks/web_app.yml:3
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: ben
<localhost> EXEC /bin/sh -c 'echo ~ben && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/ben/.ansible/tmp `"&& mkdir "` echo /home/ben/.ansible/tmp/ansible-tmp-1679592921.2267013-420647-192887
409782236 `" && echo ansible-tmp-1679592921.2267013-420647-192887409782236="` echo /home/ben/.ansible/tmp/ansible-tmp-1679592921.2267013-420647-192887409782236 `" ) && s
leep 0'
Using module file /home/ben/workspace/kiewit/ansible/playbooks/ap_azure/collections/ansible_collections/azure/azcollection/plugins/modules/azure_rm_webapp.py
<localhost> PUT /home/ben/.ansible/tmp/ansible-local-4202131j57g_8j/tmprykt_am9 TO /home/ben/.ansible/tmp/ansible-tmp-1679592921.2267013-420647-192887409782236/AnsiballZ
_azure_rm_webapp.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/ben/.ansible/tmp/ansible-tmp-1679592921.2267013-420647-192887409782236/ /home/ben/.ansible/tmp/ansible-tmp-1679592921.226701
3-420647-192887409782236/AnsiballZ_azure_rm_webapp.py && sleep 0'
<localhost> EXEC /bin/sh -c 'python /home/ben/.ansible/tmp/ansible-tmp-1679592921.2267013-420647-192887409782236/AnsiballZ_azure_rm_webapp.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/ben/.ansible/tmp/ansible-tmp-1679592921.2267013-420647-192887409782236/ > /dev/null 2>&1 && sleep 0'
fatal: [localhost]: FAILED! => changed=false 
  invocation:
    module_args:
      ad_user: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
      adfs_authority_url: null
      always_on: null
      api_profile: latest
      app_settings:
        ApplicationInsightsAgent_EXTENSION_VERSION: ~2
      app_state: started
      append_tags: true
      auth_source: auto
      cert_validation_mode: validate
      client_affinity_enabled: true
      client_id: null
      cloud_environment: AzureCloud
      container_settings: null
      deployment_source: null
      dns_registration: null
      frameworks:
      - name: python
        settings: null
        version: '3.1'
      ftps_state: null
      https_only: true
      location: southcentralus
      log_mode: null
      log_path: null
      min_tls_version: null
      name: wa-lab-scus-mol-baw
      password: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
      plan: sp-lab-scus-mol-baw
      profile: null
      purge_app_settings: false
      resource_group: rg-lab-scus-mol-baw
      scm_type: null
      secret: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
      skip_custom_domain_verification: null
      startup_file: null
      state: present
      subscription_id: REDACTED
      tags:
        Application: MOL
        CostRecovery: KTGO
      tenant: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
      ttl_in_seconds: null
  msg: Unsupported framework python for Linux web app.

I also note in the above that whilst I specified

frameworks:
  - name: python
    version: 3.10

The module output seems to have truncated the floating point number 3.10 down to 3.1. Perhaps this must, in fact, be a string value?

@Fred-sun
Copy link
Collaborator

@watsonb Thank you very much for reporting this problem, which seems to be caused by service changes. I can confirm that the windows system supports python2.7, but does not support python3.10. I need to consider how to deal with it. You are also welcome to improve this problem or put forward valuable suggestions, thank you very much!

@Fred-sun Fred-sun added medium_priority Medium priority work in In trying to solve, or in working with contributors bug Something isn't working labels Mar 27, 2023
@watsonb
Copy link
Contributor Author

watsonb commented Mar 27, 2023

@Fred-sun greetings. My primary goal here was to be able to deploy a Python 3.10 framework onto a Linux-based App Service Plan. After installing azure.azcollection==1.11.0 via ansible-galaxy collection install, I navigated to collections/ansible_collections/azure/azcollection/plugins/modules/azure_rm_webapp.py and modified line 586 from

        self.supported_linux_frameworks = ['ruby', 'php', 'dotnetcore', 'node', 'java']

to

        self.supported_linux_frameworks = ['ruby', 'php', 'python', 'dotnetcore', 'node', 'java']

Prior to this change, I deployed a webapp with the node==6.9 framework:

image
image

After I made the above code change, updated my inventory to change the framework from node==6.9 to python==3.10 and re-ran my playbook. I can confirm in the Azure portal that the framework is deployed:

image

This seems like a simple one-line change to built-in error checking. As for enhanced error checking on versions, I feel that would be difficult to keep up with given the speed of changes to Azure. I would "leave it as an exercise to the end user" to understand what versions of frameworks are supported on App Service Plan platforms. That being said, I would update documentation to refer to correct version schemes for Python (e.g. 2.7, 3.8, 3.10) and encourage end users to pass these versions in as a string (e.g. '3.10' instead of 3.10) as this module will treat the non-string 3.10 as a float and actually pass 3.1 to Azure.

I have NOT tested Python 2.7 on Windows at this time, but it is something I can test later on today.

I can try to fork this repo, make the code changes, and submit a PR. But I just wanted to point this out in the event I am too bogged down with other work to do it.

@Fred-sun
Copy link
Collaborator

@watsonb Thanks for your comments, and you're welcome to contribute!

@watsonb
Copy link
Contributor Author

watsonb commented Mar 27, 2023

I've submitted PR #1128

@Fred-sun Fred-sun added has_pr PR fixes have been made and removed work in In trying to solve, or in working with contributors labels Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working has_pr PR fixes have been made medium_priority Medium priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants