云深处 发表于 2018-8-2 11:22:07

MCollective架构篇3-Puppet插件的部署及测试

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 %>'),
  
}
  
}
  

  
# yum install mcollective-facter-facts
  
# ll /usr/libexec/mcollective/mcollective/facts/
  
total 12
  
-rw-r--r-- 1 root root422 Feb 212013 facter_facts.ddl
  
-rw-r--r-- 1 root root945 Feb 212013 facter_facts.rb
  
-rw-r--r-- 1 root root 1530 May 21 01:34 yaml_facts.rb
  
# vim /etc/mcollective/server.cfg
  

  
# Facts
  
#factsource = yaml #注释掉
  
factsource = facter
  
plugin.yaml = /etc/mcollective/facts.yaml
  
# /etc/rc.d/init.d/mcollective restart
  
Shutting down mcollective:                                 
  
Starting mcollective:                                    
  
# 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
  
# 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
  
# 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
  
# 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
页: [1]
查看完整版本: MCollective架构篇3-Puppet插件的部署及测试