Introduced
CentOSonSaltManagement services are throughServicemanaged, so your service must have been inServiceregister cut inSaltcalled when the name andRCorInitthe script below is consistent, otherwise it cannot be managed.
Command-line Operations
Salt ' * ' service.reload <service name>
Salt ' * ' service.< reload | Restart | Start | Stop | Status | Enabled ><service name>
< Smooth Restart | Restart | Start | stop | state | boot up >
Service Status Management
Here is the file directory structure
[Email protected]apache]# Tree
.
├── Files
│ └── httpd.conf
└── Install-rpm.sls
1 directory, 2 files
The following are the service state management SLS notation
[[email protected] apache]# cat install-rpm.slshttpd: #状态ID service.running: #服务状态运行 - enable: true #允许开机启动 - reload: true #允许reload服务, default restart - require: #服务运行依赖于下面红色区域httpd是否安装 - pkg: httpd - watch:: # Each time you find the following file changes reloadnginx - file: /etc/httpd/conf/httpd.conf pkg.installed: #salt的yum安装包 - name: httpd #安装包名 file.managed: - name: /etc/httpd/conf/httpd.conf - source: salt://apache/files/httpd.conf
" State.sls "module can specify" SLS "File execution," env= "You can specify that your execution environment is base by default.
[[email protected] base]# salt ' Salt-minion1 ' state.sls Apache.install-rpmsalt-minion1:---------- ID: Httpd function: pkg.installed result: true Comment: Package httpd is already installed. started: 10:31:08.031272 duration: 684.705 ms Changes: ---------- ID: httpd Function: file.managed name: /etc/httpd/conf/httpd.conf result: true Comment: File /etc/httpd/conf/httpd.conf updated started: 10:31:08.718996 duration: 14.606 ms changes: ---------- diff: --- +++ @@ -1007,3 +1007,4 @@ # errorlog logs/dummy-host.example.com-error_log # customlog logs/dummy-host.example.com-access_log common #</VirtualHost> +---------- ID: httpd Function: Service.running result: true comment: Service reloaded Started: 10:31:08.770629 duration: 89.05 ms changes: ---------- httpd: &nBsp True summary------------succeeded: 3 (changed=2) failed: 0------------ Total states run: 3
This article is from the "Nginxs Small white" blog, please be sure to keep this source http://nginxs.blog.51cto.com/4676810/1699731
Saltstack use Tutorial (iv): service Management