Newbie question re Hiera

33 views
Skip to first unread message

Alex Samad

unread,
Jun 21, 2016, 7:14:02 PM6/21/16
to Puppet Users
Hi

I have a greenfield install. Centos 6.x puppet opensource latest.  installed r10k.

I have setup my git repo, used the control repo as a starting spot.

now I am getting my head around hiera 

Looking at this https://docs.puppet.com/hiera/3.1/complete_example.html  I understand the way that works for each environment.

But how do I use hiera to allocate nodes to environments ?

for example can I classify by name regex, so all hosts with name ".*prod.*" is in production and ".*inf.*" into inf environment 
can I also classify by ip address ?

Rob Nelson

unread,
Jun 21, 2016, 8:39:34 PM6/21/16
to puppet...@googlegroups.com
Typically, you wouldn't actually classify or assign environment via hiera. That's a value provided to the master during checkin, either as a CLI argument or in puppet.conf. You could, of course, manage that file and provide an environment value through hiera. But that would change the environment used on next run, not the current run.

If you're in a master less environment, you could do some magic with hiera cli/puppet lookup to find a value for the environment then call puppet apply with that environment, but that seems a bit needlessly complex at that point.

You would typically use hiera to classify the node and assign the classes it receives, though. That would be done with hiera_include('some_key'), where somekey is found in your hierarchy with the proper value. 
--
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/8236b18c-2b1c-4733-a744-7dbeb281784c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

Alex Samad

unread,
Jun 21, 2016, 8:57:33 PM6/21/16
to Puppet Users
Done some more reading.

I'm have a  master puppet server

I had thought to use hiera. seems like i need to setup ENC https://docs.puppet.com/guides/external_nodes.html

Alex


On Wednesday, 22 June 2016 10:39:34 UTC+10, Rob Nelson wrote:
Typically, you wouldn't actually classify or assign environment via hiera. That's a value provided to the master during checkin, either as a CLI argument or in puppet.conf. You could, of course, manage that file and provide an environment value through hiera. But that would change the environment used on next run, not the current run.

If you're in a master less environment, you could do some magic with hiera cli/puppet lookup to find a value for the environment then call puppet apply with that environment, but that seems a bit needlessly complex at that point.

You would typically use hiera to classify the node and assign the classes it receives, though. That would be done with hiera_include('some_key'), where somekey is found in your hierarchy with the proper value. 

On Tuesday, June 21, 2016, Alex Samad <al...@samad.com.au> wrote:
Hi

I have a greenfield install. Centos 6.x puppet opensource latest.  installed r10k.

I have setup my git repo, used the control repo as a starting spot.

now I am getting my head around hiera 

Looking at this https://docs.puppet.com/hiera/3.1/complete_example.html  I understand the way that works for each environment.

But how do I use hiera to allocate nodes to environments ?

for example can I classify by name regex, so all hosts with name ".*prod.*" is in production and ".*inf.*" into inf environment 
can I also classify by ip address ?

--
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+unsubscribe@googlegroups.com.


--

Trevor Vaughan

unread,
Jun 22, 2016, 10:18:26 AM6/22/16
to puppet...@googlegroups.com
Hi Alex,


Thanks,

Trevor

--
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.



--
Trevor Vaughan
Vice President, Onyx Point, Inc

-- This account not approved for unencrypted proprietary information --
Reply all
Reply to author
Forward
0 new messages