puppet小知识

网上看到的一些有用的,记录下
常用的资源主要有以下几个:
file:文件管理
package:软件包管理
service:系统服务管理
cron:配置定期任务
exec:运行shell命令
(1)    file资源
更详细资料,可参见: http://puppet.wikidot.com/file
(2)    package资源
更详细资料,可参见: http://puppet.wikidot.com/package
(3)    service资源
更详细资料,可参见: http://puppet.wikidot.com/srv
(4)    exec资源
更详细资料,可参见: http://puppet.wikidot.com/exec
(5)    cron资源
更详细资料,可参见: http://puppet.wikidot.com/cron
 
puppet 文件(file)用法:
file常见语法
file {"/tmp/bixuan/etc":
        ensure => file,
        source =>"puppet://$puppetserver/files/etc",
        owner =>"root",
        group =>"root",
        mode =>"744"
}
file的基本属性:
path: Specifies the target location for file. (namevar)
ensure: Accepts absent, present, file, and directory.
            Any other value will be treated as a symlink.
owner: 文件所属用户.
group: 文件所属组.
mode: 文件权限,比如:755
content: 指定文件的内容,作为字符串返回。
source: 指定源文件
force: Force replacement of directories with a link. Valid values (true, false).
ignore: 忽略指定文件,比如.svn, .git.
          Omits files matching specified patterns during recursion (Ex: .svn, .git).
recurse: 递归检索文件,同步目录时设为true
purge: 清除已删除的文件。Whether or not to purge unmanaged file resources within a directory.
          Valid values (true,false)
例子
1、同步目录:
file {"/tmp/bixuan/etc":
        source =>"puppet://$puppetserver/files/etc",
        recurse =>"true", #递归检索文件,同步目录时设为true
        owner =>"root",
        group =>"root",
        mode =>"744",
        purge =>"true", #保持和source完全一致。类似rsync的 --delete参数
}
2、同步文件:
file { "/etc/sysctl.conf":
        source => "puppet://$puppetserver/files/etc/sysctl.conf",
        owner => "root",
        group => "root",
        mode => 0644,
}

你可能感兴趣的:(小知识点)