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. supporting files and directories
1.2, set the file and directory owners and permissions
1.3, restore documents (including the contents of the document, permissions and owners)
1.4, clean up the directory and subdirectories
2, support parameters
2.1 Ensure => {Present|absent|directory|file|link}, specifying the target state of the file
=> present, check whether the file exists or not, the new
=> absent, check if the file exists, delete it
=> directory, specifies that this is a directory that does not exist to create
2.2 Owner|user => Root, user, can also use UID
2.3 Group => Puppet, Group of users, can also use GID
2.4 Mode => 0644, permission attributes, four-bit octal number
2.5 Source => "Puppet:///modules/ssh/etc/ssh/sshd_config" | Soure => "/etc/passwd" file gets the address, starts with the puppet:///and downloads from master, and the normal path is read locally by the agent
Note: "puppet://" is equivalent to the Modulepath value in the main configuration file Puppet.config
2.6 Path => "/ETC/POSTFIX/MAIN.CF", the full path to the file. The default is the same as title, not written
eg.
file {"MAIN.CF":
Path => "/ETC/POSTFIX/MAIN.CF",
2.7 Content => "Hello", |content => template ("Postfix/main.cf.erb"), the specific contents of the file, can also be generated by the Erb template, select this does not write resource source
2.8 Backup => ' main ', | Backup => ". $backup _date.bak", the previous version backup method before the node was updated; Backup => ' main ' needs to be implemented with resources Filebucket
2.9 recurse => ' {true|false|inf|remote} ' for a directory (TRUE) No (false) recursion (ensure => directory is valid)
There are three 2.10 puppet dependency resources, respectively Require,before,after
Require => class["Mysql::install"], | Require => package["Setup", where the current resource or class is dependent on the resource or class required, the resource or class required to execute successfully after executing its own resource or class
Before is executed before a resource
Package {"Openssh-server":
...
Before => file["/etc/ssh/sshd_config"],
}
After a resource is executed
file {"/etc/ssh/sshd_config":
...
After => package["Openssh-server"],
}