Custom fact working, but not on the puppetmaster

51 views
Skip to first unread message

Bob Hoekstra

unread,
Apr 15, 2014, 10:09:46 AM4/15/14
to puppet...@googlegroups.com
This has me confused - please advise. Using open source puppet on AWS instances. Info is dumped into user-data at creation of the instances, and a custom fact reads this so that puppet can configure the instance depending on the content. So far so good. The fact:

# cat /etc/puppet/modules/useful_utils/lib/facter/ud_purpose.rb
require 'facter/util/ec2'
require 'open-uri'

Facter.add("ud_purpose") do
  setcode do
    if Facter::Util::EC2.userdata.match(/ud_purpose=(\S+)/)
      $1
    else
     'notfound'
    end
  end
end

On first puppet run, I see the fact bein installed and after this I can see the fact with "facter -p ud_purpose" on the command line (including the puppetmaster host). All good. Then I can check the logs. I have a line in site.pp
   notify{"PURPOSE: ${::ud_purpose}" : }
that works perfectly on all host except the puppet master. For this host I see
...: PURPOSE:
...: (/Stage[main]/Main/Node[purpose]/Notify[PURPOSE: ]/message) defined 'message' as 'PURPOSE: '
where I expect to see:
... : PURPOSE: PUPPET-0
as I can see (on the command line):
# facter -p ud_purpose
PUPPET-0

Is there anything I am doing wrong? The puppet.conf file is pretty similar between master and agents, though the master has a few additional lines to do with puppetdb and environments.

Jeff Fuller

unread,
Aug 19, 2014, 4:11:15 PM8/19/14
to puppet...@googlegroups.com
I encountered the same problem while trying to deploy custom facts. The solution that I have used is the assign a definite certname in puppet.conf under both the [agent] and [master] sections of the file, giving it the certname puppetmaster. After this, you need to deactivate the node as it was previously named (probably its fqdn), accept any SSL certificates it requested, then restart the puppet agent service. That allowed the backend (PuppetDB) to sync the puppetmaster's facts when the agent was re-run for me.

Good luck
Reply all
Reply to author
Forward
0 new messages