我对 devops/ci/cd 还很陌生,所以请耐心等待。
目前,我正在为 docker 镜像验证设置一个 puppet 清单配置。让我尝试布局一下:
我有一个 Puppet 主服务器,其配置如下:
- Puppetmaster 版本:5.5.10-4ubuntu3
- 两台服务器都是 Linux 20.04
- 全部托管在 AWS 上
/etc/puppet/code/environments/production/manifests/site.pp
node default {
include 'docker'
docker::image { 'jorgemauriciodev/ubuntu-dockerfile-dev-v1': }
}
每次我在 .pp 中尝试新的验证命令时,我都会使用以下命令重新启动 Puppet Master 服务器:sudo systemctl restart puppet-master
我在我的两台服务器(代理服务器和主服务器)上都安装了一个名为 garethr-docker 的模块。
在从属/代理服务器上,我有此镜像 docker 镜像并正在运行:jorgemauriciodev/ubuntu-dockerfile-dev-v1 第一步,我只想检查该镜像是否存在于我的从属服务器中。稍后,我将弄清楚以确保它正在运行或使用 Dockerfile 构建。
在从属/代理服务器上,我运行:sudo puppet agent –test
我收到以下错误消息:
错误:无法从远程服务器检索目录:服务器上的错误 500:服务器错误:评估错误:评估函数调用时出错,找不到 ip-123-123-123-123.us-east-2.compute.internal 的类 ::docker (文件:/etc/puppet/code/environments/production/manifests/site.pp,行:2,列:5)在节点 ip-123-123-123-123.us-east-2.compute.internal 上警告:未在失败的目录上使用缓存错误:无法检索目录;跳过运行
有谁知道我的 Puppet 清单文件出了什么问题?
编辑1:
我按照建议做了一些更改。现在,我的文件有一个不同的名称,并且更改了内容:/etc/puppet/code/environments/production/manifests/init.pp
include 'docker'
class { 'docker':
version => 'latest',
}
docker::image { 'jorgemauriciodev/ubuntu-dockerfile-dev-v1': }
仍然返回相同的错误消息。
以下是完整信息:
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:315: warning: deprecated Object#=~ is called on Puppet::Transaction::Report; it always returns nil
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:315: warning: deprecated Object#=~ is called on Puppet::Transaction::Report; it always returns nil
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:315: warning: deprecated Object#=~ is called on Puppet::Transaction::Report; it always returns nil
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/indirector/request.rb:272: warning: URI.unescape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
Info: Retrieving plugin
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:315: warning: deprecated Object#=~ is called on Puppet::Transaction::Report; it always returns nil
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/indirector/request.rb:272: warning: URI.unescape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
Info: Retrieving locales
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:315: warning: deprecated Object#=~ is called on Puppet::Transaction::Report; it always returns nil
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/indirector/request.rb:272: warning: URI.unescape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, Could not find class ::docker for ip-172-31-21-116.us-east-2.compute.internal (file: /etc/puppet/code/environments/production/manifests/init.pp, line: 1, column: 1) on node ip-172-31-21-116.us-east-2.compute.internal
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
/usr/lib/ruby/vendor_ruby/puppet/file_system/uniquefile.rb:126: warning: $SAFE will become a normal global variable in Ruby 3.0
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/file_system/uniquefile.rb:126: warning: $SAFE will become a normal global variable in Ruby 3.0
编辑2:
我使用以下命令在主服务器和从属/代理服务器上安装了更多模块:
sudo puppet module install puppetlabs-docker --version 4.1.2
它仍然返回错误消息,但现在似乎是一个不同的消息。所以,现在可能是语法问题。
这是该消息的重要部分。
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Duplicate declaration: Class[Docker] is already declared; cannot redeclare (file: /etc/puppet/code/environments/production/manifests/init.pp, line: 3) (file: /etc/puppet/code/environments/production/manifests/init.pp, line: 3, column: 1) on node ip-123-123-123-123.us-east-2.compute.internal
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
除了这条消息之外,它还会向我返回那些警告,但列表要长得多。不过,我认为这目前不是一个值得担心的问题。
答案1
puppet 中的错误 500 意味着代码编写不正确,您能否分享整个配置(init.pp)以便我可以从那里告诉您。
class { 'docker':
version => 'latest',
}
docker::image { 'jorgemauriciodev/ubuntu-dockerfile-dev-v1': }
更多信息请点击这里:https://forge.puppet.com/modules/puppetlabs/docker