Problem distributing facts/or debugging

18 views
Skip to first unread message

desdic

unread,
Oct 13, 2009, 2:13:36 PM10/13/09
to Puppet Users
Hi,

I have been trying to make facts work via modules (According to
http://reductivelabs.com/trac/puppet/wiki/PluginsInModules) but its
simply not working. I have been getting help via #puppet (And that has
been a big help) but still no luck

Data:

Master+server running Debian with puppet version 0.24.5-3

puppetteer:/etc/puppet/modules/mysqlserver# find .
.
./manifests
./manifests/init.pp
./plugins
./plugins/facter
./plugins/facter/mysqlversion.rb
./files

puppetteer:/etc/puppet/modules/mysqlserver# cat plugins/facter/
mysqlversion.rb
require 'facter'

Facter.add("mysqlversion") do
setcode do
%x{mysql -V}.chomp
end
end

and in my manifest I use

case $mysqlversion {
default: {
err(" mysqlversion is $mysqlversion")
err(" mysqlserver is $mysqlserver")
}
}

but the strings $mysqlversion and $mysqlserver is always empty. I run
my puppetmaster with puppetmasterd --no-daemonize -d --verbose and the
client with puppetd --no-daemonize -d -o --verbose

now when I run this I get the debug message:

....
debug: importing '/etc/puppet/modules/mysqlserver/manifests/init.pp'
info: Autoloaded module mysqlserver
err: Scope(Class[mysqlserver]): mysqlversion is
err: Scope(Class[mysqlserver]): mysqlserver is
...

but if I add this on the client

# mkdir -p ~/lib/ruby/facter ; export RUBYLIB=~/lib/ruby
# cd ~/lib/ruby/facter

and then add the same .rb script but with Facter.add("mysqlserver")
and then run the master + client again I actually get the mysqlversion
filled in $mysqlserver .. so my facter is working but to me it seems
that its not beein distributed to the client or a path is missing

my server configuration:
[main]
logdir=/var/log/puppet
vardir=/var/lib/puppet
ssldir=/var/lib/puppet/ssl
rundir=/var/run/puppet
factpath=$vardir/lib/facter
pluginsync=true

[puppetmasterd]
templatedir=/var/lib/puppet/templates

my client configuration:
[main]
logdir=/var/log/puppet
vardir=/var/lib/puppet
ssldir=/var/lib/puppet/ssl
rundir=/var/run/puppet
factpath=$vardir/lib/facter
pluginsync=true
server=puppetteer.netgroup.dk
factsignore=.svn CVS *.*~

[puppetmasterd]
templatedir=/var/lib/puppet/templates

anyone can tell me I'm doing wrong ?

Best regards
Kim

Kim Gert Nielsen

unread,
Oct 14, 2009, 3:12:36 PM10/14/09
to puppet...@googlegroups.com
Hi,

can anyone using facts verify that what I'm doing should be correct ?

Nigel Kersten

unread,
Oct 14, 2009, 3:45:34 PM10/14/09
to puppet...@googlegroups.com
On Wed, Oct 14, 2009 at 12:12 PM, Kim Gert Nielsen <k...@netgroup.dk> wrote:
>
> Hi,
>
> can anyone using facts verify that what I'm doing should be correct ?

Does this shed light on things?

http://reductivelabs.com/trac/puppet/wiki/UsingMultipleEnvironments

scroll to: "Plugins and Facts"
--
nigel

Kim Gert Nielsen

unread,
Oct 15, 2009, 6:46:41 AM10/15/09
to puppet...@googlegroups.com

no not really but I found the problem .. the version I have a bug when
using allow * in fileserver.conf and then I changed that to the IP it
worked :) but the other article is quite interesting because I was
going to use the enviroment for customers .. so instead of development
I would use customer01

Best regards
Kim

Marc Fournier

unread,
Oct 15, 2009, 7:36:41 AM10/15/09
to puppet...@googlegroups.com
> but the other article is quite interesting because I
> was going to use the enviroment for customers .. so instead of
> development I would use customer01

Beware that distributing facts and libs in modules doesn't work from
environments before 0.25.

Marc


Kim Gert Nielsen

unread,
Oct 15, 2009, 7:43:51 AM10/15/09
to puppet...@googlegroups.com

hmm then the debian version must be backported because it works in
0.24.5-3 :)

Peter Meier

unread,
Oct 15, 2009, 8:05:22 AM10/15/09
to Kim Gert Nielsen, puppet...@googlegroups.com
> hmm then the debian version must be backported because it works in
> 0.24.5-3 :)

it works if you define standard (non-per-environment) paths as well,
but puppet will then take the facts and plugins from this path and not
actually from the one in the environments.

cheers pete

Thomas Bellman

unread,
Oct 15, 2009, 8:22:53 AM10/15/09
to puppet...@googlegroups.com
Kim Gert Nielsen wrote:

It may be more correct to say that per-environment facts don't work
*reliably* before 0.25. The client would get its facts not from the
environment it request its manifest from, but from the environment
it used the *previous* time it connected to the Puppet-master. And
for a new client, or after a restart of the master, they would get
their facts from the default environment.

So, this would happen:

[Start puppetmasterd]

# puppetd --environment=devel
Gets facts from production, because that's what the default
environment is

# puppetd --environment=devel
Now gets facts from devel, because that's what it asked for
in the previous run

# puppetd --environment=production
Still gets facts from devel

# puppetd --environment=devel
Facts from production

[Restart puppetmasterd]

# puppetd --environment=devel
Facts from production, because that's what the default
environment is

The problem before 0.25 was that the client only told the master about
the wanted environment when it requested *manifests*, not when it
downloaded files (using the puppet: URL scheme), so the master guessed
what environment it used based on what it wanted the last time it asked
for its manifests. And a typical run of puppetd would do this:

1. Download custom facts (and resource types) using the puppet:
protocol (and thus without saying what environment it wanted)
2. Request compiled manifests for ENVIRONMENT.
3. Download files specified by the 'file' type using the puppet:
protocol.

which obviously fails.


And note that while per-environment custom facts is supposed to work in
0.25 (I haven't tried it myself, though), you still cannot have custom
resource types or custom functions per environment.


/Bellman

Reply all
Reply to author
Forward
0 new messages