|
class mcollective::facter {
file{"/etc/mcollective/facts.yaml":
owner => root,
group => root,
mode => 0440,
loglevel => debug, # reduce noise in Puppet reports
content => inline_template('<%= scope.to_hash.reject { |k,v| k.to_s =~ /(uptime.*|path|timestamp|free|.*password.*|.*psk.*|.*key)/ }.to_yaml %>'),
}
}
[root@agent1 ~]# yum install mcollective-facter-facts
[root@agent1 rpms]# ll /usr/libexec/mcollective/mcollective/facts/
total 12
-rw-r--r-- 1 root root 422 Feb 21 2013 facter_facts.ddl
-rw-r--r-- 1 root root 945 Feb 21 2013 facter_facts.rb
-rw-r--r-- 1 root root 1530 May 21 01:34 yaml_facts.rb
[root@agent1 ~]# vim /etc/mcollective/server.cfg
…
# Facts
#factsource = yaml #注释掉
factsource = facter
plugin.yaml = /etc/mcollective/facts.yaml
[root@agent1 rpms]# /etc/rc.d/init.d/mcollective restart
Shutting down mcollective: [ OK ]
Starting mcollective: [ OK ]
[root@puppetserver rpms]# mco inventory agent1.kisspuppet.com #查看节点agent1是否加载了facts插件
Inventory for agent1.kisspuppet.com:
Server Statistics:
Version: 2.2.4
Start Time: Thu Oct 03 16:31:47 +0800 2013
Config File: /etc/mcollective/server.cfg
Collectives: mcollective
Main Collective: mcollective
Process ID: 9485
Total Messages: 37
Messages Passed Filters: 33
Messages Filtered: 4
Expired Messages: 0
Replies Sent: 32
Total Processor Time: 0.74 seconds
System Time: 0.21 seconds
Agents:
discovery puppet rpcutil
Data Plugins:
agent fstat puppet
resource
Configuration Management Classes:
No classes applied
Facts: #可以看到获取的节点facter信息(获取信息需要一些等待时间)
architecture => x86_64
augeasversion => 0.10.0
bios_release_date => 07/02/2012
bios_vendor => Phoenix Technologies LTD
bios_version => 6.00
blockdevice_fd0_size => 4096
…
uptime_days => 0
uptime_hours => 20
uptime_seconds => 74506
uuid => 564DFBAB-CADC-FC69-36CA-955BFDB30F43
virtual => vmware
[root@puppetserver rpms]# mco facts lsbdistdescription -v #使用mco facts命令对操作系统类型进行显示
Discovering hosts using the mc method for 2 second(s) .... 2
Report for fact: lsbdistdescription
Red Hat Enterprise Linux Server release 5.7 (Tikanga)found 1 times
agent2.kisspuppet.com
Red Hat Enterprise Linux Server release 5.8 (Tikanga)found 1 times
agent1.kisspuppet.com
---- rpc stats ----
Nodes: 2 / 2
Pass / Fail: 2 / 0
Start Time: Thu Oct 03 16:59:04 +0800 2013
Discovery Time: 2004.83ms
Agent Time: 67.32ms
Total Time: 2072.15ms
[root@puppetserver rpms]# mco facts lsbdistdescription #使用mco facts命令对操作系统类型进行统计
Report for fact: lsbdistdescription
Red Hat Enterprise Linux Server release 5.7 (Tikanga)found 1 times
Red Hat Enterprise Linux Server release 5.8 (Tikanga)found 1 times
Finished processing 2 / 2 hosts in 79.15 ms
[root@puppetserver rpms]# mco facts -v --with-fact hostname='agent1' memoryfree #查看主机agent1的剩余内存
Discovering hosts using the mc method for 2 second(s) .... 1
Report for fact: memoryfree
795.13 MB found 1 times
agent1.kisspuppet.com
---- rpc stats ----
Nodes: 1 / 1
Pass / Fail: 1 / 0
Start Time: Thu Oct 03 17:02:13 +0800 2013
Discovery Time: 2005.65ms
Agent Time: 49.37ms
Total Time: 2055.03ms |
|
|