When does puppet agent load newly installed facter facts?

2,845 views
Skip to first unread message

John Pyeatt

unread,
Jan 8, 2014, 1:38:03 PM1/8/14
to puppet...@googlegroups.com

I think I have run into some sort of facter caching issue in the puppet agent that I am hoping someone can explain.

When I launch a new server I run the following command to get things started.

puppet agent --test --onetime --no-daemonize --waitforcert 5

The puppetmaster then downloads to the server as one would expect. Included in this download are some new custom facts (one is called cassandra_home_dir)  that I have written. It correctly puts them in /var/lib/puppet/lib/facter.

After the puppet agent has downloaded the custom facts it continues processing. In one of my .pp files there is a resource declaration as follows:

   file {"cassandraEnv":
      owner => 'cassandra',
      group => 'cassandra',
      mode  => '744',
      ensure => present,
      path => "${cassandra_home_dir}/conf/cassandra-env.sh",
      content => template('db/cassandra-env.sh.template.erb'),
      require => Exec['installCassandra'],
   }


But it is failing on this resource because ${cassandra_home_dir} is empty and therefore it is trying to put the file in the /conf directory which doesn't exist. The Exec['installCassandra'] executed correctly immediately prior to the attempt to create the file['cassandraEnv'] resource. So I know the appropriate information is available from the file system.

If I run the puppet agent command again everything works fine because the ${cassandra_home_dir} variable is no longer empty. So I have done nothing different other than rerun the puppet agent.

Does puppet agent cache facter facts at startup that is preventing it from loading my newly downloaded fact?


--
John Pyeatt
Singlewire Software, LLC
www.singlewire.com
------------------
608.661.1184
john....@singlewire.com

Jose Luis Ledesma

unread,
Jan 8, 2014, 1:52:16 PM1/8/14
to puppet...@googlegroups.com
Puppet loads facts first of all, so custom facts deployed are not there until next run.

Regards

jcbollinger

unread,
Jan 9, 2014, 9:48:21 AM1/9/14
to puppet...@googlegroups.com


On Wednesday, January 8, 2014 12:52:16 PM UTC-6, Jose Luis Ledesma wrote:
Puppet loads facts first of all, so custom facts deployed are not there until next run.



No, that's incorrect.  Normally, Puppet synchronizes plugins first of all, including custom facts set up as native plugins (the traditional form of custom facts).  Only afterward does the agent evaluate facts, so the values of custom facts are then available during the same run in which they are synced.  This is documented and intended behavior.

There are other ways in which custom facts can be installed on the system, however -- notably for use with the "external facts" mechanism -- that proceed via normal Puppet resource management.  Facts such as those are not available until the run after they are installed.

Inasmuch as the facts in question are being installed in /var/lib/puppet/lib/facter, they must be (intended to be) of the first type.  As such, they should be set up on the master as described here: http://docs.puppetlabs.com/guides/plugins_in_modules.html .  If indeed they are, then they should be available on the same run in which they are synced.

It is entirely conceivable that Puppet's normal chain of events is not proceeding as intended when the client does not initially have the master's certificate (or a signed certificate of its own).  I do not recall previous reports of such an issue, however, and a quick search of the issue tracker didn't turn up anything, so if that's what's happening then it's probably a new issue.  What version of Puppet are you using?

You could try running the agent as 'puppet agent --test --debug --waitforcert 5' to get full debug output about what the agent is doing (--onetime and --no-daemonize are already implied by --test).  That might be illuminating.


John



Stefan Heijmans

unread,
Jan 10, 2014, 3:42:29 AM1/10/14
to puppet...@googlegroups.com

Hi,

>>The Exec['installCassandra'] executed correctly immediately prior to the attempt to create the file['cassandraEnv'] resource. So I know the appropriate >>information is available from the file system.

It is a new server, so exec['installCassandra'] will install it but after that, your custom fact cassandra_home_dir (=empty) won't be updated anymore during the Puppet run, only at beginning.
That's why it does work for the second run, as it is already installed.

Stefan

jcbollinger

unread,
Jan 10, 2014, 4:41:07 PM1/10/14
to puppet...@googlegroups.com

That supposes the custom fact in question depends on something that will be installed by the Exec['installCassandra'] resource, which indeed seems a promising explanation.  I have seen custom facts written that way.

If a custom fact is to be used to determine the Cassandra installation location, then the manifests that consume that data need to be prepared for the case that Cassandra is not (yet) installed before the catalog run.  That Cassandra may be installed during the catalog run is irrelevant.  Facts always communicate node state as of just before the catalog run commences.


John

Reply all
Reply to author
Forward
0 new messages