Ansible內(nèi)置模塊之yum_repository
發(fā)布作者:微思網(wǎng)絡(luò) 發(fā)布時(shí)間:2024-11-13 瀏覽量:0次
選項(xiàng) 必須 類型 默認(rèn)值 說明 file 否 str 無 保存?zhèn)}庫時(shí)所使用的文件名,不包含.repo。默認(rèn)值等同于 name 值 name 是 str 無 存儲(chǔ)庫的唯一名稱。將在/etc/yum.repos.d/下創(chuàng)建以此名稱命名的文件 description 否 str 無 存儲(chǔ)庫的描述。 baseurl 否 str 無 用于該存儲(chǔ)庫的基礎(chǔ) URL。可以包含$releasever 和$basearch 等變量。 mirrorlist 否 str 無 用于該存儲(chǔ)庫的鏡像列表 URL。 metalink 否 str 無 用于該存儲(chǔ)庫的 metalinkURL。 enabled 否 bool 無 是否啟用該存儲(chǔ)庫??梢允?/span> yes 或 no。 gpgcheck 否 bool 無 是否啟用 GPG 簽名檢查。可以是 yes 或 no。 gpgkey 否 str 無 GPG 簽名的 URL??梢园鄠€(gè) URL,用逗號(hào)分隔。 exclude 否 str 無 從該存儲(chǔ)庫中排除的軟件包??梢允且粋€(gè)列表或用逗號(hào)分隔的字符串。 includepkgs 否 str 無 從該存儲(chǔ)庫中包含的軟件包??梢允且粋€(gè)列表或用逗號(hào)分隔的字符串。 priority 否 int 無 存儲(chǔ)庫的優(yōu)先級(jí)。 enabled_metadata 否 bool 無 是否啟用存儲(chǔ)庫的元數(shù)據(jù)。可以是 yes 或 no。 cost 否 int 無 設(shè)置存儲(chǔ)庫的成本。 deltarpm_metadata_percentage 否 int 無 存儲(chǔ)庫的 deltarpm 元數(shù)據(jù)百分比。 skip_if_unavailable 否 bool 無 如果存儲(chǔ)庫不可用,是否跳過。可以是 yes 或 no。 sslverify 否 bool 無 是否驗(yàn)證 SSL 證書??梢允?/span> yes 或 no。 sslcacert 否 str 無 SSLCA 證書的路徑。 sslclientcert 否 str 無 SSL 客戶端證書的路徑。 sslclientkey 否 str 無 SSL 客戶端密鑰的路徑。 state 否 str present 存儲(chǔ)庫的狀態(tài)??梢允?/span> present(存在)或 absent(不存在)。 timeout 否 int 無 存儲(chǔ)庫的超時(shí)時(shí)間。 proxy 否 str 無 用于該存儲(chǔ)庫的代理 URL。 proxy_username 否 str 無 用于代理認(rèn)證的用戶名。 proxy_password 否 str 無 用于代理認(rèn)證的密碼。 username 否 str 無 用于存儲(chǔ)庫認(rèn)證的用戶名。 password 否 str 無 用于存儲(chǔ)庫認(rèn)證的密碼。
# 添加一個(gè)新的 Yum 存儲(chǔ)庫
- name: Add a new Yum repository
ansible.builtin.yum_repository:
name: myrepo
description: My custom repository
baseurl: http://myrepo.example.com/centos/$releasever/os/$basearch/
enabled: yes
gpgcheck: yes
gpgkey: http://myrepo.example.com/RPM-GPG-KEY-myrepo
# 刪除一個(gè)現(xiàn)有的 Yum 存儲(chǔ)庫
- name: Remove a Yum repository
ansible.builtin.yum_repository:
name: myrepo
state: absent
# 禁用一個(gè)Yum 存儲(chǔ)庫
- name: Disable a Yum repository
ansible.builtin.yum_repository:
name: myrepo
enabled: no
# 添加一個(gè)帶有鏡像列表的 Yum 存儲(chǔ)庫
- name: Add a Yum repository with a mirrorlist
ansible.builtin.yum_repository:
name: myrepo
description: My custom repository
mirrorlist: http://myrepo.example.com/centos/$releasever/os/$basearch/mirrorlist
enabled: yes
gpgcheck: yes
gpgkey: http://myrepo.example.com/RPM-GPG-KEY-myrepo
# 為存儲(chǔ)庫設(shè)置優(yōu)先級(jí)
- name: Add a Yum repository with priority
ansible.builtin.yum_repository:
name: myrepo
description: My custom repository
baseurl: http://myrepo.example.com/centos/$releasever/os/$basearch/
enabled: yes
gpgcheck: yes
gpgkey: http://myrepo.example.com/RPM-GPG-KEY-myrepo
priority: 10
# 從url導(dǎo)入gpgkey
- name: Import a key from a url
ansible.builtin.rpm_key:
state: present
key: http://apt.sw.be/RPM-GPG-KEY.dag.txt
# 從文件導(dǎo)入gpgkey
- name: Import a key from a file
ansible.builtin.rpm_key:
state: present
key: /path/to/key.gpg
# 刪除gpgkey
- name: Ensure a key is not present in the db
ansible.builtin.rpm_key:
state: absent
key: DEADB33F
# 導(dǎo)入前使用其指紋驗(yàn)證該gpgkey
- name: Verify the key, using a fingerprint, before import
ansible.builtin.rpm_key:
key: /path/to/RPM-GPG-KEY.dag.txt
fingerprint: EBC6 E12C 62B1 C734 026B 2122 A20E 5214 6B8D 79E6