运行 master/agent 时找不到某些 puppet 模块,但可以使用 puppet apply

运行 master/agent 时找不到某些 puppet 模块,但可以使用 puppet apply

我已经在 Ubuntu 12.04 上从 Puppet Labs APT 存储库安装了 puppet 3.1.1。我安装了 Puppet Forge 中的 ploperations-puppet 模块来管理客户端系统上的 puppet 代理配置和软件包安装。我遇到了一些问题,因此我缩减规模以编写自己的模块,但仍然使用 ploperations-puppetlabs_apt 和 stahnma-puppetlabs_yum 模块来管理存储库。

对于以下测试,代理位于主服务器上。

现在有了以下 site.pp

node default {
    class { "puppetlabs_apt":
    }
}

我收到以下错误:

# puppet agent --test
Info: Retrieving plugin
Notice: /File[/var/lib/puppet/lib/puppet]/ensure: removed
Notice: /File[/var/lib/puppet/lib/facter/puppet_path.rb]/ensure: removed
Notice: /File[/var/lib/puppet/lib/facter/util]/ensure: removed
Notice: /File[/var/lib/puppet/lib/facter/certname.rb]/ensure: removed
Notice: /File[/var/lib/puppet/lib/facter/root_home.rb]/ensure: removed
Notice: /File[/var/lib/puppet/lib/facter/puppet_vardir.rb]/ensure: removed
Notice: /File[/var/lib/puppet/lib/facter/pe_version.rb]/ensure: removed
Notice: /File[/var/lib/puppet/lib/facter/concat_basedir.rb]/ensure: removed
Notice: /File[/var/lib/puppet/lib/facter/confenv.rb]/ensure: removed
Notice: /File[/var/lib/puppet/lib/facter/puppet_semantic_version.rb]/ensure: removed
Info: Loading facts in /etc/puppet/modules/puppetlabs_yum/lib/facter/os_maj_version.rb
Info: Loading facts in /var/lib/puppet/lib/facter/os_maj_version.rb
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Puppet::Parser::AST::Resource failed with error ArgumentError: Could not find declared class puppetlabs_apt at /etc/puppet/manifests/site.pp:3 on node mgmt.example.com
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

使用 ricardogarcia-helloworld 和 puppetlabs_yum 模块测试成功。此外,以下测试也puppet apply成功(site.pp 与上面的相同):

# puppet apply /etc/puppet/manifests/site.pp   
WARN: Fri Apr 19 16:43:32 +0000 2013: Not using Hiera::Puppet_logger. It does not report itself to be suitable.
DEBUG: Fri Apr 19 16:43:32 +0000 2013: Hiera YAML backend starting
DEBUG: Fri Apr 19 16:43:32 +0000 2013: Looking up puppetlabs_apt::enable_devel in YAML backend
DEBUG: Fri Apr 19 16:43:32 +0000 2013: Looking for data source mgmt.example.com
DEBUG: Fri Apr 19 16:43:32 +0000 2013: Cannot find datafile /etc/puppet/hieradata/mgmt.example.com.yaml, skipping
DEBUG: Fri Apr 19 16:43:32 +0000 2013: Looking for data source common
DEBUG: Fri Apr 19 16:43:32 +0000 2013: Hiera JSON backend starting
DEBUG: Fri Apr 19 16:43:32 +0000 2013: Looking up puppetlabs_apt::enable_devel in JSON backend
DEBUG: Fri Apr 19 16:43:32 +0000 2013: Looking for data source mgmt.example.com
DEBUG: Fri Apr 19 16:43:32 +0000 2013: Cannot find datafile /etc/puppet/hieradata/mgmt.example.com.json, skipping
DEBUG: Fri Apr 19 16:43:32 +0000 2013: Looking for data source common
DEBUG: Fri Apr 19 16:43:32 +0000 2013: Cannot find datafile /etc/puppet/hieradata/common.json, skipping
Notice: Finished catalog run in 0.16 seconds

最后,调试主机时,运行 Puppet 代理将得到以下输出:

# puppet master --debug --no-daemonize
Debug: Failed to load library 'selinux' for feature 'selinux'
Debug: Using settings: adding file resource 'libdir': 'File[/var/lib/puppet/lib]{:links=>:follow, :ensure=>:directory, :backup=>false, :loglevel=>:debug, :path=>"/var/lib/puppet/lib"}'
Debug: Using settings: adding file resource 'vardir': 'File[/var/lib/puppet]{:links=>:follow, :ensure=>:directory, :backup=>false, :loglevel=>:debug, :path=>"/var/lib/puppet"}'
Debug: Puppet::Type::User::ProviderPw: file pw does not exist
Debug: Puppet::Type::User::ProviderUser_role_add: file roleadd does not exist
Debug: Puppet::Type::User::ProviderDirectoryservice: file /usr/bin/uuidgen does not exist
Debug: Failed to load library 'ldap' for feature 'ldap'
Debug: Puppet::Type::User::ProviderLdap: feature ldap is missing
Debug: Puppet::Type::Group::ProviderPw: file pw does not exist
Debug: Puppet::Type::Group::ProviderDirectoryservice: file /usr/bin/dscl does not exist
Debug: Failed to load library 'ldap' for feature 'ldap'
Debug: Puppet::Type::Group::ProviderLdap: feature ldap is missing
Debug: Using settings: adding file resource 'server_datadir': 'File[/var/lib/puppet/server_data]{:links=>:follow, :group=>"puppet", :ensure=>:directory, :backup=>false, :owner=>"puppet", :mode=>"750", :loglevel=>:debug, :path=>"/var/lib/puppet/server_data"}'
Debug: Using settings: adding file resource 'hostpubkey': 'File[/var/lib/puppet/ssl/public_keys/mgmt.example.com.pem]{:links=>:follow, :ensure=>:file, :backup=>false, :owner=>"puppet", :mode=>"644", :loglevel=>:debug, :path=>"/var/lib/puppet/ssl/public_keys/mgmt.example.com.pem"}'
Debug: Using settings: adding file resource 'rundir': 'File[/var/run/puppet]{:links=>:follow, :ensure=>:directory, :backup=>false, :mode=>"1777", :loglevel=>:debug, :path=>"/var/run/puppet"}'
Debug: Using settings: adding file resource 'manifestdir': 'File[/etc/puppet/manifests]{:links=>:follow, :ensure=>:directory, :backup=>false, :loglevel=>:debug, :path=>"/etc/puppet/manifests"}'
Debug: Using settings: adding file resource 'publickeydir': 'File[/var/lib/puppet/ssl/public_keys]{:links=>:follow, :ensure=>:directory, :backup=>false, :owner=>"puppet", :loglevel=>:debug, :path=>"/var/lib/puppet/ssl/public_keys"}'
Debug: Using settings: adding file resource 'masterhttplog': 'File[/var/log/puppet/masterhttp.log]{:links=>:follow, :group=>"puppet", :ensure=>:file, :backup=>false, :owner=>"puppet", :mode=>"660", :loglevel=>:debug, :path=>"/var/log/puppet/masterhttp.log"}'
Debug: Using settings: adding file resource 'bucketdir': 'File[/var/lib/puppet/bucket]{:links=>:follow, :group=>"puppet", :ensure=>:directory, :backup=>false, :owner=>"puppet", :mode=>"750", :loglevel=>:debug, :path=>"/var/lib/puppet/bucket"}'
Debug: Using settings: adding file resource 'privatedir': 'File[/var/lib/puppet/ssl/private]{:links=>:follow, :ensure=>:directory, :backup=>false, :owner=>"puppet", :mode=>"750", :loglevel=>:debug, :path=>"/var/lib/puppet/ssl/private"}'
Debug: Using settings: adding file resource 'hostcert': 'File[/var/lib/puppet/ssl/certs/mgmt.example.com.pem]{:links=>:follow, :ensure=>:file, :backup=>false, :owner=>"puppet", :mode=>"644", :loglevel=>:debug, :path=>"/var/lib/puppet/ssl/certs/mgmt.example.com.pem"}'
Debug: Using settings: adding file resource 'hiera_config': 'File[/etc/puppet/hiera.yaml]{:links=>:follow, :ensure=>:file, :backup=>false, :loglevel=>:debug, :path=>"/etc/puppet/hiera.yaml"}'
Debug: Using settings: adding file resource 'logdir': 'File[/var/log/puppet]{:links=>:follow, :group=>"puppet", :ensure=>:directory, :backup=>false, :owner=>"puppet", :mode=>"750", :loglevel=>:debug, :path=>"/var/log/puppet"}'
Debug: Using settings: adding file resource 'localcacert': 'File[/var/lib/puppet/ssl/certs/ca.pem]{:links=>:follow, :ensure=>:file, :backup=>false, :owner=>"puppet", :mode=>"644", :loglevel=>:debug, :path=>"/var/lib/puppet/ssl/certs/ca.pem"}'
Debug: Using settings: adding file resource 'fileserverconfig': 'File[/etc/puppet/fileserver.conf]{:links=>:follow, :ensure=>:file, :backup=>false, :loglevel=>:debug, :path=>"/etc/puppet/fileserver.conf"}'
Debug: Using settings: adding file resource 'hostcrl': 'File[/var/lib/puppet/ssl/crl.pem]{:links=>:follow, :ensure=>:file, :backup=>false, :owner=>"puppet", :mode=>"644", :loglevel=>:debug, :path=>"/var/lib/puppet/ssl/crl.pem"}'
Debug: Using settings: adding file resource 'rrddir': 'File[/var/lib/puppet/rrd]{:links=>:follow, :group=>"puppet", :ensure=>:directory, :backup=>false, :owner=>"puppet", :mode=>"750", :loglevel=>:debug, :path=>"/var/lib/puppet/rrd"}'
Debug: Using settings: adding file resource 'manifest': 'File[/etc/puppet/manifests/site.pp]{:links=>:follow, :ensure=>:file, :backup=>false, :loglevel=>:debug, :path=>"/etc/puppet/manifests/site.pp"}'
Debug: Using settings: adding file resource 'certdir': 'File[/var/lib/puppet/ssl/certs]{:links=>:follow, :ensure=>:directory, :backup=>false, :owner=>"puppet", :loglevel=>:debug, :path=>"/var/lib/puppet/ssl/certs"}'
Debug: Using settings: adding file resource 'requestdir': 'File[/var/lib/puppet/ssl/certificate_requests]{:links=>:follow, :ensure=>:directory, :backup=>false, :owner=>"puppet", :loglevel=>:debug, :path=>"/var/lib/puppet/ssl/certificate_requests"}'
Debug: Using settings: adding file resource 'rest_authconfig': 'File[/etc/puppet/auth.conf]{:links=>:follow, :ensure=>:file, :backup=>false, :loglevel=>:debug, :path=>"/etc/puppet/auth.conf"}'
Debug: Using settings: adding file resource 'confdir': 'File[/etc/puppet]{:links=>:follow, :ensure=>:directory, :backup=>false, :loglevel=>:debug, :path=>"/etc/puppet"}'
Debug: Using settings: adding file resource 'yamldir': 'File[/var/lib/puppet/yaml]{:links=>:follow, :group=>"puppet", :ensure=>:directory, :backup=>false, :owner=>"puppet", :mode=>"750", :loglevel=>:debug, :path=>"/var/lib/puppet/yaml"}'
Debug: Using settings: adding file resource 'hostprivkey': 'File[/var/lib/puppet/ssl/private_keys/mgmt.example.com.pem]{:links=>:follow, :ensure=>:file, :backup=>false, :owner=>"puppet", :mode=>"600", :loglevel=>:debug, :path=>"/var/lib/puppet/ssl/private_keys/mgmt.example.com.pem"}'
Debug: Using settings: adding file resource 'reportdir': 'File[/var/lib/puppet/reports]{:links=>:follow, :group=>"puppet", :ensure=>:directory, :backup=>false, :owner=>"puppet", :mode=>"750", :loglevel=>:debug, :path=>"/var/lib/puppet/reports"}'
Debug: Using settings: adding file resource 'statedir': 'File[/var/lib/puppet/state]{:links=>:follow, :ensure=>:directory, :backup=>false, :mode=>"1755", :loglevel=>:debug, :path=>"/var/lib/puppet/state"}'
Debug: Using settings: adding file resource 'ssldir': 'File[/var/lib/puppet/ssl]{:links=>:follow, :ensure=>:directory, :backup=>false, :owner=>"puppet", :mode=>"771", :loglevel=>:debug, :path=>"/var/lib/puppet/ssl"}'
Debug: Using settings: adding file resource 'privatekeydir': 'File[/var/lib/puppet/ssl/private_keys]{:links=>:follow, :ensure=>:directory, :backup=>false, :owner=>"puppet", :mode=>"750", :loglevel=>:debug, :path=>"/var/lib/puppet/ssl/private_keys"}'
Debug: /File[/var/lib/puppet/ssl/certs/ca.pem]: Autorequiring File[/var/lib/puppet/ssl/certs]
Debug: /File[/etc/puppet/auth.conf]: Autorequiring File[/etc/puppet]
Debug: /File[/var/lib/puppet/ssl/certificate_requests]: Autorequiring File[/var/lib/puppet/ssl]
Debug: /File[/var/lib/puppet/ssl]: Autorequiring File[/var/lib/puppet]
Debug: /File[/etc/puppet/manifests]: Autorequiring File[/etc/puppet]
Debug: /File[/var/log/puppet/masterhttp.log]: Autorequiring File[/var/log/puppet]
Debug: /File[/var/lib/puppet/ssl/private]: Autorequiring File[/var/lib/puppet/ssl]
Debug: /File[/var/lib/puppet/ssl/crl.pem]: Autorequiring File[/var/lib/puppet/ssl]
Debug: /File[/var/lib/puppet/ssl/public_keys]: Autorequiring File[/var/lib/puppet/ssl]
Debug: /File[/var/lib/puppet/lib]: Autorequiring File[/var/lib/puppet]
Debug: /File[/var/lib/puppet/ssl/private_keys/mgmt.example.com.pem]: Autorequiring File[/var/lib/puppet/ssl/private_keys]
Debug: /File[/var/lib/puppet/ssl/certs/mgmt.example.com.pem]: Autorequiring File[/var/lib/puppet/ssl/certs]
Debug: /File[/var/lib/puppet/bucket]: Autorequiring File[/var/lib/puppet]
Debug: /File[/var/lib/puppet/server_data]: Autorequiring File[/var/lib/puppet]
Debug: /File[/var/lib/puppet/state]: Autorequiring File[/var/lib/puppet]
Debug: /File[/var/lib/puppet/ssl/certs]: Autorequiring File[/var/lib/puppet/ssl]
Debug: /File[/var/lib/puppet/ssl/public_keys/mgmt.example.com.pem]: Autorequiring File[/var/lib/puppet/ssl/public_keys]
Debug: /File[/var/lib/puppet/yaml]: Autorequiring File[/var/lib/puppet]
Debug: /File[/etc/puppet/fileserver.conf]: Autorequiring File[/etc/puppet]
Debug: /File[/etc/puppet/manifests/site.pp]: Autorequiring File[/etc/puppet/manifests]
Debug: /File[/var/lib/puppet/ssl/private_keys]: Autorequiring File[/var/lib/puppet/ssl]
Debug: /File[/etc/puppet/hiera.yaml]: Autorequiring File[/etc/puppet]
Debug: /File[/var/lib/puppet/reports]: Autorequiring File[/var/lib/puppet]
Debug: /File[/var/lib/puppet/rrd]: Autorequiring File[/var/lib/puppet]
Debug: Finishing transaction 70187171513100
Debug: Using settings: adding file resource 'csrdir': 'File[/var/lib/puppet/ssl/ca/requests]{:links=>:follow, :group=>"puppet", :ensure=>:directory, :backup=>false, :owner=>"puppet", :loglevel=>:debug, :path=>"/var/lib/puppet/ssl/ca/requests"}'
Debug: Using settings: adding file resource 'cacert': 'File[/var/lib/puppet/ssl/ca/ca_crt.pem]{:links=>:follow, :group=>"puppet", :ensure=>:file, :backup=>false, :owner=>"puppet", :mode=>"660", :loglevel=>:debug, :path=>"/var/lib/puppet/ssl/ca/ca_crt.pem"}'
Debug: Using settings: adding file resource 'cacrl': 'File[/var/lib/puppet/ssl/ca/ca_crl.pem]{:links=>:follow, :group=>"puppet", :ensure=>:file, :backup=>false, :owner=>"puppet", :mode=>"664", :loglevel=>:debug, :path=>"/var/lib/puppet/ssl/ca/ca_crl.pem"}'
Debug: Using settings: adding file resource 'signeddir': 'File[/var/lib/puppet/ssl/ca/signed]{:links=>:follow, :group=>"puppet", :ensure=>:directory, :backup=>false, :owner=>"puppet", :mode=>"770", :loglevel=>:debug, :path=>"/var/lib/puppet/ssl/ca/signed"}'
Debug: Using settings: adding file resource 'serial': 'File[/var/lib/puppet/ssl/ca/serial]{:links=>:follow, :group=>"puppet", :ensure=>:file, :backup=>false, :owner=>"puppet", :mode=>"644", :loglevel=>:debug, :path=>"/var/lib/puppet/ssl/ca/serial"}'
Debug: Using settings: adding file resource 'cakey': 'File[/var/lib/puppet/ssl/ca/ca_key.pem]{:links=>:follow, :group=>"puppet", :ensure=>:file, :backup=>false, :owner=>"puppet", :mode=>"660", :loglevel=>:debug, :path=>"/var/lib/puppet/ssl/ca/ca_key.pem"}'
Debug: Using settings: adding file resource 'caprivatedir': 'File[/var/lib/puppet/ssl/ca/private]{:links=>:follow, :group=>"puppet", :ensure=>:directory, :backup=>false, :owner=>"puppet", :mode=>"770", :loglevel=>:debug, :path=>"/var/lib/puppet/ssl/ca/private"}'
Debug: Using settings: adding file resource 'capass': 'File[/var/lib/puppet/ssl/ca/private/ca.pass]{:links=>:follow, :group=>"puppet", :ensure=>:file, :backup=>false, :owner=>"puppet", :mode=>"660", :loglevel=>:debug, :path=>"/var/lib/puppet/ssl/ca/private/ca.pass"}'
Debug: Using settings: adding file resource 'cert_inventory': 'File[/var/lib/puppet/ssl/ca/inventory.txt]{:links=>:follow, :group=>"puppet", :ensure=>:file, :backup=>false, :owner=>"puppet", :mode=>"644", :loglevel=>:debug, :path=>"/var/lib/puppet/ssl/ca/inventory.txt"}'
Debug: Using settings: adding file resource 'cadir': 'File[/var/lib/puppet/ssl/ca]{:links=>:follow, :group=>"puppet", :ensure=>:directory, :backup=>false, :owner=>"puppet", :mode=>"770", :loglevel=>:debug, :path=>"/var/lib/puppet/ssl/ca"}'
Debug: Using settings: adding file resource 'capub': 'File[/var/lib/puppet/ssl/ca/ca_pub.pem]{:links=>:follow, :group=>"puppet", :ensure=>:file, :backup=>false, :owner=>"puppet", :loglevel=>:debug, :path=>"/var/lib/puppet/ssl/ca/ca_pub.pem"}'
Debug: /File[/var/lib/puppet/ssl/ca/ca_key.pem]: Autorequiring File[/var/lib/puppet/ssl/ca]
Debug: /File[/var/lib/puppet/ssl/ca/requests]: Autorequiring File[/var/lib/puppet/ssl/ca]
Debug: /File[/var/lib/puppet/ssl/ca/serial]: Autorequiring File[/var/lib/puppet/ssl/ca]
Debug: /File[/var/lib/puppet/ssl/ca/ca_pub.pem]: Autorequiring File[/var/lib/puppet/ssl/ca]
Debug: /File[/var/lib/puppet/ssl/ca/private/ca.pass]: Autorequiring File[/var/lib/puppet/ssl/ca/private]
Debug: /File[/var/lib/puppet/ssl/ca/ca_crt.pem]: Autorequiring File[/var/lib/puppet/ssl/ca]
Debug: /File[/var/lib/puppet/ssl/ca/ca_crl.pem]: Autorequiring File[/var/lib/puppet/ssl/ca]
Debug: /File[/var/lib/puppet/ssl/ca/inventory.txt]: Autorequiring File[/var/lib/puppet/ssl/ca]
Debug: /File[/var/lib/puppet/ssl/ca/private]: Autorequiring File[/var/lib/puppet/ssl/ca]
Debug: /File[/var/lib/puppet/ssl/ca/signed]: Autorequiring File[/var/lib/puppet/ssl/ca]
Debug: Finishing transaction 70187171795120
Debug: Using cached certificate for ca
Debug: Using cached certificate for ca
Debug: Using cached certificate for mgmt.example.com
Debug: Using settings: adding file resource 'config': 'File[/etc/puppet/puppet.conf]{:links=>:follow, :ensure=>:file, :backup=>false, :loglevel=>:debug, :path=>"/etc/puppet/puppet.conf"}'
Debug: Finishing transaction 70187170837620
Notice: Starting Puppet master version 3.1.1
Info: access[^/catalog/([^/]+)$]: allowing 'method' find
Info: access[^/catalog/([^/]+)$]: allowing $1 access
Info: access[^/node/([^/]+)$]: allowing 'method' find
Info: access[^/node/([^/]+)$]: allowing $1 access
Info: access[/certificate_revocation_list/ca]: allowing 'method' find
Info: access[/certificate_revocation_list/ca]: allowing * access
Info: access[^/report/([^/]+)$]: allowing 'method' save
Info: access[^/report/([^/]+)$]: allowing $1 access
Info: access[/file]: allowing * access
Info: access[/certificate/ca]: adding authentication any
Info: access[/certificate/ca]: allowing 'method' find
Info: access[/certificate/ca]: allowing * access
Info: access[/certificate/]: adding authentication any
Info: access[/certificate/]: allowing 'method' find
Info: access[/certificate/]: allowing * access
Info: access[/certificate_request]: adding authentication any
Info: access[/certificate_request]: allowing 'method' find
Info: access[/certificate_request]: allowing 'method' save
Info: access[/certificate_request]: allowing * access
Info: access[/]: adding authentication any
Info: Inserting default '/status' (auth true) ACL
Info: Caching node for mgmt.example.com
Debug: No plugins found in subpath '/etc/puppet/modules/ntp/lib' (file / directory does not exist)
Debug: No plugins found in subpath '/etc/puppet/modules/helloworld/lib' (file / directory does not exist)
Debug: No plugins found in subpath '/etc/puppet/modules/apt/lib' (file / directory does not exist)
Debug: No plugins found in subpath '/etc/puppet/modules/puppetlabs_apt/lib' (file / directory does not exist)
Info: Caching node for mgmt.example.com
Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Could not find declared class puppetlabs_apt at /etc/puppet/manifests/site.pp:3 on node mgmt.example.com
Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Could not find declared class puppetlabs_apt at /etc/puppet/manifests/site.pp:3 on node mgmt.example.com
Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Could not find declared class puppetlabs_apt at /etc/puppet/manifests/site.pp:3 on node mgmt.example.com
Debug: Finishing transaction 70187171703400
Debug: Received report to process from mgmt.example.com
Debug: Processing report from mgmt.example.com with processor Puppet::Reports::Store

我也尝试过用它include puppetlabs_apt来代替课堂方式。

我还能做些什么来找出为什么主机找不到该模块,但可以找到安装在同一位置的其他模块?

答案1

这看起来像是一个权限问题。

/etc/puppet/modules# ls -la
total 28
drwxr-xr-x 7 root root  4096 Apr 19 18:01 .
drwxr-xr-x 7 root root  4096 Apr 19 16:30 ..
drwxr-xr-x 6  501 staff 4096 Dec  3 00:03 apt
drwxr-xr-x 4 root root  4096 Apr 17 18:32 ntp
drwx------ 3  502 staff 4096 Jan 25 23:09 puppetlabs_apt
drwxr-xr-x 6  503 staff 4096 Apr 19 16:30 puppetlabs_yum
drwxr-xr-x 6  502 staff 4096 Apr 12 17:14 stdlib

使 puppetlabs_apt 可供所有人读取,允许 puppet master 找到它。这解释了 master/agent 和 之间的区别puppet apply

这只是错误 #14333

答案2

您是否尝试使用 Forge 中的 puppetlabs-apt 模块?Forge 模块被命名为“moduleauthor/modulename”,但当包含时,应该只是“modulename”。

如果您将代码更改为以下内容,它应该可以工作:

node default {
  class { "apt":
  }
}

相关内容