apt_repository
ubuntu 下:
repo 指定库地址,例如 nginx 地址 ppa:nginx/stable
state 值为 absent 时为删除
ansible localhost -m apt_repository -a "repo=ppa:nginx/stable" -b --ask-become-pass
localhost | CHANGED => {
"changed": true,
"repo": "ppa:nginx/stable",
"state": "present"
}
#( 04/24/20@ 3:10PM )( zyh@zyh ):~
cat /etc/apt/sources.list.d/ppa_nginx_stable_bionic.list
deb http://ppa.launchpad.net/nginx/stable/ubuntu bionic main
apt
常用参数:
name 包名
state 包状态 (absent-删除,latest-最新包, present-默认安装) latest 相当于升级包
upgrade 升级 (yes,dist,full,no-默认)
https://docs.ansible.com/ansible/latest/modules/apt_module.html#apt-module
ansible localhost -m apt -a "name=nginx state=present" -b --ask-become-pass
localhost | CHANGED => {
"cache_update_time": 1587713114,
"cache_updated": false,
"changed": true,
"stderr": "",
"stderr_lines": [],
"stdout": "Reading package lists...\nBuilding dependency tree.......
yum_repository
name 仓库名
baseurl 仓库地址
enabled (yes-默认,no)
gpgcheck (yes, no)
gpgcakey 指定 gpg ca 公钥
state (present-默认,absent-删除)
ansible localhost -m yum_repository -a "name=epel baseurl=https://download.fedoraproject.org/pub/epel/$releasever/$basearch/"
yum
name 包名
state (absent-删除,present-安装-默认值,latest-更新)
disable_gpg_check 关闭gpg检查(用于源gpg检查没有的情况)
enablerepo 安装包的时候,先临时启用某个源
disablerepo 安装包的时候,先临时禁用某个源