saltstack+zabbix

环境:

server1172.25.60.1salt-master + salt-minion + zabbix-server
server2172.25.60.2salt-minion + zabbix-agent

1.软件包安装过程存在许多依赖性,配置好yum源

[root@server2 zabbix]# cat /etc/yum.repos.d/rhel7.3.repo 
[rhel7.3]
name=rhel7.3
baseurl=http://172.25.60.250/rhel-7.3
gpgcheck=0

[salt]
name=saltname
baseurl=http://172.25.60.250/saltstack
gpgcheck=0

[zabbix]
name=zabbix
baseurl=http://172.25.60.250/zabbix
gpgcheck=0

2.server1上首先安装配置mariadb-server

yum install mariadb-server
systemctl start mariadb
systemctl enable mariadb
mysql_secure_installation 	//安全初始化,设置密码westos
mysql -pwestos				//设置数据库
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by 'westos';
cd /usr/share/doc/zabbix-server-mysql-4.0.5/
zcat  create.sql.gz | mysql -p zabbix //输入数据库密码

在这里插入图片描述

3.master端编写文件

整体结果如下:
在这里插入图片描述
(1)vim apache/install

install-apache:
  pkg.installed:
    - pkgs:
      - httpd

  service.running:
    - name: httpd 

(2)vim pkgs/install.sls

zabbix:
  pkg.installed:
    - pkgs:
      - gcc
      - zlib-devel
      - pcre-devel

(3)vim zabbix-agent/install.sls

include:
  - pkgs.install

install-zabbix-agent:
  file.managed:
    - name: /mnt/zabbix-agent-4.0.5-1.el7.x86_64.rpm
    - source: salt://zabbix-agent/files/zabbix-agent-4.0.5-1.el7.x86_64.rpm

  cmd.run:
    - name: cd /mnt && yum rinstall -y zabbix-agent-4.0.5-1.el7.x86_64.rpm

/etc/httpd/conf.d/zabbix_agentd.conf:
  file.managed:
    - source: salt://zabbix-agent/files/zabbix_agentd.conf

service-zabbix-agent:
  file.managed:
    - name: /usr/lib/systemd/system/zabbix-agent
    - source: salt://zabbix-server/files/zabbix-agent.service

  service.running:
    - name: zabbix-agent
    - reload: True
    - watch:
      - file: /etc/zabbix/zabbix_server.conf

(4)vim zabbix-server/install.sls

include:
  - pkgs.install

install-zabbix-server:
  file.managed:
    - name: /mnt/zabbix-server-mysql-4.0.5-1.el7.x86_64.rpm
    - source: salt://zabbix-server/files/zabbix-server-mysql-4.0.5-1.el7.x86_64.rpm

install-zabbix-web:
  file.managed:
    - name: /mnt/zabbix-web-4.0.5-1.el7.noarch.rpm
    - source: salt://zabbix-server/files/zabbix-web-4.0.5-1.el7.noarch.rpm

install-zabbix-mysql:
  file.managed:
    - name: /mnt/zabbix-web-mysql-4.0.5-1.el7.noarch.rpm
    - source: salt://zabbix-server/files/zabbix-web-mysql-4.0.5-1.el7.noarch.rpm

  cmd.run:
    - name: cd /mnt && yum reinstall -y zabbix-server-mysql-4.0.5-1.el7.x86_64.rpm zabbix-web-4.0.5-1.el7.noarch.rpm zabbix-web-mysql-4.0.5-1.el7.noarch.rpm

(5)vim zabbix-server/service.sls

include:
  - zabbix-server.install

/etc/zabbix/zabbix_server.conf:
  file.managed:
    - source: salt://zabbix-server/files/zabbix_server.conf

/etc/httpd/conf.d/zabbix.conf:
  file.managed:
    - source: salt://zabbix-server/files/zabbix.conf

service-zabbix-server:
  file.managed:
    - name: /usr/lib/systemd/system/zabbix-server
    - source: salt://zabbix-server/files/zabbix-server.service

  service.running:
    - name: zabbix-server
    - reload: True
    - watch:
      - file: /etc/zabbix/zabbix_server.conf

(6)vim top.sls

base:
  'server1':
    - apache.install
    - zabbix-server.service
  'server2':
    - zabbix-agent.install

4.运行

salt '*' state.highstate

在这里插入图片描述
在这里插入图片描述

5.浏览器访问:
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值