I need help; I have been going in circles for too long now and I am sure it
is something silly that I over looked. I am attempting to use environments
with a new server build for Puppet 4 (never could get it working under the
Puppet 3 series; but I never put /that/ much effort into it either). I have
a lot of servers that I really don't want to manage by hand or manually set
anything per server. I would much rather have the agent contact the puppet
server to find out what group it should be in. Yes, there is documentation
on this but I can't get it to work and almost all of my internet sleuthing
has returned results for the old way of doing things which doesn't appear
to be working with Puppet 4 and Hiera 3. Any help would be much appreciated.

My objective: Have a top-level hiera source that tells agents which
environment to use for that host. Have hiera data in the environments
provide further details (ntp servers and what not) for configuring the host.

From my understanding of this[1] it should work. I also found several
online blog examples doing something similar but using the old puppet3 way
of doing things.
[1] https://docs.puppetlabs.com/guides/external_nodes.html

Everything in the production environment works all the time with Hiera. No
other environment works with Hiera calls. I have found it easier to test
for the ntp configuration because unless the system and environment are
"production", testing for the environment just gives 'nil' which doesn't
tell me squat about what is wrong. At least asking for the ntp gives me
errors to look at. :-)

First, lets look at my top level hiera. Pretty default. You can see that I
attempted to force the location for the yaml, but that didn't work either
and I don't want _all_ the servers in the top level anyway.

$ cat /etc/puppetlabs/code/hiera.yaml
   - yaml
   - "nodes/%{::trusted.certname}"
   - common

# datadir is empty here, so hiera uses its defaults:
# - /etc/puppetlabs/code/environments/%{environment}/hieradata on *nix
# - %CommonAppData%\PuppetLabs\code\environments\%{environment}\hieradata
on Windows
# - /etc/puppetlabs/code/hieradata
# When specifying a datadir, make sure the directory exists.

Now, lets look at the common file for the production environment.

$ cat /etc/puppetlabs/code/environments/production/hieradata/common.yaml
environment: 'production'

$ puppet apply --certname=puppetmaster01.me.fqdn -e
Notice: Scope(Class[main]): [,]
Notice: Compiled catalog for puppetmaster01.me.fqdn in environment
production in 0.43 seconds
Notice: Applied catalog in 0.09 seconds

Great! Hiera is working! Now lets move that common file to the top level so
that we can specify which environment to use (again testing with ntp so we
get more than just 'nil' back).

$ mv /etc/puppetlabs/code/environments/production/hieradata/common.yaml
$ puppet apply --certname=puppetmaster01.me.fqdn -e
Error: Evaluation Error: Error while evaluating a Function Call, Could not
find data item ntp::servers in any Hiera data file and no default supplied
  at line 1:8 on node puppetmaster01.me.fqdn

I found a blog that said the puppetserver has to be restarted after every
yaml change (I think that is /way/ off base as that hasn't been quite my
experience) but even doing a restart doesn't change the outcome.

Where I am stuck:
* I can't get any host to work with any environment except "production".
Nothing seems to work. Not hiera, nor puppet agent -t. The host just isn't
* I can't get the top level hiera to provide any details to the agent.

Any help would be greatly appreciated!

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.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/0ba7a983-10be-4e37-9ead-73f184be5476%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 7 | next ›
Discussion Overview
grouppuppet-users @
postedJul 23, '15 at 9:23p
activeJul 24, '15 at 1:05p



site design / logo © 2022 Grokbase