Ask Your Question
0

Puppet standalone and hiera

asked 2018-01-25 04:02:54 -0500

Sebastian Krysmanski gravatar image

I'm running Puppet as standalone (i.e. with puppet apply) and have some modules that I want to configure with hiera. But I can't figure out how to make hiera lookup values that are not stored in the to-be-configured module itself.

From what I read here, I probably need to store the hiera values in a Puppet environment. But I can't figure out the folder structure for an environment when running Puppet as standalone.

I've read Creating Environments but I still can't make heads or tails of it.

Here's the folder structure I currently have (in some "random" folder):

+- modules
   +- module1
   +- module2
+- main.pp

With this I call:

puppet apply --modulepath=modules main.pp

One of the modules (mymodule) makes a lookup like this:

$software_dir = lookup('mymodule::software_dir')

So I'm looking to configure mymodule::software_dir with hiera outside of the module mymodule.

Any pointers?

I should note that I'm running Puppet 5.3.3 on Windows but if someone can point me to a solution that works on Linux, that's totally fine too.

edit retag flag offensive close merge delete

Comments

I’ll have to double check, but I think there is a —hiera-path or something like that available, I had used that for bootstrapping an initial run with puppet apply to use puppet to set up the master in my configuration...

DarylW gravatar imageDarylW ( 2018-01-25 22:44:42 -0500 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2018-01-25 23:29:00 -0500

ThyHum gravatar image

Try creating these folder structure and files:

+- modules/
   +- modules1/
   +- modules2/
+- hieradata/
   +- common.yaml
+- environment.conf
+- puppet.conf
+- hiera.yaml
+- main.pp

environment.conf

# You also have site directory for your roles & profiles
modulepath = site:modules:$basemodulepath

puppet.conf

[main]
codedir=$confdir
environmentpath=$confdir
environment=''

hiera.yaml

---
version: 5
defaults:
  datadir: hieradata
  data_hash: yaml_data
hierarchy:
# You can also enable these:
#  - name: "Per-node data"
#    path: "nodes/%{::hostname}.yaml"
#  - name: "Common encrypted data"
#    lookup_key: eyaml_lookup_key
#    options:
#      pkcs7_private_key: /path/to/your/private_key.pkcs7.pem
#      pkcs7_public_key:  /path/to/your/public_key.pkcs7.pem
#    path: "common.eyaml"
  - name: "Common data"
    path: "common.yaml"

hieradata/common.yaml

mymodule::software_dir: /some/dir

Run your puppet apply:

puppet apply --confdir . main.pp
puppet apply --confdir . -e 'notify { "software_dir is ${lookup('mymodule::software_dir')}": }'
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-01-25 04:02:54 -0500

Seen: 384 times

Last updated: Jan 25