Matthias Viehweger
2014-Jul-23 17:01 UTC
[Puppet Users] Using hiera-data for a specific node
Hi list! I have a problem integrating puppet and hiera. Our puppet-master and all nodes are running puppet 3.6.2. On the master, hiera version 1.3.4 is installed. I want to use some hiera-data in a class depending on the node. To be less abstract, I have this class: class memcached::server{ $cap = hiera('memcached.cap', 64) # package and service omitted here if is_integer($cap) { file { '/etc/memcached.conf': ensure => present, content => template('memcached/memcached.conf.erb'), notify => Service['memcached']; } } else { fail("memory \$cap should be an integer") } } In a future refactoring, I may promote $cap to be a class-parameter and also use the validation from the stdlib. But first, I want to get 'memcached.cap' from a node-specific file. Puppet is configured with "hiera_config = /etc/puppet/hiera.yaml". The file /etc/puppet/hiera.yaml is as follows: --- :backends: yaml :yaml: :datadir: /var/lib/hiera :hierarchy: - %{clientcert} - common :logger: console This is - from the docs - the internal default with just one hierarchy added. I do not have the value "memcached.cap" in the /var/lib/hiera/common.yaml I do have a file /var/lib/hiera/shop-01.hoster.de which contains memcached.cap: 256 Using this configs manually via the CLI, I get the expected result: $ sudo hiera memcached.cap -d -c /etc/puppet/hiera.yaml -y /var/lib/puppet/yaml/facts/shop-01.hoster.de.yaml DEBUG: Wed Jul 23 18:49:39 +0200 2014: Hiera YAML backend starting DEBUG: Wed Jul 23 18:49:39 +0200 2014: Looking up memcached.cap in YAML backend DEBUG: Wed Jul 23 18:49:39 +0200 2014: Looking for data source shop-01.hoster.de DEBUG: Wed Jul 23 18:49:39 +0200 2014: Found memcached.cap in shop-01.hoster.de 256 So far, everything is nice. BTW, when I change the %{clientcert} to %{::clientcert} is does work through the CLI anymore. I cannot get the same data through puppet. What am I doing wrong? Where - apart from the source-code - can I look for information how that lookup works? Thanks, Matthias Viehweger -- 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+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/9933888a-1607-4473-87f2-e47439df844a%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.