Puppet Advanced Guide--exec Resources detailed

Source: Internet
Author: User
Tags gz file

EXEC Resources

The function of the exec resource is to invoke the Linux system command to complete the basic operation of system administration.


1, Exec resources commonly used properties

exec {' Resource title ':

Command

Creates

Cwd

Environment

Group

Logoutput

Onlyif

Path

Refresh

Refreshonly

Returns

Timeout

Tries

Try_sleep

User

Provider

}


Command: Specifies the system command to execute.

creates: Specifies the file generated by the command. If this argument is provided, then the command will only be executed if the specified file does not exist, preventing multiple executions at the same time.

exec {' tar-xf/root/nginx.tar.gz ':

CWD = '/var/tmp ',

creates = '/var/tmp/myfile ',

Path = ["/usr/bin", "/usr/sbin"]

}

CWD: Specifies the directory that the command executes. If the directory does not exist, the command execution fails.

Environment: Set additional environment variables for the command. Note that if you use this to set path, then the properties of path will be overwritten. Multiple environment variables should be set in the form of arrays.

Group: The account groups that execute the command run.

logoutput: Whether the output is logged. The output is logged by default 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 legitimate log levels.

onlyif: If this parameter is set, then exec will only be executed when the command set by Onlyif returns 0 o'clock.

Path: The search path that the command executes. 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. Path = ["/bin/", "/sbin/", "/usr/bin/", "/usr/sbin/"]

Refresh =>true|false: Refreshes the command execution state.

refreshonly =>true|false: This property can cause the command to change to a refresh-only trigger, which means 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.

Returns: Specifies the code that is returned. If the command being executed returns other code, an error is returned. The default value is 0, which can be defined as an array of acceptable return codes or as a single value.

Timeout: The maximum time the command runs. If the command runs longer than the time defined by timeout, the command is terminated and handled as a failure to run. When a negative value is defined, the run time limit is canceled. The value of timeout is in seconds.

Tries: The command executes the retry count, which defaults to 1. After setting this value, the command retries the set number of times until the correct code returns.

try_sleep: Sets the time interval in seconds for the command to retry.

User: Specifies the account that executes the command.

Provider:shell and Windows.


2. Case analysis

Unzip the soft.tar.gz file and edit the/ETC/PUPPET/MANIFESTS/EXEC.PP through the Exec resource to puppet account identity.

exec {' Test ':

Path = ["/usr/bin", "/bin"],

creates = '/tmp/lock ',

user = ' puppet ',

Group = ' puppet ',

Timeout = ' 3 ',

Command = ' tar xf/root/soft.tar.gz ',

}


Test to see, you can see the file is properly decompressed.

# puppet APPLY/ETC/PUPPET/MANIFESTS/EXEC.PP

Notice:/stage[main]//exec[test]/returns:executed successfully

notice:finished catalog run in 0.20 seconds



please pay attention to http://www.wzlinux.com:45 and http://www.wzlinux.com .




This article is from the "Small Drops Linux" blog, make sure to keep this source http://wangzan18.blog.51cto.com/8021085/1685869

Puppet Advanced Guide--exec Resources detailed

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.