Your Vagrant VM is already set up with a suitable Hiera config and the sample data file, in the /etc/puppetlabs/code/environments/pbg
directory. Try it now:
sudo puppet lookup --environment pbg test
--- This is a test
We haven't seen the --environment
switch before, so it's time to briefly introduce Puppet environments. A Puppet environment is a directory containing a Hiera config file, Hiera data, a set of Puppet manifests—in other words, a complete, self-contained Puppet setup. Each environment lives in a named directory under /etc/puppetlabs/code/environments
. The default environment is production
, but you can use any environment you like by giving the --environment
switch to the puppet lookup
command. In the example, we are telling Puppet to use the /etc/puppetlabs/code/environments/pbg
directory.
When you come to add Hiera data to your own Puppet environment, you can use the example hiera.yaml
and data files as a starting point.
If you don't get the result This is a test
, your Hiera setup is not working properly. If you see the warning Config file not found, using Hiera defaults
, check that your Vagrant box has an /etc/puppetlabs/code/environments/pbg
directory. If not, destroy and re-provision your Vagrant box with:
vagrant destroy scripts/start_vagrant.sh
If you see an error like the following, it generally indicates a problem with the Hiera data file syntax:
Error: Evaluation Error: Error while evaluating a Function Call, (/etc/puppetlabs/code/environments/pbg/hiera.yaml): did not find expected key while parsing a block mapping at line 11 column 5 at line 1:8 on node ubuntu-xenial
If this is the case, check the syntax of your Hiera data files.
3.145.97.109