Did you just change hiera.yaml?  If so, you must restart puppetserver for 
changes to take effect.  We do something similar with roles, with this 
site.pp.  Stolen from Gary and it works well.

node default {
  $role = hiera('role')
  include $role
}


You need to set 'role' somewhere in your hieradata in which the first found 
in your hierarchy will win.  This is hard to answer well without 
understanding what you have in your hiera data.  This role needs to be set 
in your %{application} yaml file.

Not sure how helpful this will be.  

Mike

On Sunday, August 13, 2017 at 9:04:47 AM UTC-5, Dennis McCarthy wrote:
>
> Hi,
>
> I'm setting up Puppet 4.0 for the first time and I'm probably missing 
> something. In my hiera.yaml:
>
> ---
> :backends:
>   - yaml
> :hierarchy:
>   - "%{application}"
>   - common
>
>
> :yaml:
> # 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
> # When specifying a datadir, make sure the directory exists.
>   :datadir: "/etc/puppetlabs/code/environments/%{environment}/hieradata"
> #  :datadir: /etc/puppetlabs/code/environments/development/hieradata
>
> With this setting I get this on the node:
>
> root@dc1dapp01:~# facter -p | grep application
> application => app
> root@dc1dapp01:~#
> root@dc1dapp01:~# puppet agent -t
> Info: Using configured environment 'development'
> Info: Retrieving pluginfacts
> Info: Retrieving plugin
> Info: Loading facts
> Info: Caching catalog for dc1dweb01.example.com
> Info: Applying configuration version '1502632775'
> Notice: site.pp
> Notice: /Stage[main]/Main/Notify[site.pp ]/message: defined 'message' as 
> 'site.pp 
> '
> Notice:  this is the role_basic role
> Notice: /Stage[main]/Role_basic/Notify[ this is the role_basic role ]/
> message: defined 'message' as ' this is the role_basic role '
> Notice: Applied catalog in 0.05 seconds
>
> But if i explicitly point to environment development in the Hiera.yaml 
> file, I get the following output (this is the behavior I want):
>
> root@dc1dapp01:~# puppet agent -t
> Info: Using configured environment 'development'
> Info: Retrieving pluginfacts
> Info: Retrieving plugin
> Info: Loading facts
> Info: Caching catalog for dc1dweb01.example.com
> Info: Applying configuration version '1502632844'
> Notice: site.pp
> Notice: /Stage[main]/Main/Notify[site.pp ]/message: defined 'message' as 
> 'site.pp 
> '
> Notice:  this is the APP1 module
> Notice: /Stage[main]/App1/Notify[ this is the APP1 module ]/message: 
> defined 'message' as ' this is the APP1 module '
> Notice: Applied catalog in 0.03 seconds
>
> I have a fact for the application that I want to run a specific 
> role/profile for. Can anyone explan what I'm missing please?
>
> Thanks for your help.
>
> Here are some of my other config files:
>
> environment.conf
>
> # Each environment can have an environment.conf file. Its settings will 
> only
> # affect its own environment. See docs for more info:
> # 
> https://docs.puppetlabs.com/puppet/latest/reference/config_file_environment.html
>
>
> # Any unspecified settings use default values; some of those defaults are 
> based
> # on puppet.conf settings.
>
>
> # If these settings include relative file paths, they'll be resolved 
> relative to
> # this environment's directory.
>
>
> # Allowed settings and default values:
>
>
>  modulepath = ./modules:$basemodulepath
> # manifest = (default_manifest from puppet.conf, which defaults to 
> ./manifests)
> # config_version = (no script; Puppet will use the time the catalog was 
> compiled)
> # environment_timeout = (environment_timeout from puppet.conf, which 
> defaults to 0)
>     # Note: unless you have a specific reason, we recommend only setting
>     # environment_timeout in puppet.conf.
>
> # cat manifests/site.pp
>
>
> notify { 'site.pp ': }
> #hiera_include('classes')
>
>
>   $role = hiera('classes','role_basic')
>   include $role
>
>
>
>
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/c94948c8-83a6-4a0d-a1f1-b33affd7ceb8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to