所以我开始尝试使用puppet,我认为我已经正确配置,因为节点将成功连接到主节点:
C:\Windows\system32>puppet agent -t
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for node.mydomain.com
Info: Applying configuration version '1502092203'
Notice: Applied catalog in 0.06 seconds
但是,我已经通过site.pp对master进行了更改,只需添加helloworld模块:
node default {
class { 'helloworld': }
}
使用此代码:
class helloworld {
notify { 'hello, world!':}
}
如果我在master上显式调用site.pp,这是有效的:
puppetmaster3@192:~$ sudo puppet apply
/etc/puppetlabs/code/environments/production/manifests/site.pp
[sudo] password for puppetmaster3:
Notice: Compiled catalog for 192.168.1.23 in environment production in 0.15 seconds
Notice: hello, world!
Notice: /Stage[main]/Helloworld/Notify[hello, world!]/message: defined 'message' as 'hello, world!'
Notice: Applied catalog in 0.05 seconds
然而,当我尝试验证它时,它无法找到,因为它不存在":
puppetmaster3@192:~$ puppet parser validate site.pp
Error: One or more file(s) specified did not exist:
[" site.pp\n"]
Error: Try 'puppet help parser validate' for usage
当我在节点上运行puppet agent时,它并没有按照所示的方式获取helloworld
我还没有编辑puppet.conf或environment.conf来指定清单,因为我已经使用了默认位置,我是否需要在puppet.conf中声明它们?因为如果我尝试打印清单就会出现这个问题:
puppetmaster3@192:~$ puppet config print manifest
no_manifest
答案 0 :(得分:0)
puppet parser validate
命令在响应中可能会更有帮助,但用法是:
$ puppet parser validate --help
USAGE: puppet parser validate [<manifest>] [<manifest> ...]
This action validates Puppet DSL syntax without compiling a catalog or
syncing any resources. If no manifest files are provided, it will
validate the default site manifest.
RETURNS: Nothing, or the first syntax error encountered.
OPTIONS:
--render-as FORMAT - The rendering format to use.
--verbose - Whether to log verbosely.
--debug - Whether to log debug information.
See 'puppet man parser' or 'man puppet-parser' for full help.
所以你可以这样做:
$ bundle exec puppet parser validate /Users/alexharvey/.puppetlabs/etc/code/environments/production/manifests/site.pp
$
(根本没有回应 - 好的。)
或者你可以这样做:
$ puppet parser validate
Notice: No manifest specified. Validating the default manifest /Users/alexharvey/.puppetlabs/etc/code/environments/production/manifests
它刚刚验证了/Users/alexharvey/.puppetlabs/etc/code/environments/production/manifests/site.pp。那是因为我作为非特权用户运行而我的modulepath
是:
$ puppet config print modulepath
/Users/alexharvey/.puppetlabs/etc/code/environments/production/modules:/Users/alexharvey/.puppetlabs/etc/code/modules:/opt/puppetlabs/puppet/modules
由于您没有指定完整路径,并且当前目录中没有此类文件site.pp
,您将收到该失败。