2e232 发表于 2014-4-21 09:43:43

puppet错误解决--Could not evaluate: Could not retrieve information from e...

puppet错误解决--Could not evaluate: Could not retrieve information from environment production source
故障现象:
# puppet agent -t
info: Retrieving plugin
info: Loading facts in /var/lib/puppet/lib/facter/fact_apply.rb
info: Caching catalog for puppet_linux57poc.gov.shanghaigm.com
info: Applying configuration version '1385819456'
err: /Stage/Puppet_linux57poc::Test/File: Could not evaluate: Could not retrieve information from environment production source(s) puppet:///modules/puppet_linux57poc/etc/test.txt at /etc/puppet/environments/production/agents/modules/puppet_linux57poc/manifests/init.pp:25
notice: /Stage/Mcollective::Facter/File/content:
--- /etc/mcollective/facts.yaml    2013-11-30 21:50:18.000000000 +0800
+++ /tmp/puppet-file20131130-3983-m8yrvi-0    2013-11-30 21:50:58.000000000 +0800
解决方法:
这个问题一般出现在puppetmaster上,有两种可能,一种是fileserver端文件不存在,一种是source路径写的不正确,正确写入如下 文件目录列表:
# tree puppet_linux57poc/
puppet_linux57poc/
├── files
│   └── etc
│       └── test.txt
├── manifests
│   └── init.pp
└── templates
    ├── facts.txt.erb
    └── motd.erb

4 directories, 4 files
pp文件内容:
# cat puppet_linux57poc/manifests/init.pp
class puppet_linux57poc{
include puppet_linux57poc::motd,puppet_linux57poc::facts,puppet_linux57poc::test
}
class puppet_linux57poc::motd{
package{ setup:
    ensure => present,
}
file{ "/etc/motd":
    owner   => "root",
    group   => "root",
    mode    => 0400,
    content => template("puppet_linux57poc/motd.erb"),
    backup=> 'main',
    require => Package["setup"],
}
}
class puppet_linux57poc::test{
file{ "/tmp/test.txt":
    owner   => "root",
    group   => "root",
    mode    => 0400,
    source=> "puppet:///modules/puppet_linux57poc/etc/test.txt", #正确写法
    backup=> 'main',
}
}
class puppet_linux57poc::facts{
file{ "/etc/mcollective/facts.txt":
    owner   => "root",
    group   => "root",
    mode    => 0400,
    content => template("puppet_linux57poc/facts.txt.erb"),
    backup=> 'main',
}
}
测试:
# puppet agent -t
info: Retrieving plugin
info: Loading facts in /var/lib/puppet/lib/facter/fact_apply.rb
info: Caching catalog for puppet_linux57poc.gov.shanghaigm.com
info: Applying configuration version '1385819456'
notice: /Stage/Puppet_linux57poc::Test/File/ensure: defined content as '{md5}18dc28902480f14de4c115d5e5601de8'
notice: /Stage/Mcollective::Facter/File/content:
--- /etc/mcollective/facts.yaml    2013-11-30 21:50:58.000000000 +0800
+++ /tmp/puppet-file20131130-4340-rjtmkk-0    2013-11-30 21:58:54.000000000 +0800
@@ -7,15 +7,15 @@
   facterversion: "1.7.3"
   netmask: "255.255.255.0"
   puppetversion: "2.7.23"
-environment: production

页: [1]
查看完整版本: puppet错误解决--Could not evaluate: Could not retrieve information from e...