大网数据广告活动
服务器运维问答

How do I make puppet post facts after run?

· 52CE 我爱测

I am using a simple puppet setup for a large number of servers. Puppet gets information from a CMDB using External Node Classifiers. This works perfectly. After each run, the Puppet master posts the status for the run to the CMDB…

问题原文

原帖链接 · magnusa · CC BY-SA 3.0

I am using a simple puppet setup for a large number of servers. Puppet gets information from a CMDB using External Node Classifiers. This works perfectly.

After each run, the Puppet master posts the status for the run to the CMDB using a custom report module. This also works great.

What I would like is Puppet to post the facts for a node after each run to the CMDB. Doing this, the CMDB could auto update things like memory, MAC address etc.

The question is; How can I achieve this?

The report mechanism only provides status and some metrics.

It's not so easy to write a custom storeconfig module (or at least I couldn't find any information regarding this).

Thanks for any help.

已采纳解答

原帖链接 · magnusa · CC BY-SA 3.0

I created a report module in Puppet that solved this particular use case. The reporter tries to read the latest yaml report then add extra stuff to the post.

  def process
    payload = { :host => self.host, :status => self.status, :kind => self.kind }   
    # if facts file found, read it and add facts to payload:
    if File.exists?("#{Puppet[:vardir]}/yaml/facts/#{self.host}.yaml")
        new_facts = {}
        node_facts = YAML.load_file("#{Puppet[:vardir]}/yaml/facts/#{self.host}.yaml")
        node_facts.values.each do |key, value|
            new_facts = new_facts.merge({key => value})
        end
        payload = payload.merge(new_facts)
    end    
    response = HTTParty.post(URL, :body => payload )
    Puppet.err "Response code: #{response.code} - #{response.body}" unless response.code == 200
  end

If you want to learn more about writing custom Puppet reports, check When Puppet reports part 2

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2013-06-13)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。