hiera "environmentss" question

270 views
Skip to first unread message

Guy Matz

unread,
May 2, 2012, 4:57:03 PM5/2/12
to puppet...@googlegroups.com
Hi!  I am using environments in my puppet setup, and would like to do the same for hiera.  I used to have this sort of hierarchy:
:hierarchy: - hosts/%{fqdn}
                - domain/%{domain}
                - whatever/%{some_fact}
                - common

with a yaml datadir:
:yaml:
   :datadir: - /etc/puppetlabs/puppet/hieradata

I would like to append %{environment} to my datadir in order to get separation, however it looks like I can't and will have to do this:
:hierarchy: - %{environment}/hosts/%{fqdn}
                - %{environment}/domain/%{domain}
                - %{environment}/whatever/%{some_fact}
                - %{environment}/common

Can anyone verify that appending %{environment} to datadir won't work?  Does anyone have a good way of separating hiera environments?

Thanks a lot!
Guy

Ramin K

unread,
May 2, 2012, 5:03:12 PM5/2/12
to puppet...@googlegroups.com
I'm using the following which I copied from somewhere. Quotes might be
part of the missing magic. Also I'm not sure you'd want a - in there
either.

:yaml:
:datadir: '/home/puppet/environments/%{environment}/hieradata'

Ramin

Gary Larizza

unread,
May 2, 2012, 5:16:37 PM5/2/12
to puppet...@googlegroups.com
I would use double-quotes for string interpolation, but this should work.  I've used this in a couple of on-site engagements, and it has worked well for us.


 


Ramin


--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.




--

Gary Larizza
Professional Services Engineer
Puppet Labs

Marek Dohojda

unread,
May 2, 2012, 5:23:49 PM5/2/12
to puppet...@googlegroups.com
I can attest to the fact that it works fine here is my:

:yaml:
        :datadir: '/etc/puppet/env/%{environment}/hieradata'

I am having no issues with that.



Guy

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.

Ramin K

unread,
May 2, 2012, 5:51:56 PM5/2/12
to puppet...@googlegroups.com
On 5/2/2012 2:16 PM, Gary Larizza wrote:
> I'm using the following which I copied from somewhere. Quotes might
> be part of the missing magic. Also I'm not sure you'd want a - in
> there either.
>
> :yaml:
> :datadir: '/home/puppet/environments/%{environment}/hieradata'
>
>
> I would use double-quotes for string interpolation, but this should
> work. I've used this in a couple of on-site engagements, and it has
> worked well for us.

I don't think this is correct. If it were, my config should not work at
all. In this case single or double quotes should both work. It's my
understanding that hiera.yaml is a data file that is going to be parsed
and then consumed by Puppet where things like variable interpolation
would happen. There isn't any variable interpolation during the parsing
so single quotes are more correct.

http://www.yaml.org/YAML_for_ruby.html#single-quoted_strings

Ramin

R.I.Pienaar

unread,
May 2, 2012, 5:56:00 PM5/2/12
to puppet...@googlegroups.com
that's correct yeah

Gary Larizza

unread,
May 2, 2012, 6:59:31 PM5/2/12
to puppet...@googlegroups.com
Yep, like RI said you're totally correct here.  Thanks for correcting :)

 

Ramin

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Guy Matz

unread,
May 3, 2012, 12:45:19 PM5/3/12
to puppet...@googlegroups.com
Hmmm . .   anyone have any idea why environment would not be getting interpolated?
Cannot find datafile /etc/puppetlabs/puppet/%{environment}/hieradata/10-host/gmatzpupnode.yaml

I have the following in my node's puppet.conf [agent] section:
environment = default

thanks again,
Guy

To unsubscribe from this group, send email to puppet-users...@googlegroups.com.

Ramin K

unread,
May 3, 2012, 1:51:44 PM5/3/12
to puppet...@googlegroups.com
On 5/3/2012 9:45 AM, Guy Matz wrote:
> Hmmm . . anyone have any idea why environment would not be getting
> interpolated?
> Cannot find datafile
> /etc/puppetlabs/puppet/%{environment}/hieradata/10-host/gmatzpupnode.yaml
>
> I have the following in my node's puppet.conf [agent] section:
> environment = default
>
> thanks again,
> Guy

I see a few possible problems. Have you configured a default environment
on the Puppet master? Puppet uses the environment 'production' when
nothing is set. Also does ./puppet/default/hieradata/ exist and are the
the rest of the paths correct based on what you've set in your hiera.yaml?

Ramin






Reply all
Reply to author
Forward
0 new messages