Saltstack Introduction
Salt is a basic platform management tool. The saltstack uses the C/s mode, and the server side is the master,client end of the salt, which communicates between Minion,minion and master through ZEROMQ Message Queuing. Master listens on 4505 and 4506 ports, 4505 is the master and Minion authenticated communication ports, and 4506 performs return information for commands that Master uses to send commands or to receive Minion.
?
- Saltstack Common Modules
- Saltstack provides a number of functional modules to facilitate operation of the operating system's underlying functions and common tools.
1:PKG module: Is package management, including additions and deletions updates.
2:file module: Manages file operations, including synchronizing files, setting file permissions and owning user groups, deleting files, and more.
3:cmd module: A command or script is executed on the minion.
4:user module: Manage system account operations.
5:service module: Managing system service operations
6:cron module: Managing Cron Service operations
?
Deployment environment
role |
Host name |
IP |
Master |
Master.saltstack.com |
192.168.200.128 |
Minion |
Web01.saltstack.com |
192.168.200.129 |
Minion |
Web02.saltstack.com |
192.168.200.130 |
?
Operation Steps
Saltstack Installation
1: Modify host Name
# vim /etc/hostname三台主机分别为:master.saltstack.com //(管理)web01.saltstack.com //(被管理)web02.saltstack.com //(被管理)
2: Modify three Hosts files
# vim /etc/hosts192.168.200.128 master.saltstack.com192.168.200.129 web01.saltstack.com192.168.200.130 web02.saltstack.com
3: Installation
# systemctl stop firewalld # setenforce 0 //关闭防火墙# yum install -y epel-release# yum install -y salt-master //管理端安装# yum install -y epel-release# yum install -y salt-minion //被管理端安装
4: Management-side configuration
# vim /etc/salt/masterinterface: 192.168.200.128 //15行 监听地址改为本地IP............auto_accept: True //215 证书认证............file_roots: //416行 站点目录开启 base: - /srv/salt............nodegroups: //710行 组分类 group1: ‘web01.saltstack.com‘ group2: ‘web02.saltstack.com‘............pillar_opts: True //552行 pillar开启pillar_roots: //529行 base: - /srv/pillar# cat /etc/salt/master | grep -v ^$ | grep -v ^# //查看修改好的配置项
?
?
?
7: Test on the management side. ' * ' refers to all hosts
# salt ‘*‘ test.ping //查看通信状态# salt ‘*‘ cmd.run ‘df -h‘ //查看所有被管理端的挂载情况# salt ‘web01.saltstack.com‘ cmd.run ‘df -h‘ //查看指定主机的挂载情况# salt ‘*‘ grains.items //查看grains值# salt ‘*‘ pillar.items //查看pillar(动态信息)# salt-key //查看已经被接受过的客户端
?
?
Saltstack Configuration Management installation Apache
注意:‘*‘ 表示所有客户端执行apache模块# vim /srv/salt/top.slsbase: ‘*‘: - apache
# vim /srv/salt/apache.sls //注意apache-service 是自定义的id名apache-service: pkg.installed: - names: - httpd - httpd-devel service.running: - name: httpd - enable: True
Restart Service
To perform a flush state configuration command on the management side
# salt ‘*‘ state.highstate
?
?
- Go to Minion verify that the httpd installation was successful
Deploy Saltstack and bulk install httpd services