Ask Your Question

facter not visible

asked 2015-12-31 01:02:45 -0500

rewurzb gravatar image

I define a fact called "openv" on my Puppet server. It provisions a VM server I use to create temporary VMs. This fact is visible within Puppet on the VM server. The Puppet configuration I inherited cannot pass the fact to the temporary VMs without significant changes. However, when the VM server creates a VM, it passes and runs a script on the VM to prepare it for provisioning. I pass the fact value to the script. When the script is run on the VM, it defines a variable in /etc/environment (CentOS 7) called FACTER_OPENV. The script then installs and starts Puppet on the VM. At that point, the Puppet instance on the VM begins to provision the VM using manifests from the Puppet server.

On the VM being provisioned, I can log into the VM and run "facter" from the command line and see the "openv" fact. However, the manifests being processed on the VM cannot, at least not using $openv as I do on the Puppet and VM servers. I have a manifest that copies a particular Yum repo definition onto a host based on the value of the "openv" fact. It works on the servers when referenced as $openv, but not on the temporary VMs. I've tried restarting Puppet thinking it needed to load the facts, but using $openv still does not resolve to value.

Any ideas as to why a fact is visible to facter, but not to Puppet, on the same host?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2015-12-31 09:08:13 -0500

rewurzb gravatar image

On the Puppet Server in a Ruby script:

Facter.add('openv') do
    setcode do

In a manifest common to all hosts:

notify { "Processing ${openv} configuration": }
if $openv == 'v9int'
        'Add V9 Yum Repository':
            path    => '/etc/yum.repos.d/docker.repo',
            mode    => '0750',
            ensure  => file,
            source  => "puppet:///modules/yum/${openv}-docker.repo";
elseif ....

On the Puppet and VM Servers, $openv is resolved to a value. On the temporary VMs using the environmental value FACTER_OPENV=v9int set by startup script and placed in /etc/environment on a CentOS VM. On the temporary VM, the command "facter openv" results in the output "v9int", but the manifest resolution is blank.

edit flag offensive delete link more

answered 2015-12-31 03:38:38 -0500

YevgenyT gravatar image

Can you provide an example of Puppet code?

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2015-12-31 01:02:45 -0500

Seen: 137 times

Last updated: Dec 31 '15