Closed sandymcp closed 6 years ago
I stepped through in the debugger, it looks like the yaml backend datadir value is set to a fixed value "/home/en10029/control-repo/.onceover/etc/puppetlabs/code/environments/production/"
irrespective of the value in the hiera.yaml, which is sort of sensible as it's an absolute path within the onceover setup. Unfortunately it's not the value that is the puppet default, which expects the stuff to be in .../production/hierdata. Will the onceover run copy hierdata from the spec directory if it's at a particular location?
Here's the snippet where it is set:
62 hiera_config.each do |setting,value| 63 if value.is_a?(Hash) 64 if value.has_key?(:datadir) 65 hiera_config[setting][:datadir] = "#{@repo.tempdir}/#{@repo.environmentpath}/production/#{value[:datadir]}" 66 end 67 end 68 end 69 File.write("#{@repo.tempdir}/#{@repo.environmentpath}/production/hiera.yaml",hiera_config.to_yaml)
Dropping my common.yaml file at .onceover/etc/puppetlabs/code/environments/production/common.yaml
allows me to move ahead. I'll submit a merge request
@sandymcp The spec/hiera.yaml
file needs to have a datadir that is relative to the root of the controlrepo i.e. just hieradata
. Onceover won't move anything around though.
Ok so I dug around a bit more.
If I leave out the datadir altogether, I would expect the file in
.onceover/etc/puppetlabs/code/environments/production/hieradata/common.yaml
to be used as the puppet documentation says that is the default. However it tries to look in
/etc/puppetlabs/code/environments/rp_env/hieradata
If I put in the datadir: value but leave it empty, I would also expect the
.onceover/etc/puppetlabs/code/environments/production/hieradata/common.yaml
to be used as puppet looks there, but the value set by onceover is
/home/en10029/control-repo/.onceover/etc/puppetlabs/code/environments/production/
The documentation says copy the hiera.yaml from the puppet master. So I would expect it to work with the hiera.yaml from the server as-is, adding hierdata explicitly is not a big deal,but it is not in the documentation and it is not the default behaviour of puppet. I can make a change and put it up for review if you want.
Just to confirm, have you set the datadir of the hiera.yaml you are using for testing to be relative to the root of the controlrepo? It likely won't work directly from the Puppet master (depending on how you have set it up. The datadir will need to be modified as /etc/puppetlabs/code/environments/STRY0011377/hieradata
likely isn't the correct place when testing on your local machine
In the README you say the datadir should be relative to the controlrepo root, which it is: it's at the default puppet location. What you don't say is that this value must be explicitly set to hieradata even when using the puppet default. That's what tripped me up. IMHO onceover should obey the puppet default setting when datadir is not set as I bet 99% of users use the default.
But the thing is the default setting isn't relative, it's /etc/puppetlabs/code/hieradata
at least that's what this says. So if it obeyed the default it would end up looking the that absolute path, which is almost definitely not right given you are likely running this in your own laptop. Maybe an error message would be better, error out of the path is not relative?
I think a statement in the README like "if your puppet master hiera.yaml does not set the datadir, because you are using the puppet default, you will need to set it explicitly to hieradata" or similar would be fine and yes an error message would be nice.
hi,
i did set the datadir to hieradata, which is located inside the controlrepo.
https://gist.github.com/x4FF3/fe6bf559f69b4c5f2f33265251c45f14
but on onceover run spec
it cannot lookup any key.
If I run
hiera --debug -c .onceover/spec/hiera.yaml drdc_base
I can find the drdc_base, but if I run onceoveronceover run spec -d
My tests fail withrole::icinga_server using fact set RHEL-7-3 should compile into a catalogue without dependency cycles Failure/Error: it { should compile } error during compilation: Evaluation Error: Error while evaluating a Function Call, Could not find data item drdc_base in any Hiera data file and no default supplied at /home/en10029/control-repo/.onceover/etc/puppetlabs/code/environments/production/site/app/manifests/init.pp:17:15 on node lsv20222.linux.internalcorp.net
Puppet runs are also fine
Uploaded the YAML files as txt files to keep github happy
common.txt hiera.txt onceover.txt