ansible-2.xansible-galaxytelegrafwavefront-telegraf

ansible-galaxy failing for init install - Failed to get data from the API server - a bytes-like object is required, not 'str'


ansible: ansible-galaxy 2.2.0.0

python: Python 2.7.10

I tried ansible-galaxy command to create a new role structure (init command) but it failed with the following message. So, I looked online and tried --offline option and structure creation part worked.

So far, I have my Github repo: https://github.com/asangal/wavefront-ansible

Role is also visible in Ansible Galaxy under Browse Roles.

https://galaxy.ansible.com/list#/roles?page=1&page_size=10&autocomplete=wavefront or

https://galaxy.ansible.com/asangal/wavefront-ansible/

As per the instructions, I'm trying to run the install step by running but it failed again with the same error message as shown below.

$ ansible-galaxy install asangal.wavefront-ansible
 [WARNING]: - asangal.wavefront-ansible was NOT installed successfully: Failed to get data from the API server (https://galaxy.ansible.com/api/): a bytes-like object is
required, not 'str'

ERROR! - you can use --ignore-errors to skip failed roles and finish processing the list.

OR (used --ignore-errors and -p <role_path> options but it didn't help)

$ ansible-galaxy install asangal.wavefront-ansible --ignore-errors -p ~/aks/dummy
 [WARNING]: - asangal.wavefront-ansible was NOT installed successfully: Failed to get data from the API server (https://galaxy.ansible.com/api/): a bytes-like object is
required, not 'str'

[arun@vagrant ~/aks/dummy] $ ls -l
[arun@vagrant ~/aks/dummy] $

curl -v https://galaxy.ansible.com/asangal/wavefront-ansible/ seems to work fine.

Why am I getting this error: Failed to get data from the API server (https://galaxy.ansible.com/api/): a bytes-like object is required, not 'str'?


Solution

  • Your role downloads fine for me with Python 2.7.13.

    The bytes-like object is required, not 'str' is Python3 related, i suspect you should be ok if you use Python 2.x.