SaltStack安装配置

一、环境准备:
操作系统CentOS Linux release 7.3.1611
master ip:192.168.1.180
minion ip:192.168.1.183
设置server(master)网络
[root@server ~]# cat /etc/sysconfig/network
server 192.168.1.180
[root@server ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.180 server
192.168.1.183 node1

设置minion(node1)网络
[root@node1 ~]# cat /etc/sysconfig/network
node1 192.168.1.183
[root@node1 ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.180 server
192.168.1.183 node1

二、安装SaltStack

安装saltack的yum源
yum -y install https://repo.saltstack.com/yum/redhat/salt-repo-latest-2.el7.noarch.rpm

安装master端:
yum install salt-master salt-minion
设置开机自启动:
systemctl enable salt-master.service
systemctl enable salt-minion.service
查看是否设置成功:
systemctl is-enabled salt-master.service
sed -i "s/#master: salt/master: 192.168.1.180/g" /etc/salt/minion
sed -i "s/#id:/id: server/g" /etc/salt/minion
启动服务:
[root@server ~]# systemctl start salt-master.service
[root@server ~]# systemctl start salt-minion.service

安装minion端:
yum install salt-minion
配置文件修改:
sed -i "s/#master: salt/master: 192.168.1.180/g" /etc/salt/minion
sed -i "s/#id:/id: node1/g" /etc/salt/minion
[root@node1 ~]# systemctl start salt-minion.service

设置秘钥验证:
salt master会启动两个端口:tcp 4505和tcp 4506
其中tcp4506是master的端口,在minion配置文件中能看到,允许minion访问后执行salt-key时会获取到
防火墙要允许minion连接的mastertcp4505 端口
master端执行:同意所有
salt-key -A

测试是否配置成功:
[root@server master]# salt '*' test.ping
node1:
    True
server:
    True

三、安装软件
安装软件(一)
修改master配置文件
vim /etc/salt/master去掉下面内容前面的"#"号
file_roots:
  base:
    - /srv/salt
重启服务:
systemctl restart salt-master.service
创建/srv/salt目录
mkdir -pv /srv/salt
创建apache.sls文件加入如下内容:
apache-install:
  pkg.installed:
    - names:
      - httpd
      - httpd-devel

apache-service:
  service.running:
    - name: httpd
    - enable: True
    - reload: True
执行命令:
salt '*' state.sls apache
即可安装完成,并且安装后就会启动httpd服务

安装软件(二)
创建top.sls文件加入如下内容:
base:
  '*':
    - apache
salt '*' state.highstate

posted @ 2017-09-07 16:06  fansik  阅读(258)  评论(0编辑  收藏  举报