安装工头时,木偶上的hiera没有价值

时间:2015-03-27 22:44:18

标签: puppet hiera theforeman

如果尝试从模块中获取数据,请使用calling_class,数据不会出现在puppet清单中,如果将变量放到common或osfamily yaml文件中,则可以从manifets中获取。 我的环境: Puppet Master 3.7.4 + Foreman 1.7 + Hiera 1.3.4 Hiera配置:

    ---
: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: '/etc/puppet/hiera'

/etc/puppet/hiera/production/profile/common.yaml

profile::common::directory_hierarchy:
  - "C:\\SiteName"
  - "C:\\SiteName\\Config"
profile::common::system: "common"

在个人资料模块清单 /etc/puppet/environments/production/modules/profile/manifests/common.pp

class profile::common (
      $directory_hierarchy      =undef,
      $system                   =undef
  )
{
  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

更有趣的是,如果在没有领班的情况下部署相同的代码,它将会起作用。 也许我错过了一些配置或插件?

1 个答案:

答案 0 :(得分:0)

您需要一个环境(示例中为production)文件夹结构,如下所示:

/etc/puppet/hiera/environments/production/node/%{::fqdn}.yaml
/etc/puppet/hiera/environments/production/profile/%{calling_class}.yaml
/etc/puppet/hiera/environments/production/production/*.yaml
/etc/puppet/hiera/environments/production/%{::osfamily}.yaml
/etc/puppet/hiera/environments/common.yaml

因此,您粘贴的环境路径也是错误的。

/etc/puppet/hiera/production/profile/common.yaml

旁注

首先看一下,不应该将hieradata与modulepath混合,所以如果可以的话,将模块移出basemodulepath

basemodulepath   = /etc/puppet/environments/common

使用您粘贴的puppet.conf,真正的配置文件模块路径位于以下三个文件夹之一:

/etc/puppet/environments/common/modules/profile
/etc/puppet/modules/profile
/usr/share/puppet/modules/profile
相关问题