Hello,


Control Repo and R10K work fine with Puppet OSS and is the recommended 
architecture for using multiple environments with Puppet.



PE Code Manager is indeed only for PE, but in most cases is just a fancy name 
for R10K.



-----Original message-----
From: solarflow 99 <solarflo...@gmail.com>
Sent: Thursday 11th June 2020 19:45
To: Puppet Users <puppet-users@googlegroups.com>
Subject: Re: [Puppet Users] hiera with environments

hi, thanks for the reply.  This is all for PE, but i'm using puppet 6 OSS..

It used to work this way in 5.5 too, so I don't understand why its not seeing 
hiera in the preprod environment.  I could always do this:

- make changed in preprod, and git commit there
- cd to prod, then:
- git remote update, 
- git merge --ff-only preprod/master
- cd back to preprod, then
- git pull



On Thursday, June 11, 2020 at 1:54:13 AM UTC-7, Martin Alfke wrote:
Hi,

You should change to using a control-repo and adopt your codebase.
https://puppet.com/docs/pe/2018.1/control_repo.html
https://github.com/puppetlabs/best-practices/blob/master/puppet-modules-and-the-control-repo.md

We recommend (assuming you use a git based control-repo and r10k or PE code 
manager for deployment):

1. Copy your global hiera.yaml file (etc/puppetlabs/puppet/hiera.yaml) to each 
of your environments.
2. Remove global hiera.yaml file
3. Just use data or hieradata as datadir. Not the complete path.
4. Use relative paths in your environment.conf file
5. Instead of having different hieradata per environment we recommend to add an 
environment hierarchy.

You can also separate your hieradata from control-repo and make them an 
individual git repo.
In this case you can add hieradata as a module to your puppet file and change 
the path in hiera.yaml file.

You can find examples on how to achieve this in our Puppet Infrastructure 
Construction Kit (https://github.com/example42/psick)
https://github.com/example42/psick/blob/production/Puppetfile#L7
Here we deploy the same branch name - when existing on hieradata repo - and 
fall back to master branch.

Hth,
Martin


On 9. Jun 2020, at 07:46, solarflow 99 <solar...@gmail.com> wrote:

I have this strange problem where I just upgraded from puppetserver 5.5 to 6, 
and now the 2nd environment doesn't see hiera values, but the production 
environment does.  I wonder if top level lookups don't work anymore?  Here's 
how I have it configured:


Here's my directory layout:

code
└── environments
    ├── preprod
    │   ├── environment.conf
    │   ├── gitclone
    │   │   └── production
    │   │       ├── hieradata
    │   │       │   ├── common.yaml
    │   │       │   └── nodes
    │   │       ├── manifests
    │   │       │   ├── nodes.pp
    │   │       │   └── site.pp
    │   │       └── modules
    └── production
        ├── hieradata
        │   ├── common.yaml
        │   └── nodes
        ├── manifests
        │   ├── nodes.pp
        │   └── site.pp
        └── modules






/etc/puppetlabs/puppet:

$ cat hiera.yaml 
---
version: 5
defaults:
  # The default value for "datadir" is "data" under the same directory as the 
hiera.yaml
  # file (this file)
  # When specifying a datadir, make sure the directory exists.
  # See https://puppet.com/docs/puppet/latest/environments_about.html for 
further details on environments.
  # datadir: data
  # data_hash: yaml_data

  datadir: "/etc/puppetlabs/code/environments/%{::environment}/hieradata"
  data_hash: yaml_data


hierarchy:
  - name: "Per-node data (yaml version)"
    path: "nodes/%{::trusted.certname}.yaml"
  - name: "Other YAML hierarchy levels"
    paths:
      - "common.yaml"





/etc/puppetlabs/code/environments/preprod:


$ ls -la
total 4
drwxr-xr-x  3 root root  62 Jun  8 21:44 ./
drwxr-xr-x. 4 root root  39 Jun  8 14:33 ../
-rw-r--r--  1 root root 142 Jun  8 14:38 environment.conf
drwxr-xr-x  3 root root  24 Jun  8 14:36 gitclone/
lrwxrwxrwx  1 root root  29 Jun  8 21:44 hierdata -> 
gitclone/production/hieradata/





$ cat environment.conf 
manifest = $codedir/environments/preprod/gitclone/production/manifests
modulepath = $codedir/environments/preprod/gitclone/production/modules





 
$ cat hierdata/common.yaml 
---
infraserver:             'bigmachine.local'




$ cat site.pp 

$infraserver          = hiera( 'infraserver' )




But the clients don't see it in preprod, failing their puppet runs, and the 
codebase is exactly the same:

Error 500 on SERVER: Server Error: Function lookup() did not find a value for 
the name 'infraserver' on node dev1.local


$ puppet lookup infraserver --environment production --node dev1.local
--- bigmachine.local
 
$ puppet lookup infraserver --environment preprod --node dev1.local



-- 
 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...@googlegroups.com.
 To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/a0655c3e-9b5e-4097-a793-60f3117df82do%40googlegroups.com.



-- 
 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+unsubscr...@googlegroups.com 
<mailto:puppet-users+unsubscr...@googlegroups.com> .
 To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/88343dbe-0818-49b8-85be-bad4ee8e7963o%40googlegroups.com.
 

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/zarafa.5ee32bb9.22f1.343f175707ecc404%40anjie.dontpanic.nl.

Reply via email to