Ugo,

In your last example you used 'agen1' instead of 'agent1'. Maybe it's just
a typo? Those are the best problems :) I also don't see where the 400 error
comes from, can you capture that somewhere?

An alternative solution - or maybe complementary - is to change line 11 to
say `hiera_include('classes', [])`, or add a default class that notifies
"Can't find a class!" This way, all runs complete, even if they don't
manage the device properly, which ensures that facts are at least collected.

I also recommend upgrading to the latest 3.x version now, and 4.x as soon
as you can, as SO MANY hiera bugs were fixed in 3.7/3.8 and then 4.3/4.4
that it's very likely that any bug you run into is already fixed by moving
past 3.6.2.


Rob Nelson
[email protected]

On Tue, Apr 19, 2016 at 1:36 PM, Ugo Bellavance <[email protected]> wrote:

> Hi,
>
> I'm currently testing hiera and I can't make it work.  I get this
> error: Error 400 on SERVER: Could not find data item classes in any Hiera
> data file and no default supplied at /etc/puppet/manifests/site.pp:11 on
> node. I'm trying to do something like this:
> https://docs.puppet.com/hiera/3.0/complete_example.html (puppetlabs ntp
> module).
>
> Client: puppet 3.6.2
>
> On the master:
>
> puppet 3.6.2
>
> # puppet config print | grep hiera_
> hiera_config = /etc/puppet/hiera.yaml
>
> Contents of /etc/puppet/hiera.yaml
> ---
> :backends:
> #  - regex
>   - yaml
> :yaml:
>   :datadir: /var/lib/hiera
> #:regex:
> #  :datadir: /var/lib/hiera
> :hierarchy:
>   - "host/%{fqdn}"
>   - "domain/%{domain}"
>   - "env/%{::environment}"
>   - "os/%{operatingsystem}"
>   - "osfamily/%{osfamily}"
>   - "virtual/%{::virtual}"
>   - common
>
> Contents of /etc/puppet/manifests/site.pp
>
> import "nodes/*"
> import "os/*"
> import "packages/*"
> import "users/*"
> import "service-types/*"
>
> # Enable hiera
> hiera_include('classes')
>
> #filebitbucket { main: server => puppet }
> #File { backup => main }
>
> # The filebucket option allows for file backups to the server
> filebucket { main: server => 'puppet' }
>
> # Set global defaults - including backing up all files to the main
> filebucket and adds a global path
> File { backup => main }
>
> Contents of the hiera file for this host:
>
> # cat /var/lib/hiera/host/agent1.example.com.yaml
> ---
> classes: ntp
> ntp::restrict:
>   -
> ntp::autoupdate: false
> ntp::enable: true
> ntp::servers:
>   - 0.ca.pool.ntp.org
>   - 1.ca.pool.ntp.org
>   - 2.ca.pool.ntp.org
>   - 3.ca.pool.ntp.org
>
> Contents of the common file:
>
> # cat /var/lib/hiera/common.yaml
> ---
> ntp::autoupdate: true
> ntp::enable: true
> ntp::servers:
>   - ntp1.example
>   - ntp2.example.com
>
>
> When debugging on the master:
>
> # puppet master --debug --compile agent1.example.com | grep hiera | grep
> -v Cannot | grep -v Looking
> Warning: The use of 'import' is deprecated at
> /etc/puppet/manifests/site.pp:4. See
> http://links.puppetlabs.com/puppet-import-deprecation
>    (at grammar.ra:610:in `block in _reduce_190')
> Debug: hiera(): Hiera YAML backend starting
> Debug: hiera(): Found classes in host/agent1.example.com
> Debug: hiera(): Found ntp::autoupdate in host/agent1.example.com
> Debug: hiera(): Found ntp::restrict in host/agent1.example.com
> Debug: hiera(): Found ntp::servers in host/agent1.example.com
> Warning: Variable access via 'search_domain' is deprecated. Use
> '@search_domain' instead.
> template[/etc/puppet/modules/resolv/templates/resolv.conf.erb]:5
>    (at /etc/puppet/modules/resolv/templates/resolv.conf.erb:5:in `block in
> result')
> Warning: Variable access via 'dns_servers' is deprecated. Use
> '@dns_servers' instead.
> template[/etc/puppet/modules/resolv/templates/resolv.conf.erb]:7
>    (at /etc/puppet/modules/resolv/templates/resolv.conf.erb:7:in `block in
> result')
>
> (I will eventually fix the warnings, I doubt they cause my hiera problem)
>
> hiera debugging on the master:
>
> # hiera ntp::servers clientcert=agen1.example.com --debug
> DEBUG: 2016-04-19 13:26:43 -0400: Hiera YAML backend starting
> DEBUG: 2016-04-19 13:26:43 -0400: Looking up ntp::servers in YAML backend
> DEBUG: 2016-04-19 13:26:43 -0400: Looking for data source common
> DEBUG: 2016-04-19 13:26:43 -0400: Found ntp::servers in common
> ["ntp1.example.com", "ntp2.example.com"]
>
> (should not find the information in common, should use the information in
> /var/lib/hiera/host/agent1.example.com.yaml
>
> Any help would be greatly appreciated.
>
> Thanks,
>
> Ugo
>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/11548aff-32cd-4cdb-9886-4cfc079cd5fa%40googlegroups.com
> <https://groups.google.com/d/msgid/puppet-users/11548aff-32cd-4cdb-9886-4cfc079cd5fa%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAC76iT9qMh7KNgq6fTX1NsVPdvR0A4vmFdfm%3DJHZJswPGdvwWQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to