运行 puppet apply with modulepath 时找不到 class

Could not find class when running puppet apply with modulepath

使用 modulepath 开关运行 puppet apply 失败并显示 Error: Could not find class apt for vagrant.example.com on node vagrant.example.com

Puppet 版本是 3.7.3,运行在 Ubuntu 14.04 上,由 Vagrant 和 VirtualBox 管理

这是我正在运行的命令:

sudo puppet apply --debug --verbose --modulepath '/tmp/vagrant-puppet-3/modules-0' /tmp/vagrant-puppet-3/manifests/default.pp

输出

vagrant@vagrant:~$ sudo puppet apply --debug --verbose --modulepath '/tmp/vagrant-puppet-3/modules-0'  /tmp/vagrant-puppet-3/manifests/default.pp
Warning: Setting templatedir is deprecated. See http://links.puppetlabs.com/env-settings-deprecations
   (at /usr/lib/ruby/vendor_ruby/puppet/settings.rb:1139:in `issue_deprecation_warning')
Debug: Runtime environment: puppet_version=3.7.3, ruby_version=1.9.3, run_mode=user, default_encoding=US-ASCII
Info: Loading facts
Debug: Loading facts from /tmp/vagrant-puppet-3/modules-0/puppetlabs-apt/lib/facter/apt_update_last_success.rb
Debug: Loading facts from /tmp/vagrant-puppet-3/modules-0/puppetlabs-apt/lib/facter/apt_updates.rb
Info: Loading facts
Debug: Loading facts from /tmp/vagrant-puppet-3/modules-0/puppetlabs-concat/lib/facter/concat_basedir.rb
Info: Loading facts
Debug: Loading facts from /tmp/vagrant-puppet-3/modules-0/puppetlabs-stdlib/lib/facter/facter_dot_d.rb
Debug: Loading facts from /tmp/vagrant-puppet-3/modules-0/puppetlabs-stdlib/lib/facter/pe_version.rb
Debug: Loading facts from /tmp/vagrant-puppet-3/modules-0/puppetlabs-stdlib/lib/facter/puppet_vardir.rb
Debug: Loading facts from /tmp/vagrant-puppet-3/modules-0/puppetlabs-stdlib/lib/facter/root_home.rb
Error: Could not find class apt for vagrant.example.com on node vagrant.example.com
Error: Could not find class apt for vagrant.example.com on node vagrant.example.com

/tmp/vagrant-puppet-3/manifests/default.pp`的内容

node default 
{ 
  include apt
}

/tmp/vagrant-puppet-3/modules-0的内容

drwxr-xr-x 1 root vagrant  714 Jan  5 20:03 puppetlabs-apt
drwxr-xr-x 1 root vagrant  680 Jan  5 20:03 puppetlabs-concat
drwxr-xr-x 1 root vagrant  782 Jan  5 20:03 puppetlabs-postgresql
drwxr-xr-x 1 root vagrant  782 Jan  5 20:03 puppetlabs-stdlib

使用相同的模块路径运行 puppet module list 确实列出了模块(包括我所指的 puppetlabs-apt),尽管有依赖项警告。

vagrant@vagrant:~$ puppet module list --debug --verbose --modulepath '/tmp/vagrant-puppet-3/modules-0'
Warning: Missing dependency 'puppetlabs-apt':
  'puppetlabs-postgresql' (v4.1.0) requires 'puppetlabs-apt' (>=1.1.0 <2.0.0)
Warning: Missing dependency 'puppetlabs-concat':
  'puppetlabs-postgresql' (v4.1.0) requires 'puppetlabs-concat' (>= 1.1.0 <2.0.0)
Warning: Missing dependency 'puppetlabs-stdlib':
  'puppetlabs-apt' (v1.7.0) requires 'puppetlabs-stdlib' (>= 2.2.1)
  'puppetlabs-concat' (v1.1.2) requires 'puppetlabs-stdlib' (>= 3.2.0 < 5.0.0)
  'puppetlabs-postgresql' (v4.1.0) requires 'puppetlabs-stdlib' (v4.x)
/tmp/vagrant-puppet-3/modules-0
├── puppetlabs-apt (v1.7.0)
├── puppetlabs-concat (v1.1.2)
├── puppetlabs-postgresql (v4.1.0)
└── puppetlabs-stdlib (v4.5.0)

奇怪的是 puppet module list 似乎在寻找模块,但在我的清单文件中引用任何模块都失败了(如果我尝试包含 postgresql,也会出现 class 错误)。我感觉我的清单文件是错误的。我在这里遗漏了什么明显的东西吗?

干杯

将模块文件夹 puppetlabs-apt 重命名为 apt

或更改pp代码

来自

include apt 

include puppetlabs-apt

取决于你在apt pp文件中的定义。