---
: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
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
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
# 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
Thanks for your reply. I've realised my mistake in that I need to have a separate site.pp per environment. I'm used to just having one but with puppet 4.0 they've had a change around.
And yes I'm implementing the "role" like you are in the relevant .yaml files under hieradata. Thank you Gary and Craig.
Cheer Mike