KevinY
KevinY

Reputation: 1239

Unknown variable error compiling puppet script with facter/ruby dependency

facter --version 3.0.2 (commit 5dc120fa9db4c19150466b1bbd1d0cf42c87c6bd)

puppet --version 4.2.1

Using this as an example: https://serverfault.com/questions/471995/how-do-i-check-if-a-user-exists-in-puppet

I'm having some issues which do not seem to be common. If I:

root@puppet manifests]# puppet master --compile cs1.home
Error: Evaluation Error: Unknown variable: '::user_exists_dmadmin'. at /etc/puppetlabs/code/environments/production/manifests/site.pp:28:5 on node cs1.home

From /etc/puppetlabs/code/environments/production/modules/facts/lib/facter/user_exists_dmadmin.rb

require 'facter'
Facter.add(:user_exists_dmadmin) do
  setcode do
    name = "dmadmin"
    Facter::Util::Resolution.exec("/usr/bin/id -u #{name} 2>/dev/null")
    #puts "inside user_exists_dmadmin"
  end
end

And site.pp contains

node "cs1.home" {
if ($::user_exists_dmadmin)  {
   notify {"Documentum Installation Owner exists - NOT  making an installation 
    at this time!" : }
 }else
 {
   notify {"Calling the Documentum Class for installation of Documentum":}
   include documentum
 }
}

And when I compile the catalog

[root@puppet production]# puppet master --compile cs1.home
Error: Evaluation Error: Unknown variable: '::user_exists_dmadmin'. at /etc/puppetlabs/code/environments/production/manifests/site.pp:29:6 on node cs1.home

Will be very grateful to know why the error.

Many thanks

Kevin

Upvotes: 0

Views: 1631

Answers (1)

Chris Pitman
Chris Pitman

Reputation: 13104

When you use puppet master --compile the last set of cached facts for the node are used, which means that this fact must not have been sent the last time puppet was run by the actual agent. Run puppet agent --test from cs1.home so that the plugin can be synced down and new fact values cached.

Upvotes: 1

Related Questions