Traceback in azure_rm.py on Centos 7.3 with Azure python SDK rc6

Hi there,

I am trying to install Ansible on a clean, yum-updated CentOS 7.3 machine with the Azure modules, but azure_rm.py refuses to work. I installed the Azure SDK version rc6, and I could not spot any error. I am using file based authentication (~/.azure/credentials), with a file that works in another host. However, azure_rm.py will break:

[jose@vm-00 ~]$ python ./ansible/contrib/inventory/azure_rm.py --list
Traceback (most recent call last):
File “./ansible/contrib/inventory/azure_rm.py”, line 205, in
from azure.common.credentials import ServicePrincipalCredentials, UserPassCredentials
File “/usr/lib/python2.7/site-packages/azure/common/credentials.py”, line 28, in
from msrestazure.azure_active_directory import (
File “/usr/lib/python2.7/site-packages/msrestazure/azure_active_directory.py”, line 35, in
import keyring
File “/usr/lib/python2.7/site-packages/keyring/init.py”, line 6, in
from .core import (set_keyring, get_keyring, set_password, get_password,
File “/usr/lib/python2.7/site-packages/keyring/core.py”, line 149, in
init_backend()
File “/usr/lib/python2.7/site-packages/keyring/core.py”, line 65, in init_backend
keyrings = filter(limit, backend.get_all_keyring())
File “/usr/lib/python2.7/site-packages/keyring/util/init.py”, line 20, in wrapper
func.always_returns = func(*args, **kwargs)
File “/usr/lib/python2.7/site-packages/keyring/backend.py”, line 179, in get_all_keyring
_load_backends()
File “/usr/lib/python2.7/site-packages/keyring/backend.py”, line 139, in _load_backends
list(map(_load_backend, backends))
File “/usr/lib/python2.7/site-packages/keyring/backend.py”, line 131, in _load_backend
mod = importlib.import_module(‘.’+name, package)
File “/usr/lib64/python2.7/importlib/init.py”, line 37, in import_module
import(name)
File “/usr/lib/python2.7/site-packages/keyring/backends/SecretService.py”, line 9, in
import secretstorage
File “/usr/lib/python2.7/site-packages/secretstorage/init.py”, line 14, in
from secretstorage.collection import Collection, create_collection,
File “/usr/lib/python2.7/site-packages/secretstorage/collection.py”, line 21, in
from secretstorage.item import Item
File “/usr/lib/python2.7/site-packages/secretstorage/item.py”, line 15, in
from secretstorage.util import InterfaceWrapper, bus_get_object,
File “/usr/lib/python2.7/site-packages/secretstorage/util.py”, line 14, in
from secretstorage.dhcrypto import Session, int_to_bytes
File “/usr/lib/python2.7/site-packages/secretstorage/dhcrypto.py”, line 36, in
DH_PRIME_1024 = int_from_bytes(bytearray(DH_PRIME_1024_BYTES), ‘big’)
File “/usr/lib64/python2.7/site-packages/cryptography/utils.py”, line 50, in int_from_bytes
return int(data.encode(‘hex’), 16)
AttributeError: ‘bytearray’ object has no attribute ‘encode’

Any idea what is missing?

Thanks!

The doc is pretty clear about the supported Azure version beeting 2.0.0rc5. The python modules for Azure har unfortunately known for breaking changes betweens minor versions, so there’s no way the Ansible modules will keep up with all the changes. Solution: Uninstall your current packages, and install 2.0.0rc5. rc5 has some include issues so you probably have to manually add some extra packages, but errors about that should be surfaced by Ansible. You can also manually verify by starting up python and try to import a module such as:
import msrestazure.azure_exceptions