每日學習-ansible yum_repository模塊

yum_repository模塊用於在基於RPM的Linux發行版中添加或刪除YUM倉庫。

yum_repository模塊常用參數

name:必須參數,指定唯一的倉庫ID,state爲present或absent時需要設置name參數
baseurl:指定yum倉庫repodata目錄的URL,可以是多個,如果設置爲多個,需要使用"metalink"和"mirrorlist"參數
enabled:使用此yum倉庫
gpgcheck:是否對軟件包執行gpg簽名檢查
gpgkey:gpg祕鑰的URL
mode:權限設置,當設置爲preserve時,文件將與源文件權限相同
file:用於設置倉庫的配置文件名稱,即設置”.repo”配置文件的文件名前綴,在不使用此參數的情況下,默認以 name 參數的倉庫ID作爲”.repo”配置文件的文件名前綴,同一個”.repo” 配置文件中可以存在多個 yum 源
state:狀態,默認的present爲安裝此yum倉庫,absent爲刪除此yum倉庫
description:設置倉庫的註釋信息
async:如果yum倉庫支持並行,yum將並行下載軟件包和元數據
bandwidth:與throttle參數一起使用,限制yum可用的網絡帶寬









yum_repository模塊示例
安裝yum倉庫

  - name: install yum repo 
    yum_repository:
      name: rh294_BASE
      state: present
      description: RHCE8.0 test
      baseurl: http://content.example.com/rhel8.0/x86_64/dvd/BaseOS
      gpgcheck: yes
      gpgkey: http://content.example.com/rhel8.0/x86_64/dvd/RPM-GPG-KEY-redhat-releas
      enabled: yes

卸載yum倉庫

  tasks:
  - name: uninstall yum repo
    yum_repository:
      name: rh294_BASE
      state: absent
    notify: yum-clean-metadata
  handlers:
    - name: clean yum cache
      shell: yum clean metadata 

參考:ansible-doc yum_repository

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章