Puppet Resource type detailed (02)

Source: Internet
Author: User
Tags error status code

Common Types of resources:

Notify, Cron, Exec, service, file, package, group, user


(1) notify: Use puppet to define a message.

Message: Information content of the notification

Notify {' Warning ':message=> "from warning notify resource.",}


(2) Cron

Ensure: Target status

Command: Commands

Hour

Minute

Month

MonthDay

Weekday

Name: Names

User: Users receiving this task

Environment: Run-time environment variables


Cron {' message ':minute=> ' */10 ',command=> '/bin/echo ' puppet ' ',name=> ' echo something ',ensure=> present,}


(3) Exec

Command (Namevar): To execute an order, to be idempotent;

Creates: This resource is executed only if the file specified by this property does not exist;

Onlyif: The command specified by this resource is run only when the test condition specified by this property returns a success status code;

Unless: The command specified by this resource is run only when the test condition specified by this property returns an error status code;

User: Runs the specified command for the resource as specified by this attribute;


Group

Path: The search path of the command collection;

CWD: Run this command under the path specified in this property;

Refresh: Defines how to refresh this resource; The default behavior when this exec resource receives an event notification for another resource is to run the resource again, and the Refresh property is used to change the default behavior;

Refreshonly: Executes the command specified by this EXEC resource only when a refresh notification is received;

Timeout: command run timeout length;

Tries: Number of attempts to run;

exec {' test ':command=> ' echo ' Hi from exec again ' >>/tmp/hello.puppet ', Path = '/bin:/sbin:/usr/bin:/usr/ Sbin ',unless=> ' test-f/tmp/hello.puppet ',}


Note: If you do not specify the Path property, the command must be an absolute path, and the shell built-in command may not work;


(4) file

Content: Directly given the contents of the file;

Source: Copies the contents of the file defined by this attribute for this file;

Recurse: If source specifies a path for the directory to recursively transmit the entire directory; true or false;


Checksum: Specifies the method used to check whether the contents of the file have changed;

CTime

Mtime

Ensure: Whether the file exists or not and its file type

If the file does not already exist to create a new file, the values you can set are absent and Present,file and directory. If you specify present, the file is checked for existence and if it does not exist, if you specify absent, The file will be deleted (if Recurse = True, the directory will be deleted)

File, directory, link, present, absent

Target: Specifies the source file of the link when the ensure is link;

Force: forced operation or not;

Owner: Master

Group: Genus

Links: How to handle linked files when copying, follow, ignore, manage;

Mode: Permissions

Path:namevar, file path;


file {'/tmp/mydir ':ensure=> directory,}file {'/tmp/mydir/test.txt ':content=> ' Hello from file resource ', ensure= > file,}file {'/tmp/mydir/fstab.puppet ':source=> '/etc/fstab ',ensure=> file,}file {'/tmp/mydir/fstab.link ' :target=> '/tmp/mydir/fstab.puppet ',ensure=> link,}file {'/tmp/pam.puppet ':source=> '/ETC/PAM.D ', recurse= > true,ensure=> Directory,}


(5) Group

Name: Group name, Namevar

Gid:gid

System: Whether it is a group of systems;

Group {' Mygrp ':gid=> 2000,system=> false,}


(6) User

Comment: Notes

Ensure:

Expiry: Expiry time

GID: Basic Group

Groups: Additional groups

Managehome: Whether to make the home directory with "manageability";

Home: Home directory path

Shell: Default shell;

System: Whether it is a user;

Uid:uid

Name:namevar, user name;

Password: password

Password_max_age:

Password_min_age:


group {' MySQL ':ensure=> present,system=> true,gid=> 306,}
Group {' dbusers ':ensure=> present,gid=> 3306,}
User {' MySQL ':ensure=> present,uid=> 306,gid=> 306,groups=> ' dbusers ',system=> True,}


(7) Package

Ensure:present, absent, latest, installed or version number;

Name: package name, Namevar;

Source: package source;

Provider: Specifies that you want to use the Package manager;

package{' zsh ':ensure=> installed,}
package{' Nginx ':ensure=> installed,provider = rpm,source=> '/tmp/nginx-1.6.2-1.el6.ngx.x86_64.rpm ',}


(8) Service

Ensure:running, true; Stopped, false;

Enable: Whether the boot automatically start;

Hasrestart: tells puppet whether the service script is running using the "restart" parameter;

Hasstatus: Tells the Puppet whether the service script is running using the "status" parameter;

Name: script names;

Path: Script Lookup path

Pattern: Indicates the mode of the process associated with the search service, and is used to help determine whether the service is running when the script does not support the use of the Restart/status parameter;

Restart: Manually specify the command for the service "restart";

Start

Stop

Status

package{' Nginx ':ensure=> installed,provider = rpm,source=> '/tmp/nginx-1.6.2-1.el6.ngx.x86_64.rpm ',}
file {'/etc/nginx/conf.d/default.conf ':ensure=> file,source=> '/tmp/default.conf ',notify=> Service[' Nginx ‘],}
file {'/etc/nginx/nginx.conf ':ensure=> file,source=> '/tmp/nginx.conf ',notify=> Service[' Nginx '],}
service{' Nginx ':ensure=> running,enable=> true,require=> package[' nginx '],restart=> '/etc/rc.d/init.d/ Nginx Reload ',}

This article is from the "My Study blog" blog, please be sure to keep this source http://houzhimeng.blog.51cto.com/3938990/1734828

Puppet Resource type detailed (02)

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.