gpt4 book ai didi

ansible - 使用 ansible-galaxy 直接从 git URI 安装 Ansible 集合

转载 作者:行者123 更新时间:2023-12-03 09:36:52 25 4
gpt4 key购买 nike

ansible-galaxy 的文档表示以下内容:

The ansible-galaxy command comes bundled with Ansible, and you can use it to install roles from Galaxy or directly from a git based SCM. You can also use it to create a new role, remove roles, or perform tasks on the Galaxy website.



我试图弄清楚如何“直接从基于 git 的 SCM”安装 Ansible 集合,如图所示。当我跑 ansible-galaxy collections --help ,从 MacOS Catalina 上的 Ansible 2.9.1 开始,我看到以下内容:
usage: ansible-galaxy collection install [-h] [-s API_SERVER]
[--api-key API_KEY] [-c] [-v] [-f]
[-i] [-n | --force-with-deps]
[-p COLLECTIONS_PATH]
[-r REQUIREMENTS]
[collection_name [collection_name ...]]

positional arguments:
collection_name The collection(s) name or path/url to a tar.gz
collection artifact. This is mutually exclusive with
--requirements-file.

optional arguments:
-h, --help show this help message and exit
-s API_SERVER, --server API_SERVER
The Galaxy API server URL
--api-key API_KEY The Ansible Galaxy API key which can be found at
https://galaxy.ansible.com/me/preferences. You can
also use ansible-galaxy login to retrieve this key or
set the token for the GALAXY_SERVER_LIST entry.
-c, --ignore-certs Ignore SSL certificate validation errors.
-v, --verbose verbose mode (-vvv for more, -vvvv to enable
connection debugging)
-f, --force Force overwriting an existing role or collection
-i, --ignore-errors Ignore errors during installation and continue with
the next specified collection. This will not ignore
dependency conflict errors.
-n, --no-deps Don't download collections listed as dependencies.
--force-with-deps Force overwriting an existing collection and its
dependencies.
-p COLLECTIONS_PATH, --collections-path COLLECTIONS_PATH
The path to the directory containing your collections.
-r REQUIREMENTS, --requirements-file REQUIREMENTS
A file containing a list of collections to be
installed.

我尝试为 -p 指定一个 GitHub 存储库 URI参数,而不是识别有效的 URI, ansible-galaxy试图查看名为我指定的 URI 的子文件夹。
ansible-galaxy collection install -p https://github.com/pcgeek86/ansible-galaxy-test trevor.trevormacos

我的期望是为 -p 指定一个 GitHub 存储库 URI。参数应该正确地表明我想从该 GitHub 存储库安装一个集合。

问题 : 如何指导 ansible-galaxy直接从 GitHub URI 安装 Ansible 集合?

最佳答案

从最近的 Ansible 2.10 版开始,这现在是可能的。
见:https://github.com/ansible/ansible/pull/69154
要使用它,您需要指定类似于角色:

collections:
- name: git@github.com:my_org/private_collections.git#/path/to/collection,devel
- name: https://github.com/ansible-collections/amazon.aws.git
type: git
version: 8102847014fd6e7a3233df9ea998ef4677b99248

关于ansible - 使用 ansible-galaxy 直接从 git URI 安装 Ansible 集合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59003007/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com