ansible-galaxy - 指定要安装的版本范围

ansible-galaxy - specify version range to install

我正在尝试安装 Ansible Galaxy 集合,但我需要强制执行旧版本。 According to the documentation,我尝试了以下安装方式:

$ 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

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

Ansible weareinteractive.ufw role

来源: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/ufwhttps://github.com/weareinteractive/ansible-ufw


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

When the Galaxy server imports a role, it imports any git tags matching the Semantic Version format as versions. In turn, you can download a specific version of a role by specifying one of the imported tags.

来源: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

还有requirement.yml还有differs a bit,这里也要给个具体的verison。

- name: weareinteractive.ufw
  version: v1.10.0