Search code examples
vagrantpuppet

Issue configuring puppetlabs/apache module with Vagrant


I started using Vagrant and Puppet recently, and i am having bit of difficulty getting puppet to work.

With puppet i want to change apache user and group to vagrant to solve permission issue when sharing the folder.

I want to do it by using following puppet config

class { "apache":
    user => "vagrant",
    group => "vagrant",
}

Reference : http://ryansechrest.com/2014/04/unable-set-permissions-within-shared-folder-using-vagrant-virtualbox/

For this i installed puppet on my host and guest machine, on host machine i added following cofig in Vagrantfile

config.vm.provision :puppet do |puppet|
    puppet.manifests_path = 'puppet/manifests'
    puppet.module_path    = 'puppet/modules'
end

And created the file puppet/manifests/default.pp on host machine with following content

node 'node1' {

    include apache

    class { "apache":
        user => "vagrant",
        group => "vagrant",
    }
}

When i run vagrant provision, i get the following error

==> default: Error: Could not find default node or by name with 'localhost' on node localhost
==> default: Error: Could not find default node or by name with 'localhost' on node localhost
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

Where am i going wrong?


Solution

  • Just keep it simple:

    For this i installed puppet on my host and guest machine,

    you only need puppet to be installed on your guest machine, you can keep your host clean

    you reference and define puppet/manifests/default.pp which is fine, just remove the node part

    Package {
      allow_virtual => true,
    }
    
    class { "apache":
        user => "vagrant",
        group => "vagrant",
    }
    
    include apache
    

    can you confirm you have an apache module in your host puppet/modules or installed on the guest - you can have provision to run something like

    #!/bin/bash
    
    mkdir -p /etc/puppet/modules;
    
    if [ ! -d /etc/puppet/modules/puppetlabs-apache ]; then
      puppet module install puppetlabs-apache
    fi
    

    assuming you talk about this apache module, else replace with the module you're using if it comes from the forge