Detailed explanation of puppet (5) - detailed explanation of service resources

Today, I will continue to introduce the relevant knowledge of Linux operation and maintenance. The main content of this article is the detailed explanation of service resources in puppet.

1. Common parameters of service resources

In puppet, service resources are mainly used to start, shut down or restart client services or processes, and can set services to start automatically.
The parameters supported by the service resource are as follows:
enable: Specifies whether the service is started at boot time. It can be set to true or false.
ensure: Specifies whether to run the service. If it is set to running, it means to run the service. If it is set to stopped, it means to stop the service.
name: Specifies the name of the client service.
path: Specifies the search path for startup scripts.
provider: The default is init.
hasrestart: Whether the management script supports the restart parameter, if not, use stop and start to achieve the restart effect.
hasstatus: Whether the management script supports the status parameter. Puppet uses the status parameter to determine whether the specified service is running. If the status parameter is not supported, puppet will check whether there is a service name in the running process list to determine whether the service is running.

Second, the actual combat of service resources

Next, we will carry out the actual combat of puppet's service resources.
On the puppet server, modify the site.pp file in the /etc/puppet/manifests/ directory to make the content as follows:

node default {
    
    
        service{
    
    
                "httpd":
                ensure=>running;
        }
}

In the above configuration, we try to control the puppet client device to start the Apache service.

3. Effect test

Finally, let's examine the results of the configuration we just made.
Execute the command on the puppet client:

puppet agent --server puppet-server --test

The results are as follows:
insert image description here
It can be seen that the puppet client device has indeed executed the commands of the puppet server, started the Apache service, and the service resource configuration in our puppet is successful!
Originality is not easy, please indicate the source for reprinting: https://blog.csdn.net/weixin_40228200

Guess you like

Origin blog.csdn.net/weixin_40228200/article/details/123669749