Reputation: 378
This is probably just a basic question, but I can't find a solution. I set up an environment where I want to use the apache module given by puppetlabs.
My puppet version is 3.7.2
tree of my directory:
.
├── environments
│ └── test
│ ├── environment.conf
│ ├── manifests
│ │ └── site.pp
│ └── modules
│ ├── apache
│ │ └── manifests
│ │ ├── init.pp
│ │ └── vhost_basic.pp
│ └── update
│ └── manifests
│ └── init.pp
└── Vagrantfile
my provisioner inside Vagrantfile looks like this:
config.vm.provision :puppet do |puppet|
puppet.environment_path = "environments"
puppet.environment = "test"
puppet.options = ['--verbose']
end
my site.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'
}
}
inside the apaches (directory) init.pp I only have include apache
. And I installed the apache module via puppet module install puppetlabs-apache
. And it's also stored in home/user/.puppet/modules
. I also installed the module via sudo (since I read somewhere that it makes a difference..). But when I run vagrant provision
it says me:
==> 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
What am I missing here?
EDIT:
the result of puppet config print |grep path
is:
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
Upvotes: 2
Views: 1268
Reputation: 53713
You environment.conf
is not correct, as you installed the modules locally they will be shared in your VM under the /vagrant
directory so you should reference this instead. (they are shared in your /etc/puppet
directory when you indicate the puppet.modules
path in your puppet provisioner block)
However what I suggest is to add a simple shell provisioner which will install the modules for you (and manage the sudo part) - In your vagrantfile (before the puppet provisioner)
config.vm.provision :shell, path: "/path/to/script.sh"
In your script.sh
#!/bin/bash
puppet module install puppetlabs-apache --version 1.10.0
This will install the modules in /etc/puppetlabs ... so you can reference this in your environment.conf
modulepath = /etc/puppetlabs/code/environments/production/modules:$basemodulepath
Upvotes: 4