1、创建sls文件 install-rpms: cmd.run: - name: yum install -y autoconf automake imake libxml2-devel expat-devel cmake gcc gcc-c++ libaio libaio-devel bzr bison libtool ncurses5-devel net-snmp\* java-1.7.0-openjdk.x86_64 java-1.7.0-openjdk-devel.x86_64 libxml2 libxml2-devel bzip2 libpng-devel freetype-devel bzip2-devel curl* curl-devel libjpeg\* openjpeg\* install-zabbix_agent: file.managed: - name: /tmp/zabbix-3.0.3.tar.gz - source: salt://init/files/zabbix-3.0.3.tar.gz cmd.run: - name: (id zabbix || useradd -u 600 zabbix) && cd /tmp && tar zxf zabbix-3.0.3.tar.gz && cd zabbix-3.0.3 && ./configure --prefix=/usr/local/zabbix --enable-agent --enable-java && make && make install && mkdir /usr/local/zabbix/log && chown zabbix:zabbix /usr/local/zabbix/log - unless: test -d /usr/local/zabbix config-zabbix_agent: file.managed: - name: /usr/local/zabbix/etc/zabbix_agentd.conf - source: salt://init/files/zabbix_agentd.conf cmd.run: - name: (grep zabbix_agentd /etc/rc.local || echo "/usr/local/zabbix/sbin/zabbix_agentd">>/etc/rc.local) && /usr/local/zabbix/sbin/zabbix_agentd - require: - file: install-zabbix_agent 2、安装zabbix agent:salt-ssh ‘*‘ state.sls init.zabbix_agent
时间: 2024-12-19 10:08:38