V
V
Viktor Vedmich2015-03-27 23:39:03
Puppet
Viktor Vedmich, 2015-03-27 23:39:03

Getting data from hiera in puppet manifets with foreman installed?

Can't get data from Hiera after installing foreman.
My config: Puppet Master 3.7.4 + Foreman 1.7 + Hiera 1.3.4
Hiera configs:

/etc/puppet/hiera.yaml

---
:backends:
  - yaml
:hierarchy:
  - "%{::environment}/node/%{::fqdn}" #node settings
  - "%{::environment}/profile/%{calling_class}" # profile settings
  - "%{::environment}/%{::environment}" # environment settings
  - "%{::environment}/%{::osfamily}" # osfamily settings
  - common # common settings
:yaml:
# datadir is empty here, so hiera uses its defaults:
# - /var/lib/hiera on *nix
# - %CommonAppData%\PuppetLabs\hiera\var on Windows
# When specifying a datadir, make sure the directory exists.
  :datadir: '/etc/puppet/hiera'

/etc/puppet/hiera/production/profile/common.yaml
profile::common::directory_hierarchy:
  - "C:\\SiteName"
  - "C:\\SiteName\\Config"
profile::common::system: "common"

Hiera data for specific module /etc/puppet/hiera/production/profile/common.yaml :
profile::common::directory_hierarchy:
  - "C:\\SiteName"
  - "C:\\SiteName\\Config"
profile::common::system: "common"

Manifest code /etc/puppet/environments/production/modules/profile/manifests/common.pp
class profile::common (
      $directory_hierarchy      =undef,
      $system                   =undef
  )
{
  # $directory_hierarchy, $system, $share_directory
  notify { "Dir is- $directory_hierarchy my fqdn is $fqdn, system = $system": }
}

Puppet config /etc/puppet/puppet.config
[main]
    logdir = /var/log/puppet
    rundir = /var/run/puppet
    ssldir = $vardir/ssl
    privatekeydir = $ssldir/private_keys { group = service }
    hostprivkey = $privatekeydir/$certname.pem { mode = 640 }
    autosign       = $confdir/autosign.conf { mode = 664 }
    show_diff     = false
    hiera_config = $confdir/hiera.yaml
[agent]
    classfile = $vardir/classes.txt
    localconfig = $vardir/localconfig
    default_schedules = false
    report            = true
    pluginsync        = true
    masterport        = 8140
    environment       = production
    certname          = puppet024.novalocal
    server            = puppet024.novalocal
    listen            = false
    splay             = false
    splaylimit        = 1800
    runinterval       = 1800
    noop              = false
    configtimeout     = 120
    usecacheonfailure = true
[master]
    autosign       = $confdir/autosign.conf { mode = 664 }
    reports        = foreman
    external_nodes = /etc/puppet/node.rb
    node_terminus  = exec
    ca             = true
    ssldir         = /var/lib/puppet/ssl
    certname       = puppet024.novalocal
    strict_variables = false
    environmentpath  = /etc/puppet/environments
    basemodulepath   = /etc/puppet/environments/common:/etc/puppet/modules:/usr/share/puppet/modules
    parser = future

I'm trying to get data from a particular class of the folder in the hier but it doesn't get through. If I make a request like
hiera -c /etc/puppet/hiera.yaml profile::common::directory_hierarchy ::environment=production calling_class=common
I get the data. If the data is registered, for example, in common or osfamily, then they come through the data.
And what is the strangest thing, if you install the master without foreman, then the same code works.
Can someone suggest what could be the problem.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
rionnagel, 2016-11-24
@rionnagel

As far as I understand, foreman needs a certain hier structure, and as an enc tool, it basically replaces hiera. I'm not sure, but it seems that external_nodes and node_terminus should be disabled, leaving foreman only for reports. And how to use it hybridly, I xs - you have to rummage through the code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question