Open davividal opened 8 years ago
FWIW, I'm using Puppet 4
What errors are you getting? I'm doing something similar without any issues
@jlintz I'm getting no errors. It simply does not work. I asked around at #puppet , and it looks like this doesn't work.
can you verify with hiera cmdline that you are able to read the values as expected from hiera?
@jlintz I'm not sure as to how to do that. Can you point me to any doc?
Take a look at https://docs.puppet.com/hiera/3.2/command_line.html
I realized that there are many things that must be configured properly for hiera to work. Still looks like black magic for me. One thing that would help would be to see your hiera.yaml file. Also, did you put
classes:
- nginx
at the top of your common.yaml?
Where is data/common.yaml?
Also try something like this:
hiera -c /etc/puppet/hiera.yaml nginx::nginx_vhosts fqdn=server.domain.com --debug
and post the output.
@davividal Please be more specific with what does and does not work. Is the nginx
class not being included at all, or is it being included with the defaults but not the settings from hiera? Those two problems and significantly different and knowing exactly what is happening would help us a lot.
Also, you could add a gist (gist.github.com) with additional files so your hiera, site manifests, etc. are all in one place. That might be easiest to reference and comment on.
@rnelson0 this is what I'm trying to accomplish: https://github.com/davividal/rcjenkins . On my node I'm simply running puppet agent -t -v. I'm sure that hiera is working because my modules' vars are being properly assigned.
I tried @ubellavance suggestion on https://github.com/davividal/rcjenkins/blob/master/data/common.yaml, without success.
Please let me know if I wasn't clear enough.
Also:
# hiera -c /etc/puppetlabs/puppet/hiera.yaml nginx::nginx_vhosts fqdn=ip-192-168-1-156.sa-east-1.compute.internal environment=stage --debug
DEBUG: 2016-09-28 17:22:54 -0300: Hiera YAML backend starting
DEBUG: 2016-09-28 17:22:54 -0300: Looking up nginx::nginx_vhosts in YAML backend
DEBUG: 2016-09-28 17:22:54 -0300: Looking for data source common
nil
Can we see the contents of /etc/puppetlabs/puppet/hiera.yaml
? And, if possible, where you define the nginx_vhosts configs for this host. You could try removing the environment in your command.
@ubellavance : nginx::nginx_vhosts
:
https://github.com/davividal/rcjenkins/blob/master/data/common.yaml
/etc/puppetlabs/puppet/hiera.yaml
:
---
:backends:
- yaml
:hierarchy:
- "nodes/%{::trusted.certname}"
- common
:yaml:
# datadir is empty here, so hiera uses its defaults:
# - /etc/puppetlabs/code/environments/%{environment}/hieradata on *nix
# - %CommonAppData%\PuppetLabs\code\environments\%{environment}\hieradata on Windows
# When specifying a datadir, make sure the directory exists.
:datadir:
It is different from what I can see in your git repo... Have you tried setting the datadir value? Not sure about this one but the rest looks OK. Have you tried adding this to your common.yaml:
classes:
- nginx
And if you've changed your hiera config, it may be necessary to restart your puppet master.
It is different from the hiera.yaml from the git repo because that is the module's hiera.yaml. The one I posted is the hiera from my puppet master.
I've tried adding classes: [nginx]
without success.
I suggested
classes:
- nginx
Not
classes: [nginx]
but I don't know if there is a real difference. Have you tried to make anything else work with hiera? Maybe try the ntp module, which is used in the puppetlabs hiera doc as an example. Did you restart your puppet master?
@ubellavance there is no difference. :) And, in fact, I tried exactly what you suggested, I was just lazy to write it all. Since I was only dealing with modules, I didn't restart my puppet master.
Ok sorry but that's about as far as I can go with my little puppet/hiera knowledge. You may want to try a puppetlabs module like ntp, try to make it work with hiera and post on the puppet group for help if it doesn't work.
FWIW, the nginx::nginx_upstreams
should work. nginx::nginx_vhosts
is probably ignored because the parameter is actually called $nginx_servers
, so you'll need the Hiera key nginx::nginx_servers
.
For debugging:
notify { "debug": message => hiera("nginx::nginx_servers")
next to your include ::nginx
. (Prefer include
over class { '::nginx': }
in general.)notify { "debug2": message => $nginx_servers }
in the body of the nginx
class.Those should give you an indication whether the values are being loaded and used okay.
@ffrank: It's only nginx_servers
if he's using current or recent git version. The big vhost => server rename hasn't been released yet.
ðŸ˜
Well apart from that mixup, I do at least stand by my recommendations, minus the re-rename of the parameter 😅
I'm writing a custom module to get jenkins up and running. Jenkins is fine, but I'm trying to setup nginx using hiera. Here is my
data/common.yaml
:My
metadata.json
:Should I put anything other than
class { 'nginx': }
on my init.pp? EDIT: I also tried bothinclude nginx
andinclude ::nginx
, without success.