ansible-galaxy 初始化安装失败 - 无法从 API 服务器获取数据 - 需要一个类似字节的对象,而不是"str"



ansible: ansible-galaxy 2.2.0.0

python: Python 2.7.10

我尝试了 ansible-galaxy 命令来创建新的角色结构(init命令),但它失败并显示以下消息。因此,我在网上查看并尝试了--offline选项和结构创建部分。

到目前为止,我有我的 Github 存储库:https://github.com/asangal/wavefront-ansible

角色在Ansible Galaxy的Browse Roles下也可见。

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

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

按照说明,我正在尝试通过运行来运行安装步骤但它再次失败,并显示相同的错误消息,如下所示。

$ 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(使用--ignore-errors-p <role_path>选项,但没有帮助)

$ 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/似乎工作正常。

为什么我会收到此错误:Failed to get data from the API server (https://galaxy.ansible.com/api/): a bytes-like object is required, not 'str'

你的角色在 Python 2.7.13 中对我来说下载得很好。

bytes-like object is required, not 'str'与 Python3 相关,我怀疑如果你使用 Python 2.x,你应该没问题。

所以,感谢兹莱米尼。所以澄清一下:

我的 ansible 实际上来自 Python 3.5 路径。即使默认的python是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

运行相同的install命令它从我的另一台流浪机器上,ansible实际上来自/usr/bin/ansible,该命令按预期工作。

$ 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

相关内容

最新更新