puppet连载16:搭建facter插件

简介: mkdir -p /etc/puppet/modules/public/{manifests,templates,files}vi /puppet/soft/backup_date.

mkdir -p /etc/puppet/modules/public/{manifests,templates,files}

vi /puppet/soft/backup_date.rb
Facter.add("backup_date") do
setcode do
Facter::Util::Resolution.exec('/bin/date +%Y%m%d%H%M%S')
end
end

vi /etc/puppet/modules/public/manifests/init.pp
class public::externalfacter {
exec {"mkdir facter":
command => "mkdir -p /etc/puppet/facter/",
path => ["/usr/bin","/usr/sbin","/bin","/sbin"],
creates => "/etc/puppet/facter/",
before => File["backup_date.rb"],
}
file {"backup_date.rb":
path => "/etc/puppet/facter/backup_date.rb",
source => "puppet:///soft/backup_date.rb",
mode => 755,owner => root,group => root,
ensure => present,
notify => Exec["profile"],
}
exec {"profile":
command => "sed -i '/FACTERLIB/d' /etc/profile && echo 'export FACTERLIB=/etc/puppet/facter'>>/etc/profile && source /etc/profile",
path =>["/usr/local/sbin","/usr/local/bin","/sbin","/bin","/usr/sbin","/usr/bin"],
user => root,group => root,
provider => shell,
refreshonly => true,
}
}

include public::externalfacter

目录
相关文章
|
JSON 开发工具 数据格式
puppet 自定义facter
自定义fact可以让节点增加更多的标签 在使用puppet作为配置管理工具的同时,facter是一个非常有用的系统盘点工具,这个工具可以通过一些预先设定好变量定位一台主机,比如可以通过变量lsbdistrelease便可以知道当前系统的版本号,通过osfamily便可以知道系统是RedHat还是SLES,还是其它等等。
1390 0
|
监控 Ruby 分布式计算
|
测试技术
puppet 利用 facter, 实现不同主机调用不同变量方法
 分析¶ 变量类型常见三种 1. 内建变量, 如 $title, $name 等, 针对类固定的格式而进行调用 2. 自定义变量, 如 myname = tttttt, 等, 但需要在每个类中进行独立定义, 不能够在类之间进行传递, 3. facter , 公共变量, 可以在每个类中共同使用, 当前打算使用 facter 作为变量的调用 测试1.¶ 修改
1310 0
|
安全 Linux 网络协议
puppet yum模块、配置仓储、mount模块
转载:http://blog.51cto.com/ywzhou/1577335 作用:自动为客户端配置YUM源,为使用yum安装软件包提供便捷。 1、服务端配置yum模块 (1)模块清单 [root@puppet ~]# tree /etc/puppe...
1080 0
|
网络协议 安全 网络安全
|
Perl 存储 数据挖掘