Structured custom fact behavior

56 views
Skip to first unread message

Guto Carvalho

unread,
Nov 17, 2015, 9:19:29 PM11/17/15
to Puppet Users
Hi guys,

I'm playing around with custom facts, I'm trying to create a simple custom (structured) fact. 

[root@centos7 ~]# puppet --version
4.2.1

[root@centos7 ~]# facter --version
3.0.2 (commit 5dc120fa9db4c19150466b1bbd1d0cf42c87c6bd)

Here is my code


The fact is almost working

root@centos7 ~]# facter -p postgresql
{
  installed => true,
  version => "9.2.13"
}

When I try to print the fact value using notify it works fine

notify { "PostgreSQL version is ${::postgresql['version']}":

info: Applying configuration version '1447812110'
Notice: PostgreSQL version is 9.2.13
Notice: /Stage[main]/Main/Node[centos7.puppet]/Notify[PostgreSQL version is 9.2.13]/message: defined 'message' as 'PostgreSQL version is 9.2.13'

But, when I try to call postgresql.installed or postgresql.version facter doesn't show any result.

[root@centos7 ~]# facter -p postgresql.installed

[root@centos7 ~]# facter -p postgresql.version

What could possibly cause this?

Peter Huene

unread,
Nov 17, 2015, 9:24:14 PM11/17/15
to puppet...@googlegroups.com

Hi Guto,


On Nov 17, 2015 6:19 PM, "Guto Carvalho" <gutoca...@gmail.com> wrote:
>
> Hi guys,
>
> I'm playing around with custom facts, I'm trying to create a simple custom (structured) fact. 
>
> [root@centos7 ~]# puppet --version
> 4.2.1
>
> [root@centos7 ~]# facter --version
> 3.0.2 (commit 5dc120fa9db4c19150466b1bbd1d0cf42c87c6bd)
>
> Here is my code
>
> https://gist.github.com/gutocarvalho/d60987f4cee423d017c4
>
> The fact is almost working
>
> root@centos7 ~]# facter -p postgresql
> {
>   installed => true,
>   version => "9.2.13"
> }
>
> When I try to print the fact value using notify it works fine
>
> notify { "PostgreSQL version is ${::postgresql['version']}":
>
> info: Applying configuration version '1447812110'
> Notice: PostgreSQL version is 9.2.13
> Notice: /Stage[main]/Main/Node[centos7.puppet]/Notify[PostgreSQL version is 9.2.13]/message: defined 'message' as 'PostgreSQL version is 9.2.13'
>
> But, when I try to call postgresql.installed or postgresql.version facter doesn't show any result.

This was a bug in facter that was recently fixed. The bug was that facts from ruby (i.e. custom facts) were not able to be traversed by facter's command line query.  I'm on a mobile device at the moment, so I'll follow-up with a link to a ticket when I can.

>
> [root@centos7 ~]# facter -p postgresql.installed
>
> [root@centos7 ~]# facter -p postgresql.version
>
> What could possibly cause this?
>

> --
> 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...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/be550b4e-e7b7-4e36-89d4-2e37445b910f%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Peter Huene

unread,
Nov 17, 2015, 10:21:15 PM11/17/15
to puppet...@googlegroups.com
On Tue, Nov 17, 2015 at 6:24 PM, Peter Huene <peter...@puppetlabs.com> wrote:

Hi Guto,
On Nov 17, 2015 6:19 PM, "Guto Carvalho" <gutoca...@gmail.com> wrote:
>
> Hi guys,
>
> I'm playing around with custom facts, I'm trying to create a simple custom (structured) fact. 
>
> [root@centos7 ~]# puppet --version
> 4.2.1
>
> [root@centos7 ~]# facter --version
> 3.0.2 (commit 5dc120fa9db4c19150466b1bbd1d0cf42c87c6bd)
>
> Here is my code
>
> https://gist.github.com/gutocarvalho/d60987f4cee423d017c4
>
> The fact is almost working
>
> root@centos7 ~]# facter -p postgresql
> {
>   installed => true,
>   version => "9.2.13"
> }
>
> When I try to print the fact value using notify it works fine
>
> notify { "PostgreSQL version is ${::postgresql['version']}":
>
> info: Applying configuration version '1447812110'
> Notice: PostgreSQL version is 9.2.13
> Notice: /Stage[main]/Main/Node[centos7.puppet]/Notify[PostgreSQL version is 9.2.13]/message: defined 'message' as 'PostgreSQL version is 9.2.13'
>
> But, when I try to call postgresql.installed or postgresql.version facter doesn't show any result.

This was a bug in facter that was recently fixed. The bug was that facts from ruby (i.e. custom facts) were not able to be traversed by facter's command line query.  I'm on a mobile device at the moment, so I'll follow-up with a link to a ticket when I can.



It was fixed in Facter 3.1.2.

Guto Carvalho

unread,
Nov 17, 2015, 10:26:13 PM11/17/15
to Puppet Users
Thanks Peter!
Reply all
Reply to author
Forward
0 new messages