设置环境目录 - 获取无法在"生产"以外的环境中使用XXX找到默认节点或名称

时间:2015-08-07 15:02:05

标签: puppet

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

Puppet Master版本:" 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

这就是我所称的环境"组织" : /etc/puppet/environments/organisation/environment.conf

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

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

/etc/puppet/environments/organisation/manifests/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它就可以了。

当我打印"清单"来自"组织"和"生产"我得到了正确的输出:

[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

我可能在这里遗漏了一些东西,但不能把手指放在上面......

谢谢

1 个答案:

答案 0 :(得分:0)

问题解决了。

主设备上的配置正常。

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

默认环境是:生产。

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

就我而言,我的节点是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