預設路徑安裝內容集

  1. 設定 Collections 路徑:修改工作目錄下的 ansible.cfg,設定內容集的路徑為 ~/ansible/collections
    [deyu1@kvm19 ansible]$ vim ansible.cfg
    [deyu1@kvm19 ansible]$ grep ^collection ansible.cfg
    collections_path=~/ansible/collections
    
  2. 查看工作目錄 ~/ansible 中沒有 collections 次目錄。
    [deyu1@kvm19 ansible]$ ll
    total 48
    -rw-r--r--. 1 deyu1 deyu1    13 Feb 20 10:36 adhoc.txt
    -rw-r--r--. 1 deyu1 deyu1 38850 Feb 20 18:34 ansible.cfg
    -rw-r--r--. 1 deyu1 deyu1   129 Feb 18 10:49 inventory
    drwxr-xr-x. 2 deyu1 deyu1     6 Feb 18 11:32 roles
    
  3. 不指定路徑安裝 mynmspace.mycollect:1.0.0
    [deyu1@kvm19 ansible]$ ansible-galaxy collection install \ 
    http://dywang.csie.cyut.edu.tw/materials/mynmspace-mycollect-1.0.0.tar.gz
    Downloading http://dywang.csie.cyut.edu.tw/materials/mynmspace-mycollect-1.0.0.tar.gz to 
    /home/deyu1/.ansible/tmp/ansible-local-22956ce4nf82/tmp2k57mqnm/mynmspace-mycollect-1.0.0-89_b1sqk
    Starting galaxy collection install process
    Process install dependency map
    Starting collection install process
    Installing 'mynmspace.mycollect:1.0.0' to 
    '/home/deyu1/ansible/collections/ansible_collections/mynmspace/mycollect'
    mynmspace.mycollect:1.0.0 was installed successfully
    
  4. 安裝時沒指定安裝路徑,預設安裝在 ansible.cfg 設定的路徑 ~/ansible/collections/,不用先建目錄 ~/ansible/collections,安裝時會自動產生。
    [deyu1@kvm19 ansible]$ ansible-galaxy collection list
    
    # /home/deyu1/ansible/collections/ansible_collections
    Collection          Version
    ------------------- -------
    mynmspace.mycollect 1.0.0
    
  5. 查看目錄 ~/ansible/collections 下安裝的內容集檔案。
    [deyu1@kvm19 ansible]$ tree collections/
    collections/
    └── ansible_collections
        └── mynmspace
            └── mycollect
                ├── docs
                ├── FILES.json
                ├── MANIFEST.json
                ├── plugins
                │   └── README.md
                ├── README.md
                └── roles
    
    6 directories, 4 files