簡體   English   中英

ansible-galaxy - 指定要安裝的版本范圍

[英]ansible-galaxy - specify version range to install

我正在嘗試安裝 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 的解決方案

如您嘗試安裝的角色的存儲庫首頁所述:

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


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

當 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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM