yum_repository 模块
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
[root@m01 ~]# ansible-doc yum_repository EXAMPLES: yum_repository: name: epel description: EPEL YUM repo baseurl: https://download.fedoraproject.org/pub/epel/$releasever/$basearch/ file: external_repos gpgcheck: no mirrorlist: http://mirrorlist.repoforge.org/el7/mirrors-rpmforge enabled: no state: absent [nginx-stable] name=nginx stable repo baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=1 enabled=1 gpgkey=https://nginx.org/keys/nginx_signing.key module_hotfixes=true #创建nginx官方源 [root@m01 ~]# ansible 'web_group' -m yum_repository -a 'name="nginx-stable" description="nginx stable repo" baseurl=http://nginx.org/packages/centos/7/$basearch/ gpgcheck=no enabled=yes file=nginx' #添加源:不修改 file,只要name不相同就是添加源 [root@m01 ~]# ansible 'web_group' -m yum_repository -a 'name="nginx-mainline" description="nginx mainline repo" baseurl=http://nginx.org/packages/mainline/centos/7/$basearch/ gpgcheck=no enabled=yes file=nginx' #修改源:不修改 file 和 name,改其他的内容都会修改源 [root@m01 ~]# ansible 'web_group' -m yum_repository -a 'name="nginx-mainline" description="nginx mainline repo" baseurl=http://nginx.org/packages/mainline/centos/7/$basearch/ gpgcheck=no enabled=yes file=nginx' name: #yum源 []里面的内容 description: #yum源 name的值 baseurl: #yum源 中的仓库地址 file: #yum源的名字 gpgcheck: #yum源是否检查 mirrorlist: #源的列表 enabled: no #源是否启动 state: absent #删除 present #添加 |
yum模块
1)语法帮助
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
[root@m01 ~]# ansible-doc yum EXAMPLES: - name: install the latest version of Apache yum: name: httpd state: latest name: httpd #服务的名字 http:// #软件包网上的地址 /usr/local/src/nginx-release-centos-6-0.el6.ngx.noarch.rpm #本地的rpm包 state: latest #安装最新的版本 present #安装 absent #卸载 |
2)yum实例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
#名字安装httpd [root@m01 ~]# ansible 'web_group' -m yum -a 'name=httpd state=present' #类似于在远程机器上执行 yum install -y httpd #使用网上软件包安装 1.找到网上的包 https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-agent-4.0.1-1.el7.x86_64.rpm 2.安装 [root@m01 ~]# ansible 'web_group' -m yum -a 'name=https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-agent-4.0.1-1.el7.x86_64.rpm state=present' #类似于在远程机器上执行 yum install -y https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-agent-4.0.1-1.el7.x86_64.rpm #使用本地包安装 1.上传包(上传到web端) 2.安装 [root@m01 ~]# ansible 'web_group' -m yum -a 'name=/tmp/nginx-1.16.1-1.el7.ngx.x86_64.rpm state=present' #类似于在远程机器上执行 yum localinstall -y /tmp/nginx-1.16.1-1.el7.ngx.x86_64.rpm |