Search code examples
azureansibleyamlansible-inventory

Ansible inventory plugin for azure throws encoding error


From what I understand using ansible-inventory-plugins over dynamic-inventory-provisioners is the new way of handling dynamic hosts, as of cloud providers and so on.

So, at first I've set the azure credentials in my environment:

 ± env | grep AZ
AZURE_SECRET=asdf
AZURE_TENANT=asdf
AZURE_SUBSCRIPTION_ID=asdf
AZURE_CLIENT_ID=asdf

Next, I've written an ansible.cfg with the following content:

± cat ansible.cfg
[inventory]
enable_plugins = azure_rm

Finally I wrote the yaml file with the minimum setting as shown at the ansible inventory plugin page:

± cat foo.azure_rm.yaml 
---
plugin: azure_rm

When I am running the ansible-inventory binary on that file, I get:

± ansible-inventory -i foo.azure_rm.yaml --list
 [WARNING]:  * Failed to parse /path/to/foo.azure_rm.yaml with azure_rm plugin: Unicode-objects must be encoded before hashing

 [WARNING]: Unable to parse /path/to/foo.azure_rm.yaml as an inventory source

 [WARNING]: No inventory was parsed, only implicit localhost is available

{
    "_meta": {
        "hostvars": {}
    },
    "all": {
        "children": [
            "ungrouped"
        ]
    },
    "ungrouped": {}
}

Summing up: The main problem seems to be the line:

[WARNING]:  * Failed to parse /path/to/foo.azure_rm.yaml with azure_rm plugin: Unicode-objects must be encoded before hashing

Help, anyone?


Solution

  • I've fixed it in a github fork and use pipenv to include this version in my environment. Actually it should be a backup port from devel, where the problem is already fixed. Maybe I'll fix this during the coming days and do a PR at ansible to include it into stable-2.7, but maybe the better option is to wait for 2.8 in May.