First, the directory tree
zabbix_client/
├──conf.sls
├──files
│├──zabbix-2.4.7.tar.gz
│├──zabbix_agentd
│└──zabbix_agentd.conf
├──init.sls
└──install.sls
1 directory, 6 files
Second, the document detailed
(1) Vim Init.sls (linked file with Top.sls)
Include
-Zabbix_client.install
-Zabbix_client.conf
(2) Vim Install.sls
#安装文件
Zabbix_client_source:
File.managed:
-Name:/tmp/zabbix-2.4.7.tar.gz
-Unless:test-e/tmp/zabbix-2.4.7.tar.gz
-User:root
-Group:root
-Makedirs:true
-Source:salt://zabbix_client/files/zabbix-2.4.7.tar.gz
Zabbix_client_extract:
Cmd.run:
-CWD:/tmp
-Names:
-TAR-ZXVF zabbix-2.4.7.tar.gz
-Unless:test-d/tmp/zabbix-2.4.7
-Require:
-File:zabbix_client_source
Zabbix_user:
User.present:
-Name:zabbix
-Createhome:false
-Gid_from_name:false
-Shell:/sbin/nologin
Pkgs_install:
Pkg.installed:
-pkgs:
-GCC
Zabbix_client_compile:
Cmd.run:
-CWD:/tmp/zabbix-2.4.7
-Names:
-./configure--prefix=/zabbix_client--enable-agent
-Require:
-Cmd:zabbix_client_extract
-Pkg:pkgs_install
Zabbix_client_make:
Cmd.run:
-CWD:/tmp/zabbix-2.4.7
-Names:
-Make
-Make Install
-Reqiure:
-Cmd:zabbix_client_compile
(3) Vim Conf.sls
Include
-Zabbix_client.install
Zabbix_client_conf:
File.managed:
-Name:/zabbix_client/etc/zabbix_agentd.conf
-Source:salt://zabbix_client/files/zabbix_agentd.conf
-Template:jinja
-Defaults:
Zabbix_client_service:
File.managed:
-Name:/etc/init.d/zabbix_agentd
-User:root
-mode:755
-Source:salt://zabbix_client/files/zabbix_agentd
Cmd.run:
-Names:
-/bin/chmod +x/etc/init.d/zabbix_agentd
-/sbin/chkconfig--add Zabbix_agentd
-/sbin/chkconfig Zabbix_agentd on
-Unless:/sbin/chkconfig--list zabbix_agentd
Service.running:
-Name:zabbix_agentd
-Enable:true
-Restart:true
-Watch:
-File:/zabbix_client/etc/zabbix_agentd.conf
It is worth mentioning that: in zabbix_agent.conf hostname={{grains[' ip_interfaces ' [' eth0 '][0]}}
Everything in the FILESL is available for download. During the execution of this process. Problems encountered:
(1) in execution: Salt ' minion ' state.highstate test=true
Appears: ID service.running in SLS are not a dictionary
This error means that there is a bug in the file running service.running. Intolerable, even the first compilation of his mother can not get through. So you don't think it's a. sls file anymore. Maybe it's grammar. Format. Horizontal slots. Mine is service.running that paragraph of the whole is not indented.
(2) One more mistake is:
[Salt.master] [ERROR] [2374] Received minion error from [Minion]: The Minion function caused an exception
There will be a bunch of Python code errors you don't understand. A look is given by minion. Guess is minion error, the client's thing, or the problem of the system. Don't be blind to it. It's your problem with the. sls file. I was in the writing-require, unexpectedly silly with the top-names under the alignment. Require should have said it. Lao Tzu is with-names level you let me align with your subordinates. Grandpa's. Looking for a housekeeper. So Python came out. A scolding.
(3) in the process of execution, encountered because my system is to minimize the installation. In the compilation process, the error is missing GCC, to install him. It saves a lot of things. So there's more pkgs_install: Wait.
Because of the use of salt in the previous installment Nginx I feel very detailed. This is the process of recording the zabbix_agent.
This article is from the "Dark Before dawn" blog, please be sure to keep this source http://9907516.blog.51cto.com/9897516/1740765
Salt Installation Zabbix Agent