The detailed introduction and case analysis of exec resources in puppet

Source: Internet
Author: User
Tags log variables resource rsyslog

First, the system environment

1. Puppet Service End

release:rhel6.4

HOSTNAME:puppetserver.rsyslog.org

Tcp/ip:172.16.200.100/24

Packages:

Puppet-server-2.7.21-1.el6.noarch

mcollective-client-2.2.4

activemq-5.5.0

2, puppet node

release:rhel5.8

HOSTNAME:agent1.rsyslog.org

Tcp/ip:172.16.200.101/24

Packages:

Puppet-2.7.21-1.el5

Mcollective-2.2.4-1.el5

3, puppet node

release:rhel6.4

HOSTNAME:agent3.rsyslog.org

Tcp/ip:172.16.200.103/24

Packages:

Puppet-2.7.21-1.el6

Mcollective-2.2.4-1.el6

Ii. Introduction of resources

1, realize the function

1.1 Remote Execution System command, in fact, is the shell of the call

1.2 Because exec is a one-time execution resource, the exec name can be the same in different classes.

2, support parameters

2.1 Command => "Mkdir/tmp/rhel5/nginx", the commands executed must be the absolute path to the command being executed.

2.2 CWD => "/tmp/rhel5/nginx" specifies the directory where the command executes. If the directory does not exist, the command execution fails.

2.3 Environment => "Path=/home/puppetfans" to set additional environment variables for the command. Note that if you use this to set your path, the path's properties will be overwritten. Multiple environment variables should be set in the form of an array.

2.4 Group => defines the group of users who run the command. The results of running under different platforms cannot be determined, because variables are invariant when different users run the command, so this is a platform problem, not a Ruby or puppet problem.

2.5 logoutput => on_failure|true|false whether to record output. The default is to record output based on the log level (loglevel) of the exec resource. If defined as On_failure, the output is logged only when the command returns an error. The desirable values are: True,false and other valid log levels.

2.6 Onlyif => "/bin/ls/usr/local/nginx/conf", if this parameter is set, EXEC will only be executed when the Onlyif set command returns 0 o'clock.

2.7 Path => ["/bin/", "/sbin/", "/usr/bin/", "/usr/sbin/"] command to execute the search path. If path is not defined, the command needs to use an absolute path. The path can be defined as an array or as a colon-delimited form.

2.8 creates => "/tmp/rhel5/nginx" to specify the files generated by the command. If this argument is provided, the command will only be executed if the specified file does not exist:

2.9 Refresh =>true|false defines how the command is updated. When exec receives an event from another resource, the command is only executed again by default. However, this parameter allows you to perform different commands when defining updates.

2.10 Refreshonly =>true|false This property enables the command to be triggered only by refreshing, meaning that the command is executed only if a dependent object is changed. It only makes sense to use subscribe or notify at the same time.

2.11 returns specifies the returned code. If the executed command returns another code, a fault (error) is returned. The default value is 0, which can be defined as an array or single value consisting of acceptable return codes.

2.12 Timeout The maximum time that the => 0 command runs. If the command runs longer than the time defined by timeout, the command is terminated and processed as a run failure. When defined as a negative value, the limit of elapsed time is canceled. The value of the timeout is measured in seconds.

2.13 unless => "/bin/ls/usr/local/nginx/conf", if this variable is specified, then exec executes unless the command set by unless returns 0

2.14 User => "Nginx" to define who runs the command. Note that if you use this parameter, any error output will not be captured at the moment, which is a bug in Ruby.

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.