saltstack
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了saltstack相关的知识,希望对你有一定的参考价值。
saltstack时一种基于C/S架构的服务模式,可以简单地理解为如果我们想要使用saltstack就需要在现有的环境下引入维护一套C/S架构。在saltstack架构中服务器端叫做master,客户端叫做minion。
首先来安装saltstack:
在安装之前需要在两台服务器上安装epel源:yum install -y epel-release 在master: yum install -y salt-master salt-minion 在slace: yum install -y salt-minion
因为我们在master上安装了客户端程序,因此master本身也是一个minion。
修改minion端的配置文件
/etc/salt/minion 把#master: salt 把前面的注释去掉,然后把salt改为master端的ip地址。 master: 192.168.1.120 //master端ip
启动saltsatck:
在对用的服务器上分别采用如下语句启用saltstack:
service salt-master start 或者/etc/init.d/salt-master start service salt-minion start 或者/etc/init.d/salt-minion start
认证:
saltstck使用ssl签证的方式进行安全认证:
[[email protected] ~]# salt-key //显示当前key的状态 Accepted Keys: Denied Keys: Unaccepted Keys: //未接受的key有两个 master slave Rejected Keys: [[email protected] ~]# salt-key -L //可以使用-L来显示 Accepted Keys: Denied Keys: Unaccepted Keys: master slave Rejected Keys: 同意签证未接受的key [[email protected] ~]# salt-key -a slave //用-a选项指定接受某个key,用A则是同意签证所有未接收的key The following keys are going to be accepted: Unaccepted Keys: slave Proceed? [n/Y] y //敲字母y Key for minion slave accepted. [[email protected] ~]# salt-key -L Accepted Keys: slave //已经签证。 Denied Keys: Unaccepted Keys: master Rejected Keys: [[email protected] ~]# salt-key -A -y //签证另一个key,, The following keys are going to be accepted: Unaccepted Keys: master Key for minion master accepted. [[email protected] ~]# salt-key -L Accepted Keys: //两个key已经签证。 master slave Denied Keys: Unaccepted Keys: Rejected Keys:
接受成功后我们运行一条指令,如下:
[[email protected]r ~]# salt ‘*‘ test.ping //*表示所有的minion。 slave: True master: True
可以查看一下master,minion端安装了那些文件:
[[email protected] ~]# rpm -ql salt-master /etc/rc.d/init.d/salt-master /etc/salt/master /usr/bin/salt /usr/bin/salt-cp /usr/bin/salt-key /usr/bin/salt-master /usr/bin/salt-run /usr/bin/salt-unity [[email protected] minion.d]# rpm -ql salt-minion /etc/rc.d/init.d/salt-minion /etc/salt/minion /usr/bin/salt-call /usr/bin/salt-minion
salt命令的几种匹配方式:
正则匹配:
[[email protected] ~]# salt -E ‘^s‘ test.ping slave: True
列表匹配:
[[email protected] ~]# salt -L master,slave test.ping //中间用逗号分割 master: True slave: True [[email protected] ~]#
组匹配:
需要在minion配置文件中做如下修改:
nodegroups: groups: ‘[email protected],slave‘ //把注释去掉,然后添加minion。
[[email protected] ~]# salt -N groups test.ping master: True slave: True
本文出自 “自定义” 博客,谢绝转载!
以上是关于saltstack的主要内容,如果未能解决你的问题,请参考以下文章
首发分析 | SaltStack远程执行代码多个高危漏洞透析(CVE-2021-25281/25282/25283)
漏洞告警SaltStack多个高危漏洞(CVE-2021-25281/25282/25283)