1.服务端安装
# rpm -ivh http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm
# yum install -y salt-master
# vi /etc/salt/master
interface: 127.0.0.1
# /etc/init.d/salt-master start
# chkconfig salt-master on
2.客户端安装
# rpm -ivh http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm
# yum install -y salt-minion
# vi /etc/salt/minion
master: x.x.x.x(服务端IP)
# /etc/init.d/salt-minion start
# chkconfig salt-minion on
3.添加并测试
salt-key -a 'wnode'(客户端id)
salt-key -L
Accepted Keys:
SolrCloud-node2
wnode
Unaccepted Keys:
Rejected Keys:
salt 'wnode' test.ping
wnode:
    True
4.测试安装apache
# mkdir -p /srv/salt
# cd /srv/salt/
# vi top.sls
base:
  'SolrCloud-node2':
    - fc7.sc
    - fc7.pack
    - fc7.fc7
# mkdir fc7
# cd fc7/
# vi pack.sls
apache:
  pkg:
    - name: httpd
    - installed
  service:
    - name: httpd
    - running
    - reload: True
    - watch:
      - file: /etc/httpd/conf/httpd.conf
/etc/httpd/conf/httpd.conf:
  file.managed:
    - source: salt://fc7/httpd.conf
    - user: root
    - group: root
    - mode: 644
    - backup: minion
# yum install -y httpd
# cp /etc/httpd/conf/httpd.conf .
# ls
httpd.conf  pack.sls
# salt 'SolrCloud-node2' state.highstate
SolrCloud-node2:
----------
    State: - pkg
    Name:      httpd
    Function:  installed
        Result:    True
        Comment:   Package httpd is already installed
        Changes: 
----------
    State: - file
    Name:      /etc/httpd/conf/httpd.conf
    Function:  managed
        Result:    True
        Comment:   File /etc/httpd/conf/httpd.conf updated
        Changes:   diff: ---
+++
@@ -133,7 +133,7 @@
# prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
#
#Listen 12.34.56.78:80
-Listen 80
+Listen 88
#
# Dynamic Shared Object (DSO) Support
                      
----------
    State: - service
    Name:      httpd
    Function:  running
        Result:    True
        Comment:   Service reloaded
        Changes:   httpd: True
                      
Summary
------------
Succeeded: 3
Failed:    0
------------
Total:     3
# salt 'SolrCloud-node2' cmd.run 'ps -ef |grep httpd'
SolrCloud-node2:
    root      4224     1  0 Oct12 ?        00:01:27 /usr/sbin/httpd
    apache    5020  4224  0 00:26 ?        00:00:00 /usr/sbin/httpd
    apache    5021  4224  0 00:26 ?        00:00:00 /usr/sbin/httpd
    apache    5022  4224  0 00:26 ?        00:00:00 /usr/sbin/httpd
    apache    5023  4224  0 00:26 ?        00:00:00 /usr/sbin/httpd
    apache    5024  4224  0 00:26 ?        00:00:00 /usr/sbin/httpd
    apache    5025  4224  0 00:26 ?        00:00:00 /usr/sbin/httpd
    apache    5026  4224  0 00:26 ?        00:00:00 /usr/sbin/httpd
    apache    5027  4224  0 00:26 ?        00:00:00 /usr/sbin/httpd
    root      5031  5030  1 00:28 ?        00:00:00 /bin/bash -c ps -ef |grep httpd
    root      5033  5031  0 00:28 ?        00:00:00 grep httpd
# salt 'SolrCloud-node2' cmd.run 'netstat -ltunp |grep 88'
SolrCloud-node2:
    tcp        0      0 :::3888                     :::*                        LISTEN      28539/java        
    tcp        0      0 :::88                       :::*                        LISTEN      4224/httpd