Problem with custom facts and hiera

577 views
Skip to first unread message

Dirk Heinrichs

unread,
Mar 11, 2014, 5:17:44 AM3/11/14
to puppet...@googlegroups.com
Hi,

I'm trying to categorize our Puppet agent nodes via custom facts. To do this, I've placed a simple text file "custom_facts.txt" into C:\ProgramData\PuppetLabs\facter\facts.d with content

[facts]
role = PuppetDev

When I call facter on the agent node, I can see the new fact.

On the server, I've added a line

  - "role/%{::role}"

into /etc/hiera.yaml, below the :hierarchy: line and restarted the master.

Finally, I've added /etc/puppet/hiera/role/PuppetDev.yaml with content

---
puppet_agent::version: 3.4.3

while /etc/puppet/hiera/common.yaml has

puppet_agent::version: 3.4.2

To verify that the correct version is delivered, I run

hiera puppet_agent::version ::role=PuppetDev

and get the correct version (3.4.3) back.

However, when I run the puppet agent on the node, it has role unset and thus it doesn't try to update the puppet agent.

What am I doing wrong here?

Master is 3.4.3, agents are 3.4.2.

Thanks...

    Dirk
--

Dirk Heinrichs, Senior Systems Engineer, Engineering Solutions
Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach
Tel: +49 2226 1596666 (Ansage) 1149
Email: d...@recommind.com
Skype: dirk.heinrichs.recommind
www.recommind.com

Craig Dunn

unread,
Mar 11, 2014, 5:31:25 AM3/11/14
to puppet...@googlegroups.com

Drop the :: from your hiera.yaml, it's being taken literally as '::role' rather than defining scope.

Regards
Craig


--
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/531ED4B8.5060001%40recommind.com.
For more options, visit https://groups.google.com/d/optout.



--
Enviatics | Automation and configuration management
http://www.enviatics.com | @Enviatics
Puppet Training http://www.enviatics.com/training/

Dirk Heinrichs

unread,
Mar 11, 2014, 6:21:00 AM3/11/14
to puppet...@googlegroups.com
Am 11.03.2014 10:31, schrieb Craig Dunn:
Drop the :: from your hiera.yaml, it's being taken literally as '::role' rather than defining scope.

That doesn't help, unfortunately. OTOH, using a predefined fact works fine. For example, I also have a line

  - "node/%{::fqdn}"

in hiera.yaml and I can overwrite values from common.yaml with values taken from node/myhost.recommind.com.yaml without problem.

To me it looks like facter is reading the file containing the custom fact, while the agent does not.

Bye...

Dirk Heinrichs

unread,
Mar 11, 2014, 7:44:58 AM3/11/14
to puppet...@googlegroups.com
Am 11.03.2014 10:17, schrieb Dirk Heinrichs:

To do this, I've placed a simple text file "custom_facts.txt" into C:\ProgramData\PuppetLabs\facter\facts.d with content

[facts]
role = PuppetDev

Got it to work by removing the blanks:

role=PuppetDev

Bye...

Matthew Burgess

unread,
Mar 11, 2014, 3:47:21 PM3/11/14
to puppet...@googlegroups.com


On 11 Mar 2014 10:21, "Dirk Heinrichs" <d...@recommind.com> wrote:
>
> To me it looks like facter is reading the file containing the custom fact, while the agent does not.

Puppet uses /etc/puppet/hiera.yaml (or /etc/puppetlabs/puppet/hiera.yaml for PE) not /etc/hiera.yaml. You could symlink them so that the hiera command and puppet both use the same configuration.

Regards

Matt

Garrett Honeycutt

unread,
Apr 30, 2014, 8:06:39 PM4/30/14
to puppet...@googlegroups.com, d...@recommind.com



Hi,

I ran into a similar issue and wanted to post the fix here for others. To create the text file I used

  echo key=value > file.txt

After looking in /var/lib/puppet/yaml/facts/<certname>.yaml, I found that there was trailing whitespace as I had 'key=value '. To fix, I edited in notepad to remove the trailing whitespace.

Hope this saves someone else some time :>
-g
Reply all
Reply to author
Forward
0 new messages