设置环境目录 - 无法在 "production" 以外的环境中找到默认节点或名称为 XXX

Setting up environment directory - Getting Could not find default node or by name with XXX on environment other than "production"

我目前正在尝试配置一些目录环境来管理不同的客户端

傀儡大师版本:"puppet-server-3.8.1-1" (centos 6)

这是木偶大师给我的树 /etc/puppet :

    ├── organisation
│   ├── environment.conf
│   ├── manifests
│   │   ├── accounts.pp
│   │   ├── lab_accounts.pp
│   │   ├── lab_nodes.pp
│   │   └── nodes.pp
│   └── modules
│       ├── account
│       │   ├── files
│       │   ├── lib
│       │   ├── spec
│       │   │   └── classes
│       │   └── templates
│       └── dns
│           ├── manifests
│           │   └── init.pp
│           └── templates
│               ├── resolv.conf.erb
│               └── resolv.conf.fqdn.erb
├── production
│   ├── environment.conf
│   ├── manifests
│   │   ├── accounts.pp
│   │   ├── lab_accounts.pp
│   │   └── lab_nodes.pp
│   └── modules
│       ├── account
│       │   ├── CHANGELOG
│       │   ├── files
│       │   ├── lib
│       │   ├── LICENSE
│       │   ├── manifests
│       │   │   ├── init.pp
│       │   │   └── site.pp
│       │   ├── metadata.json
│       │   ├── Modulefile
│       │   ├── Rakefile
│       │   ├── README.mkd
│       │   ├── spec
│       │   │   ├── classes
│       │   │   ├── defines
│       │   │   │   └── account_spec.rb
│       │   │   └── spec_helper.rb
│       │   └── templates
│       ├── dns
│       │   ├── manifests
│       │   │   └── init.pp
│       │   └── templates
│       │       ├── resolv.conf.erb
│       │       └── resolv.conf.fqdn.erb
│       └── sshkeys
│           └── manifests
│               └── init.pp
└── README.md

现在配置文件: /etc/puppet.conf

[main]
    logdir = /var/log/puppet
    rundir = /var/run/puppet
    ssldir = $vardir/ssl
    dns_alt_names = centos66a.local.lab,centos66a,puppet,puppetmaster
[master]
    environmentpath = $confdir/environments
    basemodulepath = $confdir/modules:/opt/puppet/share/puppet/modules
[agent]
    classfile = $vardir/classes.txt
    localconfig = $vardir/localconfig
    server = puppet

这里是我调用的环境 "organisation" : /etc/puppet/环境/组织/environment.conf

modulepath = /etc/puppet/environments/organisation/modules
environment_timeout = 5s

现在我在 "nodes.pp" 中声明我的节点:

/etc/puppet/环境/组织/清单/nodes.pp

node 'centos66a.local.lab' {
  include dns
}

node 'gcacnt02.local.lab' {
  include dns
}

这是我尝试将我的节点同步到主节点时的输出:

gcacnt02:~ # hostname
gcacnt02.local.lab
gcacnt02:~ # puppet agent -t
Info: Creating a new SSL key for gcacnt02.local.lab
Info: csr_attributes file loading from /etc/puppet/csr_attributes.yaml
Info: Creating a new SSL certificate request for gcacnt02.local.lab
Info: Certificate Request fingerprint (SHA256): 49:73:11:78:99:6F:50:BD:6B:2F:5D:B9:92:7C:6F:A9:63:52:92:53:DB:B8:A1:AE:86:21:AF:36:BE:B0:94:DB
Info: Caching certificate for gcacnt02.local.lab
Info: Caching certificate for gcacnt02.local.lab
Info: Retrieving pluginfacts
Info: Retrieving plugin
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not find default node or by name with 'gcacnt02.local.lab, gcacnt02.local, gcacnt02' on node gcacnt02.local.lab
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

如果我将 /etc/puppet/environments/organisation/manifests/nodes.pp 移动到 /etc/puppet/environments/production/manifests/nodes.pp 它工作得很好。

当我从 "organisation" 和 "production" 打印 "manifest" 时,我得到了正确的输出:

[root@centos66a environments]# puppet config print manifest --section master --environment production
/etc/puppet/environments/production/manifests
[root@centos66a environments]# puppet config print manifest --section master --environment organisation
/etc/puppet/environments/organisation/manifests

我可能在这里遗漏了一些东西,但无法确定...

谢谢

问题已解决。

master 上的配置正常。

由于Puppet在"environmentpath"变量设置的环境目录中扫描目录,我以为master会在每个环境的setup中自动回复节点。这是错误的。

默认环境是:生产。

如果设置任何其他环境,则必须将每个 Puppet 代理节点配置为查询特定环境

在我的例子中,我的节点是 gcacnt02.local.lab。所以要解决这个问题,我必须在 /etc/puppet/puppet.conf

中添加以下变量
[main]
    logdir = /var/log/puppet
    rundir = /var/run/puppet
    ssldir = $vardir/ssl

[agent]
    classfile = $vardir/classes.txt
    localconfig = $vardir/localconfig    
    environment = lan