4

When downloading roles it's possible to specify roles. One of several ways would be with the following requirements.yml file:

---
- src: https://github.com/jdauphant/ansible-role-ssl-certs
  version: v1.5.2

This role could then be downloaded with the following command:

ansible-galaxy install -r requirements.yml

How do you then specify which version of a role to use in an Ansible playbook?

  roles:
    - jdauphant.ssl-certs
4

1 回答 1

5

没有选项可以以相同的名称保存不同版本的 playbook,然后指定在 playbook 中运行哪个版本。

你可以:

  • roles通过下载到项目目录的子目录(包含剧本的目录),将特定角色版本“绑定”到剧本。Ansible 会在尝试系统roles目录中的角色之前使用这个版本。

    添加pathrequirements.yml

    - src: https://github.com/jdauphant/ansible-role-ssl-certs
      version: v1.5.2
      path: roles/
    
  • 在系统范围内以不同的名称(即在不同的目录中)保存不同的版本:

    - src: https://github.com/jdauphant/ansible-role-ssl-certs
      version: v1.5.2
      name: jdauphant.ssl-certs-1.5.2
    

    并引用一个特定的名称:

    roles:
       - jdauphant.ssl-certs-1.5.2
    
于 2016-08-21T09:04:03.290 回答