saltstack安装配置
Posted fansik
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了saltstack安装配置相关的知识,希望对你有一定的参考价值。
一、环境准备:
操作系统CentOS Linux release 7.3.1611
master ip:192.168.1.180
minion ip:192.168.1.183
设置server(master)网络
[[email protected] ~]# cat /etc/sysconfig/network
server 192.168.1.180
[[email protected] ~]# 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)网络
[[email protected] ~]# cat /etc/sysconfig/network
node1 192.168.1.183
[[email protected] ~]# 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
二、安装saltack
安装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
启动服务:
[[email protected] ~]# systemctl start salt-master.service
[[email protected] ~]# 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
[[email protected] ~]# systemctl start salt-minion.service
设置秘钥验证:
salt master会启动两个端口:tcp 4505和tcp 4506
其中tcp4506是master的端口,在minion配置文件中能看到,允许minion访问后执行salt-key时会获取到
防火墙要允许minion连接的mastertcp4505 端口
master端执行:同意所有
salt-key -A
测试是否配置成功:
[[email protected] 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
以上是关于saltstack安装配置的主要内容,如果未能解决你的问题,请参考以下文章