Saltstack use Tutorial (iv): service Management

Source: Internet
Author: User
Tags saltstack

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.