requirements.yml

  1. 除了直接從網站下載安裝角色外,也可同時將多個安裝來源及參數寫成 YAML 格式檔,而且副檔名一定要 .yml 或 .yaml。
  2. 通常 ansible-galaxy 安裝要求檔命名成 requirements.yml,以選項 -r 指定此檔案進行安裝。
    $ ansible-galaxy install -r requirements.yml
    
  3. requirements.yml 屬性:
    1. src:必要屬性,指定安裝角色的來源。
    2. scm:如果 src 是 URL,必須指定 scm 是 git 或 hg。
    3. version:角色的版本。
    4. name:角色的名稱。
  4. requirements.yml 範例:
    # from galaxy
    - src: yatesr.timezone
    
    # from GitHub
    - src: https://github.com/bennojoy/mysql
    
    # from GitHub, overriding the name and specifying a specific tag
    - src: https://github.com/bennojoy/mysql
      version: master
      name: mysql_role
    
    # from a webserver, where the role is packaged in a tar.bz2
    - src: https://dywang.csie.cyut.edu.tw/materials/haproxy.tar.bz2
      name: haproxy-role
    
    # from Bitbucket
    - src: git+http://bitbucket.org/willthames/git-ansible-galaxy
      version: v1.4
    
    # from Bitbucket, alternative syntax and caveats
    - src: http://bitbucket.org/willthames/hg-ansible-galaxy
      scm: hg
    
    # from GitLab or other git-based scm
    - src: git@gitlab.company.com:mygroup/ansible-base.git
      scm: git
      version: "0.1" #quoted, so YAML doesn't parse this as a floating-point value