这可能只是一个基本问题,但我找不到解决方案。我建立了一个环境,我想使用puppetlabs提供的apache模块 我的木偶版本是3.7.2 我的目录树:
.
├── environments
│ └── test
│ ├── environment.conf
│ ├── manifests
│ │ └── site.pp
│ └── modules
│ ├── apache
│ │ └── manifests
│ │ ├── init.pp
│ │ └── vhost_basic.pp
│ └── update
│ └── manifests
│ └── init.pp
└── Vagrantfile
我在Vagrantfile中的配置文件如下所示:
config.vm.provision :puppet do |puppet|
puppet.environment_path = "environments"
puppet.environment = "test"
puppet.options = ['--verbose']
end
我的网站.pp:
Exec { path => [ "/bin/", "/sbin/" , "/usr/bin/", "/usr/sbin/" ] }
include update
node 'localhost' {
class { 'apache': } # use apache module
apache::vhost { 'example.com': # define vhost resource
port => '80',
docroot => '/var/www/html'
}
}
在apaches(目录)init.pp中我只有include apache
。我通过puppet module install puppetlabs-apache
安装了apache模块。它也存储在home/user/.puppet/modules
中。我也通过sudo安装了模块(因为我在某处阅读它有所不同......)。但当我运行vagrant provision
时,它会说:
==> default: Running provisioner: puppet...
==> default: Running Puppet with environment test...
==> default: Error: Evaluation Error: Error while evaluating a Resource Statement, Could not find declared class apache at /tmp/vagrant-puppet/environments/test/manifests/site.pp:16:3 on node localhost
我在这里缺少什么?
编辑:
puppet config print |grep path
的结果是:
path = none
environmentpath =
basemodulepath = /home/user/.puppet/modules:/usr/share/puppet/modules
modulepath = /home/user/.puppet/modules:/usr/share/puppet/modules
factpath = /home/user/.puppet/var/lib/facter:/home/user/.puppet/var/facts
答案 0 :(得分:3)
您environment.conf
不正确,因为您在本地安装了这些模块,它们将在/vagrant
目录下的VM中共享,因此您应该引用它。 (当您在puppet provisioner块中指明/etc/puppet
路径时,它们将在您的puppet.modules
目录中共享
但我建议添加一个简单的shell配置程序,它将为您安装模块(并管理sudo部分) - 在您的vagrantfile中(在puppet配置器之前)
config.vm.provision :shell, path: "/path/to/script.sh"
在script.sh
#!/bin/bash
puppet module install puppetlabs-apache --version 1.10.0
这将在/ etc / puppetlabs中安装模块...所以你可以在environment.conf
modulepath = /etc/puppetlabs/code/environments/production/modules:$basemodulepath