2

我正在尝试安装 Ansible Galaxy 集合,但我需要强制使用旧版本。根据文档,我尝试通过以下方式执行安装:

$ ansible-galaxy collection install 'weareinteractive.ufw:>=1.10.0,<2.0.0'
Process install dependency map
ERROR! Failed to find collection weareinteractive.ufw:>=1.10.0,<2.0.0
$ ansible-galaxy collection install 'weareinteractive.ufw:<2.0.0'
Process install dependency map
ERROR! Failed to find collection weareinteractive.ufw:<2.0.0

当我尝试从这里做同样的事情时,我在全球范围内得到了同样的错误requirements.yml

---
- name: weareinteractive.ufw
  version: '>=1.8.0,<2.0.0'

运行命令

$ ansible-galaxy install -r requirements.yml
- downloading role 'ufw', owned by weareinteractive
[WARNING]: - weareinteractive.ufw was NOT installed successfully: - the specified version (>=1.8.0,<2.0.0) of weareinteractive.ufw was not found in the list of available versions ([{'id': 141713, 'url': '', 'related': {}, 'summary_fields': {}, 'created':
'2020-11-25T18:52:30.171540Z', 'modified': '2020-11-25T18:52:30.171568Z', 'name': '2.0.1', 'version': '2.0.1', 'commit_date': '2020-11-25T10:51:53-05:00', 'commit_sha': '30b1fdc8f5440e865d3fbeb83894941bf70739c7', 'download_url':
'https://github.com/weareinteractive/ansible-ufw/archive/2.0.1.tar.gz', 'active': None}, {'id': 76043, 'url': '', 'related': {}, 'summary_fields': {}, 'created': '2018-10-04T14:07:47.602784Z', 'modified': '2018-10-04T14:07:47.602810Z', 'name': '1.8.0', 'version':
'1.8.0', 'commit_date': '2018-10-04T10:05:07-04:00', 'commit_sha': 'ae776a7dc255ba5dc679cedee32129ba22c0e797', 'download_url': 'https://github.com/weareinteractive/ansible-ufw/archive/1.8.0.tar.gz', 'active': None}, .....]).
ERROR! - you can use --ignore-errors to skip failed roles and finish processing the list.

我错过了什么?

编辑:我正在使用 ansible / ansible-galaxy 2.9.16 但我希望有一个仍然适用于 ansible 2.10 的解决方案

4

1 回答 1

4

如您尝试安装的角色的存储库首页所述:

Ansible weareinteractive.ufw 角色

来源:https ://github.com/weareinteractive/ansible-ufw#ansible-weareinteractiveufw-role

它是一个角色而不是一个集合。

尽管这两种语法可能看起来很相似,但它们实际上并不完全具有相同的语法。
对于角色,首先,您不要通过以下方式安装它们

ansible-galaxy collection install some-collection

显然,但通过:

ansible-galaxy install some-role

注意:他们的 GitHub 页面和 Ansible Galaxy 页面都证实了这一点,建议您通过以下方式安装角色

ansible-galaxy install weareinteractive.ufw

资料来源:https ://galaxy.ansible.com/weareinteractive/ufw 和https://github.com/weareinteractive/ansible-ufw


然后,版本固定也不同。在角色上,您必须指定版本,而不是版本范围:

当 Galaxy 服务器导入一个角色时,它会将任何与语义版本格式匹配的 git 标签作为版本导入。反过来,您可以通过指定其中一个导入的标签来下载角色的特定版本。

来源:https ://docs.ansible.com/ansible/latest/galaxy/user_guide.html#installing-a-specific-version-of-a-role

所以你必须以他们的仓库的 git 标签为基础,例如

ansible-galaxy install weareinteractive.ufw,v1.10.0

并且requirements.yml有所不同,您还必须提供特定的版本。

- name: weareinteractive.ufw
  version: v1.10.0
于 2021-01-30T17:48:45.967 回答