puppet module environment from hiera

41 views
Skip to first unread message

Matthew Feinberg

unread,
Apr 2, 2014, 9:45:27 AM4/2/14
to example42-pu...@googlegroups.com
Hello

I have been attempting to set all my clients environments from a single yaml file rather than having a single file for each server.

I want to modify the puppet.conf.erb file to use a hiera lookup to get the enviornment from the env.yaml file  for that $::clientcert . 

Is this possible and can someone point me in the right direction on how to do this? I have tried 100 different options from google searches and nothing works. 

For example I have env.yaml

---
  - environment: testing
  - environment: unstable
  - environment: stable

My hiera,yaml looks like

---
:backends:
  - yaml
:hierarchy:
  - env
  - environment/%{environment}
  - operatingsystem/%{operatingsystem}
  - node/%{fqdn}
  - common

:merge_behavior: deeper

:logger: puppet

:yaml:
  :datadir: /etc/puppet/hieradata

Alessandro Franceschi

unread,
Apr 4, 2014, 7:08:57 PM4/4/14
to example42-pu...@googlegroups.com
Not sure to have understood your question, which actually can probably find wider answers on puppet-users.

Anyway, just few notes, even if they might not be related to your case:

- In :yaml:  :datadir:
you can use environments and any top scope variables, for example:
 :datadir: /etc/puppet/hieradata/%{environment}

- In Puppet.conf is still not possible to have different hieradtaa for different environemnts.

- Puppet's environment internal variable is not necessarily related to your nodes' operational environment, for which, for example I generally use a fact or top scope variable called $end, which I often use in hiera's hierarchies

- You can you variables defined in Hiera on other hiera yaml files. For example:
wordpress::database_server: "%{hiera('instances::mysql::public_hostname')}" ( Check http://docs.puppetlabs.com/hiera/1/variables.html for details).

Hope some of these info might give you useful hints.

al


Reply all
Reply to author
Forward
0 new messages