ansible之block实践--自动根据centos版本安装zabbix-agent

各位看官有谁知道附件怎么上传啊,我想把完整的playbook都上传上来

block主体部分:

---
-block:
-name:"复制zabbix_agent到主机"
copy:
src=zabbix-agent-3.0.5-1.el6.x86_64.rpm
dest=/usr/local/src/
-name:"安装zabbix_agent"
yum:
name:/usr/local/src/zabbix-agent-3.0.5-1.el6.x86_64.rpm
state:present
-name:"复制zabbix_agent配置文件"
template:
src=zabbix_agentd_centos6.conf.j2
dest=/etc/zabbix/zabbix_agentd.conf
-name:"启动zabbix,设置开机启动"
service:
name=zabbix-agent
state=started
enabled=yes
when:(ansible_distribution=="CentOS"oransible_distribution=="RedHat")andansible_distribution_major_version=="6"
-block:
-name:"复制zabbix_agent到主机"
copy:
src=zabbix-agent-3.0.5-1.el7.x86_64.rpm
dest=/usr/local/src/
-name:"安装zabbix_agent"
yum:
name:/usr/local/src/zabbix-agent-3.0.5-1.el7.x86_64.rpm
state:present
-name:"复制zabbix_agent配置文件"
template:
src=zabbix_agentd_centos7.conf.j2
dest=/etc/zabbix/zabbix_agentd.conf
-name:"启动zabbix,设置开机启动"
service:
name=zabbix-agent
state=started
enabled=yes
when:ansible_distribution=="CentOS"andansible_distribution_major_version=="7"

相关文章

有时候CentOS工作在无互联网的环境下,需要在离线环境下安装一些组件,这次实现的是模拟在离线环境下安...
首先参照https://www.cnblogs.com/wdw984/p/13330074.html,来进行如何安装Centos和离线下载rpm包。 离...
有两个.NET CORE3.1网站部署在CentOS7上(内网IP是192.168.2.32),现在想实现访问http://192.168.2.32...
1、yum -y install vsftpd 安装vsftpd 2、配置vsftpd的配置文件(/etc/vsftpd/vsftpd.conf)主要修改以...
首先去mysql官网下载mysql的离线rpm安装包(https://downloads.mysql.com/archives/community/) Mysql...
第一步下载erlang环境并安装: wget https://packages.erlang-solutions.com/erlang/rpm/centos/7/x86_...