0

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'?

4

2 回答 2

1

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.

于 2017-01-24T22:14:12.203 回答
0

So, thanks to Zlemini. So to clarify:

My ansible is actually was coming from Python 3.5 path. Even though default python was 2.7.10.

[arun@host ~/aks/dummy] $ python --version
Python 2.7.10
[arun@host ~/aks/dummy] $ python3 --version
Python 3.5.2
[arun@host ~/aks/dummy] $ 

[arun@host ~/aks/dummy] $ which ansible-galaxy
/Library/Frameworks/Python.framework/Versions/3.5/bin/ansible-galaxy
[arun@host ~/aks/dummy] $ 

[arun@host ~/aks/dummy] $ which ansible
/Library/Frameworks/Python.framework/Versions/3.5/bin/ansible

Running the same install command it from my other vagrant machine where, ansible was actually coming from /usr/bin/ansible, the command worked as expected.

$ ansible-galaxy install asangal.wavefront-ansible -p ~/aks/dummy
- downloading role 'wavefront-ansible', owned by asangal
- downloading role from https://github.com/asangal/wavefront-ansible/archive/master.tar.gz
- extracting asangal.wavefront-ansible to /home/vagrant/dummy/asangal.wavefront-ansible
- asangal.wavefront-ansible was installed successfully
[vagrant@myvagrant ~/aks/dummy] $ ls -l
total 4
drwxrwxr-x. 9 vagrant vagrant 4096 Jan 24 23:16 asangal.wavefront-ansible
于 2017-01-24T23:22:49.117 回答