簡體   English   中英

使用 ansible-galaxy 直接從 git URI 安裝 Ansible 集合

[英]Install Ansible collections directly from a git URI with ansible-galaxy

ansible-galaxy的文檔說明如下:

ansible-galaxy 命令與 Ansible 捆綁在一起,您可以使用它從 Galaxy 或直接從基於 git 的 SCM 安裝角色。 您還可以使用它在 Galaxy 網站上創建新角色、刪除角色或執行任務。

我試圖弄清楚如何“直接從基於 git 的 SCM ”安裝 Ansible 集合,如所示。 當我在 MacOS Catalina 上從 Ansible 2.9.1 運行ansible-galaxy collections --help ,我看到以下內容:

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,但ansible-galaxy嘗試查找名為我指定的 URI 的子文件夾,而不是識別有效的 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

暫無
暫無

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

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