ansible - 如何使用与 git url 不同的名称安装 galaxy 角色?

标签 ansible ansible-galaxy

有个galaxy角色:git@site.net/ansible-myapp.git

我可以这样安装:

ansible-galaxy install git+git@site.net/ansible-myapp.git

,但它创建了一个名为“ansible-myapp”的角色。

如何安装与 git url 中名称不同的角色?

可以通过 requirements.yml 来完成:

- src: git@site.net/ansible-myapp.git
  scm: git
  name: myapp

ansible-galaxy install -r requirements.yml 将使用名称“myapp”安装它

但是如何在没有 requirements.yml 文件的情况下用一条命令完成呢?

最佳答案

official doc 中推断出来,通过反复试验发现了这个实际上未记录的功能(至少我没有找到文档)

在版本后添加所需的名称。

ansible-galaxy role install git+git@site.net/ansible-myapp.git,master,myapp

这将使用指定版本将角色安装为 myapp。对于 master 版本,如果这是默认的存储库分支,您可以传递一个默认为它的空版本:

ansible-galaxy role install git+git@site.net/ansible-myapp.git,,myapp

这是通过以下方式测试的:

$ ansible-galaxy --version
ansible-galaxy 2.9.10
  config file = None
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/dist-packages/ansible
  executable location = /usr/local/bin/ansible-galaxy
  python version = 3.6.9 (default, Apr 18 2020, 01:56:04) [GCC 8.4.0]

注意:在上述命令行中引入了TYPE位置参数role来区分角色和集合,如果省略则默认为role(为了与以前的ansible兼容星系版本)

关于ansible - 如何使用与 git url 不同的名称安装 galaxy 角色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62578842/

相关文章:

ubuntu - 无法在 vagrant box 上运行 ansible adhoc 命令?

ansible - 如何进入Digital Ocean代币?

github - Ansible github_packages

package - Ansible Galaxy 角色版本的定义是什么?

ansible-galaxy 集合安装超时

python - 在 Centos 或 Redhat 上使用 ansible core 的 pip 和 virtualenv

基于平台的 Ansible 条件用户

Ansible 复制目录的最佳实践

kubernetes - Ansible Galaxy 角色安装到特定目录?

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