我对 devops/ci/cd 很陌生,所以请耐心等待。
目前,我正在为 docker 图像验证设置一个 puppet manifest 配置。让我尝试布局它:
我有一个具有以下配置的 puppet master 服务器:
- 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:服务器错误:评估错误:评估函数调用时出错,找不到类 ::docker 用于 ip-123-123-123-123.us-east- 2.compute.internal(文件:/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
除了这条消息,它仍然向我返回那些警告,但列表要大得多。但是,我认为目前这不是问题。
puppet 中的错误 500 意味着编写错误的代码,您能否分享整个配置(init.pp),我可以从那里告诉您。
更多信息可在此处获得:https ://forge.puppet.com/modules/puppetlabs/docker