Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Dynamic list of files managed from hiera

Date: Fri, 2 Nov 2012 07:39:19 -0700 (PDT)
From: jcbollinger <John.Bollin...@stJude.org>
To: puppet-users@googlegroups.com
Message-Id: <7fe8c921-d163-4f3a-8366-13952a35c5bc@googlegroups.com>
In-Reply-To: <7f54c1b5-ce11-441f-9ff4-438d66e1cce2@googlegroups.com>
References: <7f54c1b5-ce11-441f-9ff4-438d66e1cce2@googlegroups.com>
Subject: Re: Dynamic list of files managed  from hiera
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_1537_14204281.1351867159761"

------=_Part_1537_14204281.1351867159761
Content-Type: multipart/alternative; 
	boundary="----=_Part_1538_25125569.1351867159761"

------=_Part_1538_25125569.1351867159761
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit



On Thursday, November 1, 2012 8:35:46 AM UTC-5, Guillem Liarte wrote:
>
>
> All,
>
> I use hiera in an straight way, for example:
>
> ---
> mode: '0644'
>
> that makes easy to do:
>
> file { somefile:
>      mode => hiera('mode')
> } 
>
>
> So far so good. But what about more complex structures? I would liek to be 
> able to handle hashes of data like this:
>
> in yaml:
>
> ---
> file_list:
>     - file1:
>       fname: 'config.conf' 
>       fpath: '/path/to/destination/'
>       fmode: '640'
>       fowner: 'sam'
>       fgroup: 'admin'
>   - file2:
>       fname: 'parameters.xml'
>       fpath: '/path/to/destination/'
>       fmode:  '660'
>       fowner: 'tom'
>       fgroup:  'finance'
>
>
> Is it possible to handle this right now?



Yes.  Hiera understands general YAML values (at least YAML 1.1; I don't 
know about 1.2) associated with top-level scalar keys.  Complex values are 
presented in Puppet via the natural mapping to Puppet hashes and arrays, 
nested as needed.

 

> What can I do in order to get a list of items that contain attributes?  I 
> understand taht this type of parsing happens for example when an ENC 
> produces YAML in this way:
>
> clasees:
>    myapp:
>       parameter1: 'value1'
>       parameter2: 'value2'
>
> Can I do something similar to this with puppet-hiera?
>


Again, yes.  The only caveat here is that the top level of your data 
document should associate values with scalar keys.  Hiera looks up values 
by those top-level keys.

 

>
> And also, is the a decent piece of *documentation* for hiera and 
> hiera-puppet? there seems to be almost nothing but fragmented 
> documentation. I am happy top read and research all this in my own but I 
> have struggled finding documentation.
>
>

I am unaware of any comprehensive documentation for Hiera.  Perhaps that 
overstates the case a bit, though, as "comprehensive" suggests big and 
complicated, and that's not a good characterization of Hiera.

If you have not already seen these documents, then you should read them:

https://github.com/puppetlabs/hiera  (scroll down)
https://github.com/puppetlabs/hiera-puppet  (scroll down)
http://puppetlabs.com/blog/first-look-installing-and-using-hiera/

Those should be enough to get anyone up and going with Hiera, but they do, 
I think, miss details about some of Hiera's more advanced capabilities.  
Until better documentation becomes available, this forum is a good place to 
pose questions.  And there's always the code, of course, which is fairly 
small.


John


------=_Part_1538_25125569.1351867159761
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

<br><br>On Thursday, November 1, 2012 8:35:46 AM UTC-5, Guillem Liarte wrot=
e:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;b=
order-left: 1px #ccc solid;padding-left: 1ex;"><br>All,<br><br>I use hiera =
in an straight way, for example:<br><br>---<br>mode: '0644'<br><br>that mak=
es easy to do:<br><br>file { somefile:<br>&nbsp; &nbsp;&nbsp; mode =3D&gt; =
hiera('mode')<br>} <br><br><br>So far so good. But what about more complex =
structures? I would liek to be able to handle hashes of data like this:<br>=
<br>in yaml:<br><br>---<br>file_list:<br>&nbsp;&nbsp;&nbsp; - file1:<br>&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp; fname: 'config.conf' <br>&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp; fpath: '/path/to/destination/'<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; f=
mode: '640'<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fowner: 'sam'<br>&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp; fgroup: 'admin'<br>&nbsp; - file2:<br>&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp; fname: 'parameters.xml'<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fpat=
h: '/path/to/destination/'<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fmode:&nbsp; '=
660'<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fowner: 'tom'<br>&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp; fgroup:&nbsp; 'finance'<br><br><br>Is it possible to handle thi=
s right now?</blockquote><div><br><br>Yes.&nbsp; Hiera understands general =
YAML values (at least YAML 1.1; I don't know about 1.2) associated with top=
-level scalar keys.&nbsp; Complex values are presented in Puppet via the na=
tural mapping to Puppet hashes and arrays, nested as needed.<br><br>&nbsp;<=
/div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8e=
x;border-left: 1px #ccc solid;padding-left: 1ex;"> What can I do in order t=
o get a list of items that contain attributes?&nbsp; I understand taht this=
 type of parsing happens for example when an ENC produces YAML in this way:=
<br><br>clasees:<br>&nbsp;&nbsp; myapp:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p=
arameter1: 'value1'<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; parameter2: 'value2'<=
br><br>Can I do something similar to this with puppet-hiera?<br></blockquot=
e><div><br><br>Again, yes.&nbsp; The only caveat here is that the top level=
 of your data document should associate values with scalar keys.&nbsp; Hier=
a looks up values by those top-level keys.<br><br>&nbsp;</div><blockquote c=
lass=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px=
 #ccc solid;padding-left: 1ex;"><br>And also, is the a decent piece of <b>d=
ocumentation</b> for hiera and hiera-puppet? there seems to be almost nothi=
ng but fragmented documentation. I am happy top read and research all this =
in my own but I have struggled finding documentation.<br><br></blockquote><=
div><br><br>I am unaware of any comprehensive documentation for Hiera.&nbsp=
; Perhaps that overstates the case a bit, though, as "comprehensive" sugges=
ts big and complicated, and that's not a good characterization of Hiera.<br=
><br>If you have not already seen these documents, then you should read the=
m:<br><br>https://github.com/puppetlabs/hiera&nbsp; (scroll down)<br>https:=
//github.com/puppetlabs/hiera-puppet&nbsp; (scroll down)<br>http://puppetla=
bs.com/blog/first-look-installing-and-using-hiera/<br><br>Those should be e=
nough to get anyone up and going with Hiera, but they do, I think, miss det=
ails about some of Hiera's more advanced capabilities.&nbsp; Until better d=
ocumentation becomes available, this forum is a good place to pose question=
s.&nbsp; And there's always the code, of course, which is fairly small.<br>=
<br><br>John<br><br></div>
------=_Part_1538_25125569.1351867159761--

------=_Part_1537_14204281.1351867159761--