Re: How to override $::operatingsystem fact

1,790 views
Skip to first unread message

julien cosmao

unread,
Jul 17, 2012, 10:44:14 AM7/17/12
to puppet...@googlegroups.com

It works with puppet 2.7, but not with 2.6.2

[16:41:15 #168 root@:~$ ] FACTER_operatingsystem=plop puppet -e 'notify { "We are running on $::operatingsystem": }'
notice: We are running on Debian
notice: /Stage[main]//Notify[We are running on Debian]/message: defined 'message' as 'We are running on Debian'
[16:41:32 #169 root@:~$ ] puppetd --version
2.6.2
[16:41:35 #170 root@:~$ ] puppet agent --version
2.6.2


Le mardi 17 juillet 2012 15:30:15 UTC+2, julien cosmao a écrit :
Hi,

I want to add "Proxmox" as new value in $::operatingsystem.
"Proxmox" is based on Debian, so the normal value is currently "Debian".

To change that, I just write a custom fact based on the facter fact "operatingsystem"

Facter.add(:operatingsystem) do
 ...
   setcode do
   ...
   elsif FileTest.exists?("/usr/bin/pveversion")
       "Proxmox"

This method doesn't override the original fact.

I've also tried to set $::operatingsystem = "Proxmox" directly in my node.

What's the best way to do override an existing fact ?

Regards,

Julien

Garrett Honeycutt

unread,
Jul 17, 2012, 9:55:42 PM7/17/12
to puppet...@googlegroups.com
On 7/17/12 11:30 PM, julien cosmao wrote:
> Hi,
>
> I want to introduce "Proxmox" as new value in $::operatingsystem.
> "Proxmox" is based on Debian, so the normal value is currently "Debian".
>
> To change that, I just write a custom fact based on the facter fact
> "operatingsystem"
>
> Facter.add(:operatingsystem) do
> ...
> setcode do
> ...
> elsif FileTest.exists?("/usr/bin/pveversion")
> "Proxmox"
>
>
> This method doesn't override the original fact.
>
> I've also tried to set $::operatingsystem = "Proxmox" directly in my node.
>
> What's the best way to do override an existing fact ?
>
> Regards,
>
> Julien

Created feature request[1] #15579 to add Proxmox support to facter.

[1] - http://projects.puppetlabs.com/issues/15579

-g

--
Garrett Honeycutt

206.414.8658
http://puppetlabs.com


j.co...@gmail.com

unread,
Jul 18, 2012, 5:38:04 AM7/18/12
to puppet...@googlegroups.com
Hi,

Thanks !

Hailee, your solution works great. Very usefull for me.


2012/7/18 Garrett Honeycutt <gar...@puppetlabs.com>


--
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.




--
Julien COSMAO
tel: +33(0)6 32 34 99 87
Mail : j.co...@gmail.com

Heiko Finzel

unread,
Mar 23, 2013, 2:42:32 PM3/23/13
to puppet...@googlegroups.com
EDIT: In fact it does work.
I found out, because I still had some keys (e.g. hostname) in my debugging config. And these values were used by puppet correctly.
However a local "facter -p" won't show these values. In this case the original hostname will be used.

Jakov Sosic

unread,
Mar 24, 2013, 2:10:00 PM3/24/13
to puppet...@googlegroups.com
That is surely a bug?!


--
Jakov Sosic
www.srce.unizg.hr

SM

unread,
Sep 3, 2013, 3:03:19 PM9/3/13
to puppet...@googlegroups.com
Just for the record, this is the code I'm using:

Facter.add(:operatingsystem) do
  confine :kernel => [ 'Linux' ]
  has_weight 100
  setcode do
    if FileTest.exists?("/usr/bin/pveversion") then
        "Proxmox"
    end
  end
end

Facter.add(:operatingsystemrelease) do
  confine :kernel => [ 'Linux' ]
  has_weight 100
  setcode do
    if FileTest.exists?("/usr/bin/pveversion") then
        Facter::Util::Resolution.exec("/usr/bin/pveversion")
    end
  end
end


Reply all
Reply to author
Forward
0 new messages