Custom facts variables coming out empty on manifest

207 views
Skip to first unread message

Paulo Pinto

unread,
Apr 29, 2014, 3:48:12 PM4/29/14
to puppet...@googlegroups.com
Hi all.

I have a very simple Custom Fact in /etc/puppet/modules/facts/lib/facter/php_version.rb :

Facter.add(:php_version) do
  setcode do
    Facter::Util::Resolution.exec('php-config --version|awk -F "." \'{print $1$2}\'') 
  end
end

It gets deployed and if I run "facter -p |grep php " on the "slave" server I get:
php_version => 54

Now, if I try to use the variable on my manifest like this:

file { "/usr/local/lib/php.ini":
                owner => root,
                group => root,
                mode => 0644,
                source  =>  "puppet:///files/php${::php_version}.ini",
                require => Exec['install_cpanel']
        }


I always get on the "slave" log :

(/Stage[main]/Cpanel::Cpanel/File[/usr/local/lib/php.ini]) Could not evaluate: Could not retrieve information from environment production source(s) puppet:///files/php.ini

As it is obvious, it's not replacing the variable ${::php_version} as it should return php54.ini and not php.ini .

What am I doing wrong here ?

Best regards,

--
Paulo


José Luis Ledesma

unread,
Apr 29, 2014, 4:19:44 PM4/29/14
to puppet...@googlegroups.com

Hi,

Perhaps there is an environment diference between the command line and the puppet agent process. The first one I think is the path one.

I would try to launch the php-config --version and the awk with the full-path.

If that doesn't work, I would check if the php-config-version needs any environment variable.

Regards,

--
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/89d00ab1-018a-447f-a95f-3b804b25c85c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Paulo Pinto

unread,
Apr 29, 2014, 4:30:30 PM4/29/14
to puppet...@googlegroups.com
Hello Jose.

That was spot on ! Changed the script using the full path to both binaries did the trick:

Facter.add(:php_version) do
  setcode do
    Facter::Util::Resolution.exec('/usr/local/bin/php-config --version|/bin/awk -F "." \'{print $1$2}\'')
  end
end

Thanks ! That made my day :-)

--
Paulo 
Reply all
Reply to author
Forward
0 new messages