Azure-Samples / ansible-playbooks

Ansible Playbook Samples for Azure
MIT License
224 stars 349 forks source link

webapp.yml fails at TASK [Create App Service on Linux with Java Runtime] #81

Closed robcamer closed 4 years ago

robcamer commented 4 years ago

Please provide us with the following information:

This issue is for a: (mark with an x)

- [ X] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

  1. Install ansible locally, in cloud shell, or using the Ansible VM
  2. Verify ansible is running correctly by creating a resource group, etc.
  3. download the webapp.yml from the repo and run with ansible-playbook webapp.yml FIRST ERROR Variable 'resource_group_name' is not defined--> fixed (this is a bug) SECOND ERROR
  4. Define resource_group_name: "ansible-test-rg"
  5. Fails at step "TASK [Create App Service on Linux with Java Runtime] "

Any log messages given by the failure

WARNING]: No inventory was parsed, only implicit localhost is available [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all' [DEPRECATION WARNING]: azure_rm_webapp_facts is kept for backwards compatibility but usage is discouraged. The module documentation details page may explain more about this rationale.. This feature will be removed in a future release. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. [DEPRECATION WARNING]: azure_rm_trafficmanagerprofile_facts is kept for backwards compatibility but usage is discouraged. The module documentation details page may explain more about this rationale.. This feature will be removed in a future release. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.

PLAY [localhost] ****

TASK [Gathering Facts] ** ok: [localhost]

TASK [Create resource group] **** changed: [localhost]

TASK [Create resource group for app service plan] *** changed: [localhost]

TASK [Create App Service Plan] ** [WARNING]: The value 1 (type int) in a string field was converted to '1' (type string). If this does not look like what you expect, quote the entire value to ensure it does not change. changed: [localhost]

TASK [Create a Linux web app with Java framework and Tomcat] **** An exception occurred during task execution. To see the full traceback, use -vvv. The error was: azure.mgmt.web.models.default_error_response_py3.DefaultErrorResponseException: Operation returned an invalid status code 'Conflict' fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File \"/Users/robcamer/.ansible/tmp/ansible-tmp-1583114293.997421-20084909233583/AnsiballZ_azure_rm_webapp.py\", line 102, in \n _ansiballz_main()\n File \"/Users/robcamer/.ansible/tmp/ansible-tmp-1583114293.997421-20084909233583/AnsiballZ_azure_rm_webapp.py\", line 94, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/Users/robcamer/.ansible/tmp/ansible-tmp-1583114293.997421-20084909233583/AnsiballZ_azure_rm_webapp.py\", line 40, in invoke_module\n runpy.run_module(mod_name='ansible.modules.cloud.azure.azure_rm_webapp', init_globals=None, run_name='main', alter_sys=True)\n File \"/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py\", line 205, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File \"/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py\", line 96, in _run_module_code\n mod_name, mod_spec, pkg_name, script_name)\n File \"/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py\", line 85, in _run_code\n exec(code, run_globals)\n File \"/var/folders/7q/f0fk9fl96zs84r2qhy3xtybm0000gn/T/ansible_azure_rm_webapp_payload_08qtfwsh/ansible_azure_rm_webapp_payload.zip/ansible/modules/cloud/azure/azure_rm_webapp.py\", line 1070, in \n File \"/var/folders/7q/f0fk9fl96zs84r2qhy3xtybm0000gn/T/ansible_azure_rm_webapp_payload_08qtfwsh/ansible_azure_rm_webapp_payload.zip/ansible/modules/cloud/azure/azure_rm_webapp.py\", line 1066, in main\n File \"/var/folders/7q/f0fk9fl96zs84r2qhy3xtybm0000gn/T/ansible_azure_rm_webapp_payload_08qtfwsh/ansible_azure_rm_webapp_payload.zip/ansible/modules/cloud/azure/azure_rm_webapp.py\", line 548, in init\n File \"/var/folders/7q/f0fk9fl96zs84r2qhy3xtybm0000gn/T/ansible_azure_rm_webapp_payload_08qtfwsh/ansible_azure_rm_webapp_payload.zip/ansible/module_utils/azure_rm_common.py\", line 348, in init\n File \"/var/folders/7q/f0fk9fl96zs84r2qhy3xtybm0000gn/T/ansible_azure_rm_webapp_payload_08qtfwsh/ansible_azure_rm_webapp_payload.zip/ansible/modules/cloud/azure/azure_rm_webapp.py\", line 762, in exec_module\n File \"/var/folders/7q/f0fk9fl96zs84r2qhy3xtybm0000gn/T/ansible_azure_rm_webapp_payload_08qtfwsh/ansible_azure_rm_webapp_payload.zip/ansible/modules/cloud/azure/azure_rm_webapp.py\", line 851, in create_update_webapp\n File \"/usr/local/lib/python3.7/site-packages/azure/mgmt/web/operations/web_apps_operations.py\", line 332, in create_or_update\n **operation_config\n File \"/usr/local/lib/python3.7/site-packages/azure/mgmt/web/operations/web_apps_operations.py\", line 280, in _create_or_update_initial\n raise models.DefaultErrorResponseException(self._deserialize, response)\nazure.mgmt.web.models.default_error_response_py3.DefaultErrorResponseException: Operation returned an invalid status code 'Conflict'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

PLAY RECAP ** localhost : ok=4 changed=3 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

Expected/desired behavior

All tasks complete.

OS and Version?

Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?) macOs - Catalina, cloud shell, and Ansible VM in Azure Marketplace

Versions

ansible 2.9.5 "latest"

Mention any other details that might be useful

Here's the run in cloudshell: [WARNING]: No inventory was parsed, only implicit localhost is available [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all' [DEPRECATION WARNING]: azure_rm_webapp_facts is kept for backwards compatibility but usage is discouraged. The module documentation details page may explain more about this rationale.. This feature will be removed in a future release. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg. [DEPRECATION WARNING]: azure_rm_trafficmanagerprofile_facts is kept for backwards compatibility but usage is discouraged. The module documentation details page may explain more about this rationale.. This feature will be removed in a future release. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.

PLAY [localhost] *****

TASK [Gathering Facts] *** ok: [localhost]

TASK [Create resource group] ***** ok: [localhost]

TASK [Create resource group for app service plan] **** ok: [localhost]

TASK [Create App Service Plan] *** [WARNING]: The value 1 (type int) in a string field was converted to u'1' (type string). If this does not look like what you expect, quote the entire value to ensure it does not change. ok: [localhost]

TASK [Create a Linux web app with Java framework and Tomcat] ***** An exception occurred during task execution. To see the full traceback, use -vvv. The error was: azure.mgmt.web.models.default_error_response.DefaultErrorResponseException: Operation returned an invalid status code 'Conflict' fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File \"/home/rob/.ansible/tmp/ansible-tmp-1583115073.05-62974939462357/AnsiballZ_azure_rm_webapp.py\", line 102, in \n _ansiballz_main()\n File \"/home/rob/.ansible/tmp/ansible-tmp-1583115073.05-62974939462357/AnsiballZ_azure_rm_webapp.py\", line 94, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/home/rob/.ansible/tmp/ansible-tmp-1583115073.05-62974939462357/AnsiballZ_azure_rm_webapp.py\", line 40, in invoke_module\n runpy.run_module(mod_name='ansible.modules.cloud.azure.azure_rm_webapp', init_globals=None, run_name='main', alter_sys=True)\n File \"/usr/lib/python2.7/runpy.py\", line 188, in run_module\n fname, loader, pkg_name)\n File \"/usr/lib/python2.7/runpy.py\", line 82, in _run_module_code\n mod_name, mod_fname, mod_loader, pkg_name)\n File \"/usr/lib/python2.7/runpy.py\", line 72, in _run_code\n exec code in run_globals\n File \"/tmp/ansible_azure_rm_webapp_payload_jpoQtw/ansible_azure_rm_webapp_payload.zip/ansible/modules/cloud/azure/azure_rm_webapp.py\", line 1070, in \n File \"/tmp/ansible_azure_rm_webapp_payload_jpoQtw/ansible_azure_rm_webapp_payload.zip/ansible/modules/cloud/azure/azure_rm_webapp.py\", line 1066, in main\n File \"/tmp/ansible_azure_rm_webapp_payload_jpoQtw/ansible_azure_rm_webapp_payload.zip/ansible/modules/cloud/azure/azure_rm_webapp.py\", line 548, in init\n File \"/tmp/ansible_azure_rm_webapp_payload_jpoQtw/ansible_azure_rm_webapp_payload.zip/ansible/module_utils/azure_rm_common.py\", line 348, in init\n File \"/tmp/ansible_azure_rm_webapp_payload_jpoQtw/ansible_azure_rm_webapp_payload.zip/ansible/modules/cloud/azure/azure_rm_webapp.py\", line 762, in exec_module\n File \"/tmp/ansible_azure_rm_webapp_payload_jpoQtw/ansible_azure_rm_webapp_payload.zip/ansible/modules/cloud/azure/azure_rm_webapp.py\", line 851, in create_update_webapp\n File \"/opt/ansible/lib/python2.7/site-packages/azure/mgmt/web/operations/web_apps_operations.py\", line 332, in create_or_update\n **operation_config\n File \"/opt/ansible/lib/python2.7/site-packages/azure/mgmt/web/operations/web_apps_operations.py\", line 280, in _create_or_update_initial\n raise models.DefaultErrorResponseException(self._deserialize, response)\nazure.mgmt.web.models.default_error_response.DefaultErrorResponseException: Operation returned an invalid status code 'Conflict'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

PLAY RECAP *** localhost : ok=4 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0


Thanks! We'll be in touch soon.

Fred-sun commented 4 years ago

@robcamer Thanks for your take the time to report this issue! We will invetesting into this! Thank you very much!

Fred-sun commented 4 years ago

@robcamer Your replay steps were tested on the azure VM, and the test was successful. Can you uninstall the VM and try again? Thank you very much! ansible install:

    sudo pip install ansible[azure] -I
    mkdir webapp
    cd webapp/
    git clone https://github.com/Azure-Samples/ansible-playbooks
    vi webapp.yml
    ansible-galaxy install azure.azure_preview_modules
    pip install -r ~/.ansible/roles/azure.azure_preview_modules/files/requirements-azure.txt
    ansible-playbook  webapp.yml


azureuser@fredVM:~/webapp$ ansible-playbook  webapp.yml
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match
'all'

PLAY [localhost] **********************************************************************************************************

TASK [Gathering Facts] ****************************************************************************************************
ok: [localhost]

TASK [azure.azure_preview_modules : Install Azure Python SDK required by modules.] ****************************************

ok: [localhost]

TASK [azure.azure_preview_modules : debug] ********************************************************************************
skipping: [localhost]

TASK [Create resource group] **********************************************************************************************
ok: [localhost]

TASK [Create resource group for app service plan] *************************************************************************
ok: [localhost]

TASK [Create App Service Plan] ********************************************************************************************
[WARNING]: The value 1 (type int) in a string field was converted to '1' (type string). If this does not look like what
you expect, quote the entire value to ensure it does not change.
changed: [localhost]

TASK [Create a Linux web app with Java framework and Tomcat] **************************************************************
[WARNING]: The value 8 (type int) in a string field was converted to '8' (type string). If this does not look like what
you expect, quote the entire value to ensure it does not change.
changed: [localhost]

TASK [Get web app facts] **************************************************************************************************
ok: [localhost]

TASK [Create Traffic Manager Profile] *************************************************************************************
[WARNING]: Azure API profile latest does not define an entry for TrafficManagerManagementClient
changed: [localhost]

TASK [Add endpoint to traffic manager profile, using the web site created above] ******************************************
changed: [localhost]

TASK [Get Traffic Manager Profile facts] **********************************************************************************
ok: [localhost]

PLAY RECAP ****************************************************************************************************************
localhost                  : ok=10   changed=4    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0
robcamer commented 4 years ago

Hi there, Thank you. I've been testing today and I think that the issue is simply a matter of using unique names for app name, etc. for resources that need to be unique. Should have caught it but i realized it tonight so wanted to comment back. Thanks!