Eugene Brodsky
2013-Feb-15 15:56 UTC
[Puppet Users] Puppet agent daemon not seeing a Facter fact
Hi all, first post here... reposting this from Stack Overflow as it didn''t get much traction there... I am using puppet to read a fact from facter, and based on that I apply a different configuration to my modules. Problem: the puppet agent isn''t seeing this fact. Running puppet agent --test interactively works as expected. Even running it non-interactively from a script seems to work fine. Only the agent *daemon* is screwing up. Process: I am deploying an Ubuntu-based app stack on EC2. Using userdata (#cloud-config), I set an environment variable in /etc/environment: export FACTER_tl_role=development then immediately in #cloud-config, i source /etc/environment. only THEN i apt-get install puppet (i moved away from using package: puppet to eliminate ambiguity in the sequence of #cloud-config steps) Once the instance boots, I confirm that the fact is available: running facter tl_role returns "development". I then check /var/log/syslog, and apparently the puppet agent is not seeing this fact - I know this because it''s unable to compile the catalog, and there''s nothing (blank) where I''m supposed to be seeing the value of the variable set depending on this fact. However, running puppet agent --test interactively compiles and runs the catalog just fine. even running this from the #cloud-config script (immediately after installing puppet) also works just fine. How do I make this fact available to the puppet agent? Restarting the agent service makes no difference, it remains unaware of the custom fact. Rebooting the instance also makes no difference. here''s some code: EC2 userdata: #cloud-config puppet: conf: agent: server: "puppet.foo.bar" certname: "%i.%f" report: "true" runcmd: - sleep 20 - echo ''export FACTER_tl_role=development'' >> /etc/environment - . /etc/environment - apt-get install puppet - puppet agent --test Main puppet manifest: # /etc/puppet/manifests/site.pp node default { case $tl_role { ''development'': { $sitedomain = "dev.foo.bar"} ''production'': { $sitedomain = "new.foo.bar"} } class {"code" : sitedomain => $sitedomain} class {"apache::site" : sitedomain => $sitedomain} class {"nodejs::grunt-daemon" : sitedomain => $sitedomain} And then I see failures where $sitedomain is supposed to be, so $tl_role appears to be not set. Any ideas? This is exploding my brain.... -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
jcbollinger
2013-Feb-15 20:23 UTC
[Puppet Users] Re: Puppet agent daemon not seeing a Facter fact
On Friday, February 15, 2013 9:56:09 AM UTC-6, Eugene Brodsky wrote:> > Hi all, first post here... reposting this from Stack Overflow as it didn''t > get much traction there... > > I am using puppet to read a fact from facter, and based on that I apply a > different configuration to my modules. > Problem: > > the puppet agent isn''t seeing this fact. Running puppet agent --test interactively > works as expected. Even running it non-interactively from a script seems to > work fine. Only the agent *daemon* is screwing up. >You seem to be assuming that the daemon will have the environment of a login shell, and that when it runs Facter it will provide its own full environment to the child process. Neither of those is a safe assumption. There are several ways to reliably provide custom facts to Puppet. The customary way is to write a bona fide Facter pluginand distribute it via Puppet''s automatic pluginsync mechanism, and that''s what I would recommend. If you want something simpler, however, then you might want to check out this plugin: https://github.com/ripienaar/facter-facts/tree/master/facts-dot-d. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Eugene Brodsky
2013-Feb-20 21:58 UTC
[Puppet Users] Re: Puppet agent daemon not seeing a Facter fact
A bit of an update: I ended up doing something very hackish, but it works. Basically, after installing Puppet, I stop the agent, and add a line to /etc/init.d/puppet to source /etc/environment. Then I start the agent. Works fantastically. I do realize this is a little ugly, but in this case was simpler to implement and easier to manage going forward than distributing custom Facter plugins. Thank you John for pointing me in the right direction. Cheers! -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.