Ask Your Question
0

Can I add a custom fact on clients with info from the master?

asked 2013-03-21 14:53:05 -0500

Ash gravatar image

updated 2013-03-21 17:22:51 -0500

Stefan gravatar image

I have a dB on the master with client server info. I need to define custom facts on the clients using this info.

Can custom facts be setup in the clients puppet.conf or via the External Node Classifier?

PE 2.7.2

edit retag flag offensive close merge delete

Comments

I want to be able to filter by custom fact when using mcollective agents. The fact is whether the system is still being built, or has gone live. This info ...(more)

Ash gravatar imageAsh ( 2013-03-21 18:30:41 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2013-03-21 17:22:14 -0500

Stefan gravatar image

updated 2013-03-22 04:20:17 -0500

The intention behind facts are that the master can get information about the agent only the agent is aware of and that the master cannot know himself (like the agent's operating system or its uptime). It sounds weired that you now want to control the factvalue by your master.

It looks like you want to define a custom function. A custom function runs on your master so you can do your database lookup there and then use the returnvalue in your puppet manifest: http://docs.puppetlabs.com/guides/custom_functions.html

So the question is: What do you actually try ... (more)

edit flag offensive delete link more
1

answered 2013-05-23 07:16:11 -0500

Thomas Rasmussen gravatar image

I have the same problem, and in fact it seems as though a custom function is the way to go. I have created a function which can read a file, look for my FQDN and return a value for this key (simple space-separated file). My function is this:

  module Puppet::Parser::Functions
  newfunction(:get_customer_name, :type => :rvalue) do |args|
    fqdn = args[0]
    filename = "/tmp/customers.txt"
    custname="UNKNOWN"
    File.open(filename,"r").each_line do |line|
      host=line.split[0]
      customer=line.split[1]
      if host==fqdn then
         custname=customer
      end
    end
    # we return custname here
    custname
  end
end

I then have ... (more)

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-03-21 14:53:05 -0500

Seen: 3,030 times

Last updated: May 23 '13