Puppet facter operatingsystemrelease

1,909 views
Skip to first unread message

Romgo

unread,
Feb 8, 2011, 9:35:41 AM2/8/11
to Puppet Users
Hello,

I am running puppet server version 0.25.4-2, and since Debian squeeze
is the new stable release I would like to adapt some of my modules.

I have a syslog-ng module, I would like to specify another template
for my squeeze server.

I changed my init.pp as follow :


if ($operatingsystemrelease <= 5.0.8) {
$syslog_template = "syslog/syslog-ng.conf.erb"
}
else {
$syslog_template = "syslog/syslog-ng.conf-squeeze.erb"
}

[...]


file { "/etc/syslog-ng/syslog-ng.conf":
ensure => present,
mode => 644,
owner => root,
group => root,
content => template($syslog_template),
notify => service[syslog-ng],
}

I try this configuration thanks to the following post :
http://groups.google.com/group/puppet-users/browse_thread/thread/33bafb3fff10171f

But it doesn't work. My old client are still using "syslog/syslog-
ng.conf.erb" and I don't get any error message.

Maybe the puppet server is too old version for using facter
operatingsystemrelease ?

Thanks in advance.

Regards

Patrick

unread,
Feb 8, 2011, 5:48:53 PM2/8/11
to puppet...@googlegroups.com

Run "factor | grep operatingsystemrelease" on your client and see what happens. If it doesn't give output, try "factor" by itself and see if you have a typo in the name for the fact.

I would guess that it's not giving a version number, or giving one different from what you expect.

Felix Frank

unread,
Feb 9, 2011, 2:47:57 AM2/9/11
to puppet...@googlegroups.com
> Run "factor | grep operatingsystemrelease" on your client and see what happens. If it doesn't give output, try "factor" by itself and see if you have a typo in the name for the fact.

Erm, that's "facter operatingsystemrelease" or just "facter" :-)
Factor is a helpful tool, but not here and now.

> I would guess that it's not giving a version number, or giving one different from what you expect.

Quite possible. Note that facts can be different between different
versions of facter (don't get me started on the old lsbdistid etc.)

However, I suspect your error is rooted elsewhere. Hint:
http://docs.puppetlabs.com/references/stable/function.html#versioncmp

HTH,
Felix

Patrick

unread,
Feb 9, 2011, 2:52:54 AM2/9/11
to puppet...@googlegroups.com

On Feb 8, 2011, at 11:47 PM, Felix Frank wrote:

>> Run "factor | grep operatingsystemrelease" on your client and see what happens. If it doesn't give output, try "factor" by itself and see if you have a typo in the name for the fact.
>
> Erm, that's "facter operatingsystemrelease" or just "facter" :-)
> Factor is a helpful tool, but not here and now.

Ah thanks for the fix.

Hugo Deprez

unread,
Feb 9, 2011, 4:41:17 AM2/9/11
to puppet...@googlegroups.com
Hello,

thank you for the anwser.
I try to run facter on both servers here it what I get :

~ # facter operatingsystemrelease
5.0.8

~ $ facter operatingsystemrelease
6.0

So far no issues.

Maybe in my if statement I should use " " ?

Is there a way to print somewhere  the value of  the variables in order to be sure of what is return ?


If not i'll try to use versioncmp.

Thanks


--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.


Felix Frank

unread,
Feb 9, 2011, 4:48:09 AM2/9/11
to puppet...@googlegroups.com
> Is there a way to print somewhere the value of the variables in order
> to be sure of what is return ?

notify { "OS release detected as '$operatingsystemrelease'": }

Hugo Deprez

unread,
Feb 9, 2011, 5:23:07 AM2/9/11
to puppet...@googlegroups.com
Hello,

I found the solution thanks to your help  :

if versioncmp($operatingsystemrelease, '5.0.8') > 0 {
$syslog_template = "syslog/syslog-ng.conf-squeeze.erb"

}
else
{
$syslog_template = "syslog/syslog-ng.conf.erb"
}

and I add in my class :


notify { "OS release detected as '$operatingsystemrelease'": }
         notify { "template detected as '$syslog_template'": }

It works
Thank you !

Hugo


--
Reply all
Reply to author
Forward
0 new messages