ansible / ansible-modules-core

Ansible modules - these modules ship with ansible
1.3k stars 1.95k forks source link

azure_rm_storageaccount throws SkuName' is not defined #5284

Closed michelleperz closed 7 years ago

michelleperz commented 7 years ago

Moving #17949 to the correct location with my own information.

ISSUE TYPE

azure_rm_storageaccount

ANSIBLE VERSION
ansible 2.2.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
OS / ENVIRONMENT

RHEL 7

SUMMARY

Using a similar example to the one found in the Azure guide, I receive a module failure that the SkuName is not defined

- name: testing storage module 
  hosts: localhost
  tasks:
  - name: Create storage account
    azure_rm_storageaccount:
      resource_group: mperz
      name: testing
      account_type: Standard_GRS
      state: present
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_Bb1sra/ansible_module_azure_rm_storageaccount.py", line 442, in <module>
    main()
  File "/tmp/ansible_Bb1sra/ansible_module_azure_rm_storageaccount.py", line 439, in main
    AzureRMStorageAccount()
  File "/tmp/ansible_Bb1sra/ansible_module_azure_rm_storageaccount.py", line 180, in __init__
    for key in SkuName:
NameError: global name 'SkuName' is not defined

fatal: [localhost]: FAILED! => {
    "changed": false, 
    "failed": true, 
    "invocation": {
        "module_name": "azure_rm_storageaccount"
    }, 
    "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_Bb1sra/ansible_module_azure_rm_storageaccount.py\", line 442, in <module>\n    main()\n  File \"/tmp/ansible_Bb1sra/ansible_module_azure_rm_storageaccount.py\", line 439, in main\n    AzureRMStorageAccount()\n  File \"/tmp/ansible_Bb1sra/ansible_module_azure_rm_storageaccount.py\", line 180, in __init__\n    for key in SkuName:\nNameError: global name 'SkuName' is not defined\n", 
    "module_stdout": "", 
    "msg": "MODULE FAILURE"
}
Additional Info
pip freeze|grep azure
azure==2.0.0rc5
azure-batch==0.30.0rc5
azure-common==1.1.4
azure-graphrbac==0.30.0rc5
azure-mgmt==0.30.0rc5
azure-mgmt-authorization==0.30.0rc5
azure-mgmt-batch==0.30.0rc5
azure-mgmt-cdn==0.30.0rc5
azure-mgmt-cognitiveservices==0.30.0rc5
azure-mgmt-commerce==0.30.0rc5
azure-mgmt-compute==0.30.0rc5
azure-mgmt-keyvault==0.30.0rc5
azure-mgmt-logic==0.30.0rc5
azure-mgmt-network==0.30.0rc5
azure-mgmt-notificationhubs==0.30.0rc5
azure-mgmt-nspkg==1.0.0
azure-mgmt-powerbiembedded==0.30.0rc5
azure-mgmt-redis==0.30.0rc5
azure-mgmt-resource==0.30.0rc5
azure-mgmt-scheduler==0.30.0rc5
azure-mgmt-storage==0.30.0rc5
azure-mgmt-web==0.30.0rc5
azure-nspkg==1.0.0
azure-servicebus==0.20.2
azure-servicemanagement-legacy==0.20.3
azure-storage==0.32.0

This happens regardless of which account_type you select.

bearrito commented 7 years ago

Is the local connection pointed at an the system python?

Are you running ansible in a virtualenv ?

ansibot commented 7 years ago

@ansible, ping. This issue is waiting on your response. click here for bot help

michelleperz commented 7 years ago

@bearrito I'm running this from Tower which does have Ansible in a virtualenv. However, I can replicate outside of Tower as well.

gvilarino commented 7 years ago

Having exactly the same issue. Running ansible in latest Ubuntu 14.04 LTS

gvilarino commented 7 years ago

This fails on line 180 with SkuName not being defined. That should be imported from azure.mgmt.storage.models.storage_management_client_enums, but for some reason it doesn't seem to be working.

The bad thing about this is that the module is silently swallowing any kind of import error which makes it impossible to debug.

Please help?

My dep versions:

# pip freeze | grep azure
azure==2.0.0rc6
azure-batch==1.0.0
azure-common==1.1.4
azure-mgmt==0.30.0rc6
azure-mgmt-batch==1.0.0
azure-mgmt-compute==0.30.0rc6
azure-mgmt-keyvault==0.30.0rc6
azure-mgmt-logic==1.0.0
azure-mgmt-network==0.30.0rc6
azure-mgmt-nspkg==1.0.0
azure-mgmt-redis==1.0.0
azure-mgmt-resource==0.30.0rc6
azure-mgmt-scheduler==1.0.0
azure-mgmt-storage==0.30.0rc6
azure-nspkg==1.0.0
azure-servicebus==0.20.3
azure-servicemanagement-legacy==0.20.4
gvilarino commented 7 years ago

Maybe @chouseknecht or @nitzmahone can lend a hand?

nitzmahone commented 7 years ago

Yeah, a number of folks have run into this. Microsoft's complex deps chain doesn't always install correctly (likely due to a pip shortcoming/bug)- manually installing msrestazure fixes this issue. Do pip install msrestazure and all should be well. Here's the link to the bug on their side: https://github.com/Azure/azure-sdk-for-python/issues/644

gvilarino commented 7 years ago

Thanks @nitzmahone that did make the error go away, but now I'm seeing something else:

"msg": "Error retrieving resource group testinggroup - global name 'self' is not defined"

I'm sure that resource group exists and with the same name; I'm seeing it now though the portal. My playbook looks like this:

---
- hosts: local
  gather_facts: False

  tasks:
    - name: Create storage account
      azure_rm_storageaccount:
        type: Standard_LRS
        name: mytestingaccount
        state: present
        resource_group: testinggroup
        subscription_id: edited
        client_id: edited
        secret: edited
        tenant: edited

Am I missing something?

nitzmahone commented 7 years ago

Yeah, looks like you'll get that with rc6. I'd suggest moving back to rc5 for now- the funny thing is it's failing in our code that prints an error when it checks the version number.

nitzmahone commented 7 years ago

Fixed by https://github.com/ansible/ansible/pull/18176

gvilarino commented 7 years ago

@nitzmahone ok, I tried that and even though I haven't been able to successfully use the module, I'm now seeing a permission error so it has to do with a different context. Thanks!

About what you posted: it sounds like your issue has to do with this: https://github.com/ansible/ansible/issues/17495 - I pinned docker-py to 1.9.0 and stuff seems to work (it's supposed to be fixed in 2.2, although I can't understand why there's no patch release with such a significant bugfix).

symgryph commented 7 years ago

I get this error with newest ansible on multiple platforms following directions on MAC/Debian 9. Can't ever get the modules to work.

Tried all the suggestions no workie. Is there a docker container where this works?

palmerabollo commented 6 years ago

@gvilarino I don't know what's the difference between this Azure/azure_preview_modules repo and the official ansible/* repo, but the SkuName import is not there in Azure's one...