运维自动化--salt
[root@ceshi ~]#rpm -ivh http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm
[root@ceshi ~]# yum install salt-master
[root@ceshi ~]# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=zhusalt
[root@zhusalt ~]# vi /etc/hosts
127.0.0.1 zhusalt
::1 zhusalt
[root@zhusalt ~]# vi /etc/salt/master
interface: 192.168.172.162 服务器IP
[root@zhusalt salt]# service salt-master restart
Stopping salt-master daemon: [失败]
Starting salt-master daemon: [确定]
[root@zhusalt salt]# netstat -an |grep 450
tcp 0 0 192.168.170.162:4505 0.0.0.0:* LISTEN
tcp 0 0 192.168.170.162:4506 0.0.0.0:* LISTEN
unix 3 [ ] STREAM CONNECTED 13450
[root@ceshi ~]# rpm -ivh http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm
[root@ceshi ~]# yum install salt-minion
[root@congsalt ~]# grep -Ev "^$|^#" /etc/salt/minion
master: zhusalt
id: congsalt
[root@congsalt init.d]# service salt-minion restart
Stopping salt-minion daemon: [确定]
Starting salt-minion daemon: [确定]
[root@congsalt init.d]# WARNING: Master hostname: zhusalt not found. Retrying in 30 seconds
[root@congsalt init.d]# vi /etc/hosts
127.0.0.1 congsalt
::1 congsalt
192.168.170.162 zhusalt
[root@zhusalt minions]# salt-key
Accepted Keys:
Unaccepted Keys:
congsalt
Rejected Keys:
[root@zhusalt minions]# salt-key -a congsalt
The following keys are going to be accepted:
Unaccepted Keys:
congsalt
Proceed? [n/Y] y
Key for minion congsalt accepted.
[root@zhusalt minions]# salt 'congsalt' cmd.run 'df -h'
congsalt:
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 19G 3.1G 15G 18% /
tmpfs 250M 0 250M 0% /dev/shm
[root@zhusalt ~]# vi /etc/salt/master
file_roots:
base:
- /srv/salt/
dev:
- /srv/salt/dev/services
- /srv/salt/dev/states
prod:
- /srv/salt/prod/services
- /srv/salt/prod/states
[root@zhusalt srv]# pwd
/srv
[root@zhusalt srv]# tree
.
└── salt
├── dev
│?? ├── services
│?? └── states
└── prod
├── services
└── states
[root@zhusalt salt]# pwd
/srv/salt
[root@zhusalt salt]# more telnet.sls top.sls
::::::::::::::
telnet.sls
::::::::::::::
telnet:
pkg:
- installed
::::::::::::::
top.sls
::::::::::::::
base:
'*':
- telnet
[root@zhusalt salt]# salt '*' state.highstate
145congsalt:
----------
State: - pkg
Name: telnet
Function: installed
Result: True
Comment: The following packages were installed/updated: telnet.
Changes: telnet: { new : 0.17-47.el6_3.1
old :
}
congsalt:
----------
State: - pkg
Name: telnet
Function: installed
Result: True
Comment: The following packages were installed/updated: telnet.
Changes: telnet: { new : 0.17-47.el6_3.1
old :
}

浙公网安备 33010602011771号