Hiera doesn t behave as expected or as written in doc

42 views
Skip to first unread message

Raphael

unread,
Jan 8, 2015, 3:52:42 AM1/8/15
to puppet...@googlegroups.com
Hi,
I have a working puppetmaster installed from package on an ubuntu server 14.04 64bits.
I've been struggeling for a while now with hiera to achieve what it is written in the doc ;

My hiera version is 1.3.0
Puppetmaster version 3.4.3

My hierachy settings is quite simple, with a common file and a specific file for host :

---
:backends:
 
- yaml
 
- json
:yaml:
 
:datadir: /etc/puppet/hieradata
:json:
 
:datadir: /etc/puppet/hieradata
:hierarchy:

 
- common
 
- "node/%{::fqdn}"

:merge_behavior: deeper

This file is in /etc/puppet/ and linked to /etc/hiera.yaml

In the common.yaml, I'm trying to use a variable based on facts (like in the example on the official documentation) :


smtpserver: "mail.%{::domain}"

When I issue hiera smtpserver, I have this output :

mail.

Even the lookup type (deeper here in my config) doesn t provide the same output as the example ...

Any idea ? version issue ?

Thx a lot for your advice / answer.

Martin Alfke

unread,
Jan 8, 2015, 9:20:45 AM1/8/15
to puppet...@googlegroups.com
Hi,
On 08.01.2015, at 09:52, Raphael <raphae...@gmail.com> wrote:

Hi,
I have a working puppetmaster installed from package on an ubuntu server 14.04 64bits.
I've been struggeling for a while now with hiera to achieve what it is written in the doc ;

My hiera version is 1.3.0
Puppetmaster version 3.4.3

My hierachy settings is quite simple, with a common file and a specific file for host :

---
:backends:
  - yaml
  - json
:yaml:
  :datadir: /etc/puppet/hieradata
:json:
  :datadir: /etc/puppet/hieradata
:hierarchy:

  - common
  - "node/%{::fqdn}"

:merge_behavior: deeper

This file is in /etc/puppet/ and linked to /etc/hiera.yaml

In the common.yaml, I'm trying to use a variable based on facts (like in the example on the official documentation) :


smtpserver: "mail.%{::domain}"

When I issue hiera smtpserver, I have this output :

mail.

You are running the hiera command on cli?
In this case you do not have facts available.
But: you can provide facts on cli:

hiera -c /etc/hiera.yaml smtpserver domain=foobar.com

hth,

Martin

Johan De Wit

unread,
Jan 8, 2015, 9:23:10 AM1/8/15
to puppet...@googlegroups.com
Hi Raphael,
hiera smtpserver domain=example.com

That should work.  If using hiera from CLI, you need to provide the facts etc also.

See the docs : https://docs.puppetlabs.com/hiera/1/command_line.html

hth

johan
--
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/3590c684-299f-4775-a12a-f241ab06f75d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


-- 
Johan De Wit

Open Source Consultant

Red Hat Certified Engineer              (805008667232363)
Puppet Certified Professional 2013/2014 (PCP0000006)
blog : http://johan.koewacht.net/
_________________________________________________________
 
Open-Future                 Phone     +32 (0)2/255 70 70
Zavelstraat 72              Fax       +32 (0)2/255 70 71
3071 KORTENBERG             Mobile    +32 (0)474/42 40 73
BELGIUM                     http://www.open-future.be
_________________________________________________________
 

Upcoming Events:

Zabbix Certified Specialist | http://www.open-future.be/zabbix-certified-professional-training-8th-till-9th-janaury

Zabbix Certified Professional | http://www.open-future.be/zabbix-certified-professional-training-8th-till-9th-janaury

Bacula Administrator 1 | http://www.open-future.be/bacula-administrator-i-training-13th-till-15th-january

Puppet Fundamentals | http://www.open-future.be/puppet-fundamentals-training-26th-till-28th-january

Puppet Architect | http://www.open-future.be/puppet-architect-training-29th-till-30th-january

Subscribe to our newsletter: http://eepurl.com/BUG8H


Raphael

unread,
Jan 8, 2015, 11:02:36 AM1/8/15
to puppet...@googlegroups.com
Oh yeah ! Sorry for this noise ! The manifest on my nodes applyed properly ... and I've got the the proper output from cli with the facts provided.

Regarding the lookup, here what I have :

Based on https://docs.puppetlabs.com/hiera/1/lookup_types.html

hiera site_users
{"bob"=>{"uid"=>501, "shell"=>"/bin/bash"},
 
"ash"=>{"uid"=>502, "shell"=>"/bin/zsh", "group"=>"common"}}


hiera site_users ::fqdn=myhost
{"jen"=>{"uid"=>503, "shell"=>"/bin/zsh", "group"=>"deglitch"},
 
"bob"=>{"uid"=>1000, "group"=>"deglitch"}}

My hiera.yaml settings :

:hierarchy:

 
- "node/%{::fqdn}"
 
- common

:merge_behavior: deeper

What did I miss ?

Martin Alfke

unread,
Jan 8, 2015, 11:09:32 AM1/8/15
to puppet...@googlegroups.com
When using cli you want to tell hiera to look up all hashes:

hiera -h site_users fqdn=myhost
> To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/1f7b7077-33bd-4511-bb81-396ffff96c2b%40googlegroups.com.

Raphael

unread,
Jan 8, 2015, 11:12:04 AM1/8/15
to puppet...@googlegroups.com
Hi Martin,
thx for this quick answer :]

When in puppet you use hiera_hash, the behaviour is the same as the -h option in cli ?

Martin Alfke

unread,
Jan 8, 2015, 11:17:06 AM1/8/15
to puppet...@googlegroups.com

On 08 Jan 2015, at 17:12, Raphael <raphae...@gmail.com> wrote:

> Hi Martin,
> thx for this quick answer :]
>
> When in puppet you use hiera_hash, the behaviour is the same as the -h option in cli ?

Yes.
CLI <-> Puppet:

hiera -a <-> hiera_array(…)
hiera -h <-> hiser_hash(…)
hiera <-> hiera(…)
> To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/402d009a-f981-4133-b660-eea3273716c8%40googlegroups.com.

Raphael

unread,
Jan 8, 2015, 11:21:19 AM1/8/15
to puppet...@googlegroups.com
Got it !

Thx for these explanation :D
Reply all
Reply to author
Forward
0 new messages