How do I set documentroot for apache with puppet? - apache

I've been trying to get apache to serve from /vagrant/ using puppet through vagrant, my manifest looks like this:
class apache {
exec { 'apt-get update':
command => '/usr/bin/apt-get update'
}
package { "apache2":
ensure => present,
}
service { "apache2":
ensure => running,
require => Package["apache2"],
root => '/vagrant/'
}
}
I would really appreciate the help.... I'm stunned at how bad the manifest documentation is.

easier than changing the httpd.conf with templates etc, it's to make a symlink from /var/www to /vagrant. Add
file { '/var/www':
ensure => 'link',
target => '/vagrant',
force => true,
}
to your puppet file and you are running.

The service resource manages the process but doesn't have anything to do with the configuration files.
Your manifest simply says "Make sure that apt is updated, apache2 is installed and running".
I think what you are looking for can be handled with templates (http://docs.puppetlabs.com/guides/templating.html).

Related

"Error: cannot file config find .jshintrc " in cli after cloning the git repo and running grunt

When i try to run grunt , i am getting error as "cannot file the config file .jshintrc". I tried to install the config dependencies but nothing is working out.Can anyone tell me how to resolve this particular error. Do i need to define any particular rule in my grunt.js file as I believe this should be generated automatically in the root folder after running grunt.
The piece of lines for jshint task in grunt.js is-
grunt.initConfig({
lesslint:{
src: ['src/']
},
jshint: { // configure the task
all: ['src/app/**/*.js'],
options: {
reporter: require('jshint-html-reporter'),
reporterOutput: 'out/jshint-report.html',
//force report
force: false,
// JS Validation rules are configured in .jshintrc file.
jshintrc: '.jshintrc'
}
});
Any help is much appreciated.

Install apache module with puppet on Debian 7

My problem is during the provisionning of my Vagrant VM using puppet. The error is :
==> default: err: /Stage[main]//Service[apache2]: Could not evaluate: Could not find init script for 'apache2'
My puppetFile is the following default.pp :
Exec { path => [ "/bin/", "/sbin/" , "/usr/bin/", "/usr/sbin/" ] }
exec { 'apt-get update':
command => 'apt-get update',
timeout => 60,
tries => 3
}
class { 'apt': }
$sysPackages = ['python-software-properties', 'build-essential', 'apache2', 'apache2.2-common']
package { $sysPackages:
ensure => "installed",
require => Exec['apt-get update'],
}
service { apache2:
ensure => running,
enable => true,
require => Package['apache2', 'apache2.2-common'],
}
When not writting the apache2 service, there is no error thrown, but there is no /etc/init.d/apache2. I guess that's why the error is thrown. So how can I avoid this error, or more generaly how to cleanly install this module ?
Any help is welcome.

Error 'invalid parameter include_src' when provisionning RabbitMQ with Puppet on Vagrant

I am trying to install the RabbitMQ module on my virtual machine. I used :
git submodule add https://github.com/puppetlabs/puppetlabs-rabbitmq.git
and I installed every dependecy I could find the same way (which are, like listed in this answer : stdlib, epel, staging and erlang).
I reduced my manifest to the bare minimum :
Exec { path => [ "/bin/", "/sbin/" , "/usr/bin/", "/usr/sbin/" ] }
exec { 'apt-get update':
command => 'apt-get update',
timeout => 60,
tries => 3
}
package { ['python-software-properties']:
ensure => 'installed',
require => Exec['apt-get update'],
}
$sysPackages = [ 'build-essential', 'git', 'curl']
package { $sysPackages:
ensure => "installed",
require => Exec['apt-get update'],
}
include epel
include staging
class { 'erlang': epel_enable => true}
class { 'rabbitmq':
port => '5672',
service_manage => true,
environment_variables => {
'RABBITMQ_NODENAME' => 'server',
'RABBITMQ_SERVICENAME' => 'rabbitMQ'
}
}
And when I provision my VM with vagrant provision, I get the error :
==> default: Error: Invalid parameter include_src at /tmp/vagrant-puppet/modules
-33d06c2339c7ee7ab2bd92b2d11cf5d9/erlang/manifests/repo/apt.pp:39
I'm almost certain it is because of a dependency I do not have, but I can not find out which one. Any ideas ?
It seems that erlang module requires older version of apt module. Look at this patch. Recently, in apt resource, parameters include_src and include_deb were substituted by one include parameter. To solve the problem please install apt module in version 1.8.0.

Configuring Apache with Puppet and Vagrant

I'm using Vagrant and Puppet for the first time in a project and I keep running into an issue.
I've used PuPHPet as a starting point, and I have the following snippet in my default.pp manifest:
class { 'apache': }
apache::dotconf { 'custom':
content => 'EnableSendfile Off',
}
apache::module { 'rewrite': }
apache::vhost { 'awesome.dev':
server_name => 'awesome.dev',
serveraliases => [
],
docroot => '/var/www',
port => '80',
directories => [ { path => '/var/www/', allow => 'from all', allow_override => ['All'] } ],
env_variables => [],
priority => '1',
}
When I run it, I always get the following error:
warning: Could not retrieve fact fqdn
Invalid parameter directories at /tmp/vagrant-puppet/manifests/default.pp:46 on node precise32
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
cd /tmp/vagrant-puppet/manifests && puppet apply --verbose --modulepath '/etc/puppet/modules:/tmp/vagrant-puppet/modules-0' default.pp --detailed-exitcodes || [ $? -eq 2 ]
Line 46 is the end of the apache::vhost rule. I want to set it to allow override using htaccess, but I can't see where I've gone wrong. Can anyone see what the issue is?
PuPHPet uses the Example42 Apache Puppet module, see the README file. This module doesn't have a directories parameter in the vhost resource:
https://github.com/puphpet/puphpet-apache/blob/master/manifests/vhost.pp#L100
Only the Puppet Labs Apache module has a directories parameter, but it's a different module:
https://github.com/puppetlabs/puppetlabs-apache/blob/master/manifests/vhost.pp#L25
You can however use the directory parameter in Example42's module similarly to the example which can be found in the vhost resource:
# apache::vhost { 'my.other.site':
# docroot => '/path/to/docroot',
# directory => '/path/to',
# directory_allow_override => 'All',
# }

Vagrant / Chef-solo not working after running recipe rvm::vagrant

After adding recipe rvm::vagrant and running vagrant provision I got:
/usr/local/bin/chef-solo: line 23: /opt/vagrant_ruby/bin/chef-solo: No such file
or directory
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.
This issue should have been fixed:
https://github.com/fnichol/chef-rvm/issues/121
Even though I add the line:
'rvm' => {
'vagrant' => {
'system_chef_solo' => '/opt/vagrant_ruby/bin/chef-solo'
}
}
I am still getting the error. How can I recover from it?
You have to make sure that '/opt/vagrant_ruby/bin/chef-solo' is actual path of chef-solo. In my case it was /usr/bin/chef-solo. And this is part of my Vagrantfile that fixed it:
config.vm.provision :chef_solo do |chef|
chef.json.merge! rvm: {vagrant: {system_chef_solo: '/usr/bin/chef-solo'}}
end
This has been frustrating as answers are very time dependent. I have had this issue though and fixed it today by adding to my Vagrantfile. I had to vagrant destroy and vagrant up again so hopefully this doesn't break next time I vagrant provision but I have checked in the box and it looks like the path to chef-solo is correct. Found this answer out on Github at here
chef.json = {
rvm: {
vagrant: {
system_chef_solo: '/opt/chef/bin/chef-solo'
},
user_installs: [
{
user: 'vagrant',
default_ruby: '2.2.1',
rubies: ['2.2.1'],
global: '2.2.1'
}
]
},
... rest of Vagrantfile