1
votes

For test purposes I wanted to setup puppet and deploy apache on Ubuntu 16.4 puppet master using puppet without bothering with using nodes by using the following steps:

$ wget https://apt.puppetlabs.com/puppet5-release-xenial.deb

Install the package by running:

$ dpkg –i puppet5-release-xenial.deb

Update package list

$ apt-get update

Install puppet server

$ sudo apt-get install puppetserver

On our Puppet server, install the puppetlabs-apache module:

$ sudo puppet module install puppetlabs-apache

From within the manifests directory, an init.pp class needs to be created /etc/puppet/modules/apache/manifests/init.pp

class apache2 {
    package {'apache2':
          ensure => 'present',
    }
}

To try to install the apache package I used:

$ sudo puppet apply init.pp

I then got the following:

Notice: Compiled catalog for osboxes.home in environment production in 0.03 seconds
Notice: Finished catalog run in 0.04 seconds

And when I check if apache is installed, it is not.

Where am I going wrong?

1

1 Answers

3
votes

If you have the Apache module in the correct module path, then the problem is you don't have any code to include the module.

To keep it simple, let's forget about the file structure on the Puppet master and so forth and just create a file apache.pp (save it in /tmp or anywhere you like) and give it this content:

class apache2 {
    package {'apache2':
        ensure => 'present',
    }
}

include apache2

Now try:

$ sudo puppet apply apache.pp

You should see Puppet install the apache2 package.

However, by convention, and also for proper integration with the Puppet master, you need to now place this content in expected file locations.

The class apache (the code you already had) needs to be in a file ${modulepath}/apache2/manifests/init.pp.

This is to satisfy Puppet's autoloader. You can find out more about that here.

Meanwhile, the modulepath is documented here, and it can vary depending on the version of Puppet, and how you set everything up.

To find out your modulepath try:

$ sudo puppet config print modulepath

Now, if you have all the files in place, you should next be able to include that class in a different way, like this:

$ sudo puppet apply -e "include apache2"

Once you get that working, it's time to read about the roles and profiles pattern.