saltstack配置安装和windowns应用

环境 centos 6.7
centos 6.7 10.1.110.230 master
centos 6.7 10.1.110.231 minion



安装:
首先,如果你的系统中EPEL当前不是enabled的话,你需要先通过如下的命令对其进行启动
warning: /var/tmp/rpm-tmp.ou3Y6v: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing...                ########################################### [100%]
   1:epel-release           ########################################### [100%]
master和minion两台都要执行

master安装saltstack
[ root@localhost ~]# yum install salt-master
minion安装saltstack
[ root@localhost ~]# yum install salt-minion

vi /etc/salt/master
master 修改配置文件
# public keys from the minions. Note that this is insecure.
#auto_accept: False
改成
# public keys from the minions. Note that this is insecure.
auto_accept: True

# The address of the interface to bind to:
#interface: 0.0.0.0
改成
# The address of the interface to bind to:
interface: 10.1.110.230


vi /etc/salt/minion
minion 修改配置文件
# clusters.
#id:
改成
# clusters.
id:minion-10-1-110-230

# resolved, then the minion will fail to start.
#master: salt
改成
# resolved, then the minion will fail to start.
master: 10.1.110.231

启动服务
master
service salt-master restart

minion
service salt-master restart


报错信息
minion服务器上面的报错
[root@localhost ~]# service salt-minion restart
Stopping salt-minion daemon:                               [  OK  ]
Starting salt-minion daemon: [ERROR   ] Error parsing configuration file: /etc/salt/minion - expected '<document start>', but found '<scalar>'
  in "<string>", line 79, column 1:
    id:minion-10-1-110-231

解决办法:
在修改minion的配置文件的时候 冒号后面都要加一个空格 就可以解决该问题

master       
salt-key -L 查看当前需要接受的keys(master和minions都需要把服务开启)
[ root@localhost ~]# salt-key -L
Accepted Keys:
minion-10-1-110-231
Denied Keys:
Unaccepted Keys:
Rejected Keys:
[ root@localhost ~]# 

查看salt软件信息
[ root@localhost ~]# salt '*' test.versions_report
minion-10-1-110-231:
               Salt: 2015.5.10
             Python: 2.6.6 (r266:84292, Jul 23 2015, 15:22:56)
             Jinja2: unknown
           M2Crypto: 0.20.2
     msgpack-python: 0.4.6
       msgpack-pure: Not Installed
           pycrypto: 2.0.1
            libnacl: Not Installed
             PyYAML: 3.10
              ioflo: Not Installed
              PyZMQ: 14.3.1
               RAET: Not Installed
                ZMQ: 3.2.5
               Mako: Not Installed
            Tornado: Not Installed
            timelib: Not Installed
           dateutil: Not Installed
[ root@localhost ~]# 

测试master和minion通讯是否下常
[ root@localhost ~]# salt '*' test.ping
minion-10-1-110-231:
    True
[ root@localhost ~]# 
True 代表正常    minion-10-1-110-231: 代表主机
也可以用正则方式来测试
以正为参考
salt 'shell正则' 命令
salt -E 'prel 正则'
salt -N $group 命令
salt -L 'server_id1,server_id2,server_id3' 命令




下面在加两台minion
一台centos 一台win2003
centos IP 10.1.110.232
按上面的步骤装好salt-minion服务
改/etc/salt/minion
master: 10.1.110.230
id: minion-10-1-110-232
重起服务
service salt-minion restart
检查是否启动成功
ps -ef |grep python

启动成功后。看master  接受的keys
salt-key -L
[ root@localhost ~]# salt-key -L
Accepted Keys:
minion-10-1-110-231
minion-10-1-110-232
Denied Keys:
Unaccepted Keys:
Rejected Keys:
[ root@localhost ~]# 

证明已经加入成功

下面win2003安装salt-minion
我下载最新的
安装的时候 直接下一步下一步就可以了。 
然后出现两行
上面一行是写salt-master的IP 或主机名(要指向HOST) 10.1.110.230
下面一行是写本机的ID名称  我写的是  minion-10-1-110-233
然后install 直接结束 就可以了。
下面我们测试一下master
[ root@localhost ~]# salt-key -L
Accepted Keys:
minion-10-1-110-231
minion-10-1-110-232
Denied Keys:
Unaccepted Keys:
Rejected Keys:
并没有发机WIN主机
我们回头看了一下WINDOWNS  salt-minion的服务发现并没有启动成功
看一下WINDOWN 日志

Failed to start service salt-minion.  Program c:\salt\bin\python.exe couldn't be launched. CreateProcess() failed: 由于应用程序配置不正确,应用程序未能启动。重新安装应用程序可能会纠正这个问题。

发现可能是未装python环境
因为saltstack是python开发的。
那么现在我们在安装python-2.7
默认安装 默认路径 就OK了
安装成功后在测试一下服务器。 这时已经启动成功
在测试一下master的keys
[ root@localhost ~]# salt-key -L
Accepted Keys:
minion-10-1-110-231
minion-10-1-110-232
minion-10-1-110-233
Denied Keys:
Unaccepted Keys:
Rejected Keys:
[ root@localhost ~]# 

现在已经OK了



接下来我们现在试图分组
因为生产环境有liunx windowns 所以分组管理是有必要的

分组标识符与解释
  1. G -- 针对 Grains 做单个匹配,例如:G@os:Ubuntu
  2. E -- 针对 minion 针对正则表达式做匹配,例如:E@web\d+.(dev|qa|prod).loc
  3. P -- 针对 Grains 做正则表达式匹配,例如:P@os:(RedHat|Fedora|CentOS)
  4. L -- 针对 minion 做列表匹配,例如:L@minion1.example.com,minion3.domain.com or bl*.domain.com
  5. I -- 针对 Pillar 做单个匹配,例如:I@pdata:foobar
  6. S -- 针对子网或是 IP 做匹配,例如:S@192.168.1.0/24 or S@192.168.1.100
  7. R -- 针对客户端范围做匹配,例如: R@%foo.bar


改master的配置文 件 
# as the main master config file).
#default_include: master.d/*.conf
改成
# as the main master config file).
default_include: master.d/*.conf
启动配置文件      这样做。可以让烦杂的业务组 主机组等一些 可以清楚的浏览
创建文件夹 mkdir master.d
vi /etc/salt/master.d/nodegroups.conf
nodegroups:
  liunxweb: ' L@minion-10-1-110-231,minion-10-1-110-232'
  winweb: ' L@minion-10-1-110-233'
              
前面的的 L@一定要写上。就是最上面提出的标识符

现在我们测试一下组
[ root@localhost ~]# salt -N liunxweb  test.ping
minion-10-1-110-231:
    True
minion-10-1-110-232:
    True
[ root@localhost ~]# salt -N winweb  test.ping
minion-10-1-110-233:
    True

[root@localhost ~]# salt -N liunx  test.ping
No minions matched the target. No command was sent, no jid was assigned.
ERROR: No return received
No minions matched the target. No command was sent, no jid was assigned.
ERROR: No return received
出现这个 表示没有获取到任何的信息

我们现在把WIN 233 主机重起测试一下PING  出现下面的。   安装成功后最好检查一下服务是否开机启动
[ root@localhost ~]# salt -N winweb  test.ping
minion-10-1-110-233:
     Minion did not return. [Not connected]
  Minion did not return. [Not connected]  表示不通


我在WIN2008安装是这样安装的 用CMD

Salt-Minion-2016.3.1-AMD64-Setup.exe /S /master=主机名称或IP /minion-name=%COMPUTERNAME%(这个是主机的主机名)
在WIN2008上面安装的时候 。安装成功服务启动不起来。这时参考网上一个文章
我因些下载了一个组件

Visual C++ 2008 Redistributable Package (x64)


安装好启动服务OK。
这样最基本的安装测试就到此为止
下篇讲一下如何使用

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值