|
2,user: Manage users
属性:
name:用户名,/
uid:UID,
gid:基本组ID,
groups:附加组,不能包含基本组,
comment:注释,
expiry:过期时间,
home:家目录,
shell:默认shell类型,
system:是否为系统用户,
ensure:present/absent,
password:加密后的密码串,
资源引用:
Type;['']
类型的首字母必须大写;
关系元参数:before/require
A before B:B依赖于A,定于在A资源中;
{
...
before => Type['B'],
...
}
B require A: B依赖于A,定义在B资源中;
{
...
require => Type['A'],
...
}
3,Package:
Manage package
属性:
ensure:installed,present,latest,absent,
name:包名,
source:程序包来源,仅对不会自动下载的相关程序包的privide有用,例如:rpm或dbkg
provider:指明安装方式
4,service
puppet describe service -s -m :查看service资源的简单介绍
Manage running service
属性:
ensure:running/true or stopped/false
enable:ture or false
name:
path:脚本的搜索路径,默认为/etc/init.d
hasrestart:
hasstatus:
start:手动定于启动命令,
stop:
status:
restart:可自定义,通常用于定义reload操作
5,file
Manage files
属性:
ensure:present、absent、file、directory、link
file:类型为普通文件,
link:类型为符号链接文件,必须由target属性指明其链接的目标文件,
directory:类型为目录,可通过source指向的路径复制生成,recurse属性指明是否是递归复制,
path:文件路径,
source:源文件,
content:文件内容,
target:符号链接的目标文件,
owner:属主,
group:属组,
mode:权限,
atime/ctime/mtime:时间戳
资源有特殊属性:
名称变量
name可省略,此时将由title表示
ensure:
定义资源的目标状态
元参数:metaparameters
依赖关系:
before
require
通知关系:通知相关的其他资源进行刷新操作
notify
A notify B:B依赖于A,且A发生改变后会通知B;
{
...
notify => Type['B'],
...
}
subscribe
B subscribe A:B依赖于A,且B监控A资源的变化产生的事件;
{
...
subscribe => Type['A'],
...
}
示例:file{'test.txt':
path => '/tmp/test.txt',
ensure => file,
source => '/etc/fstab',
}
file{'test.symlink':
path => '/tmp/test.txt',
ensure => link,
target => '/tmp/test.txt'
require => File['test.txt'],
}
file{'test.dir':
path => '/tmp/test.dir',
ensure => directory,
source => '/etc/yum.repo.d/',
recurse => true,
}
示例2:service{'httpd':
ensure => running,
enable => true,
restart => 'systemctl restart httpd.service'
}
package{'httpd':
ensure=>true,
}
file{'httpd.conf':
path=>'/etc/httpd/conf/httpd.conf'
source=>'/root/manifests/httpd.conf',
ensure=>file,
notify=>Service['httpd'],
}
Package['httpd']-> File['httpd.conf']->Service['httpd']
6,exec:
Executes external commands. Any command in an `exec` resource **must** be able to run multiple times without causing harm --- that is, it must be *idempotent*.
**command** (*namevar*):要运行的命令;
cwd:The directory from which to run the command.
**creates**:文件路径,仅此路径表示的文件不存在时,command方才执行;
user/group:运行命令的用户身份;
path:The search path used for command execution. Commands must be fully qualified if no path is specified.
onlyif:此属性指定一个命令,此命令正常(退出码为0)运行时,当前command才会运行;
unless:此属性指定一个命令,此命令非正常(退出码为非0)运行时,当前command才会运行;
refresh:重新执行当前command的替代命令;
refreshonly:仅接收到订阅的资源的通知时方才运行;
cron:
Installs and manages cron jobs. Every cron resource created by Puppet requires a command and at least one periodic attribute (hour, minute, month, monthday, weekday, or special).
command:要执行的任务;
ensure:present/absent;
hour:
minute:
monthday:
month:
weekday:
user:以哪个用户的身份运行命令
target:添加为哪个用户的任务
name:cron job的名称;
示例:
cron{'timesync':
command => '/usr/sbin/ntpdate 172.16.0.1 &> /dev/null',
ensure => present,
minute => '*/3',
user => 'root',
}
notify:
Sends an arbitrary message to the agent run-time log.
属性:
message:信息内容
name:信息名称;
核心类型:
group: 组
user:用户
packge:程序包
service:服务
file:文件
exec:执行自定义命令,要求幂等
cron:周期性任务计划
notify:通知 |
|
|