0
votes

Right, I've been using Puppet for approx. 4 hours so have a total n000b question. I've downloaded and installed a puppet module using:

puppet module install resolv_conf

All well and good. It has installed the module into:

/home/user/.puppet/modules/, again all well and good.

The module shows up when I run puppet module list, which I'm guessing it's supposed to.

So my question is how do I use the module?

I get that somewhere I need to add to a manifest,

class { 'resolv_conf': nameservers => ['192.168.0.254', '8.8.8.8'], }

but I'm assuming that I don't add that in the

/home/user/.puppet/modules/resolv_conf/manifests/init.pp file.

I tried creating a folder and init.pp file here

/etc/puppet/modules/resolv_conf/manifests

and added the class to it, but I get

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Puppet::Parser::AST::Resource failed with error ArgumentError: Could not find declared class resolv_conf at /etc/puppet/modules/resolv_conf/manifests/init.pp:4 on node rarity.home

So I'm a bit stumped. Can some kind soul point me in the right direction?

Fanks :)

1
This is a very broad question. You're missing a lot of steps, such as setting up a puppet master and defining your $modulepath etc. I suggest you try going through the puppet learning VM: puppet.com/download-learning-vm and getting some of the basics down. - jaxxstorm
Thanks @Frap. Followed this help.ubuntu.com/lts/serverguide/puppet.html and got the master setup and the agent running on another machine and puppet is making sure that some services are running. I tested that by stopping those services then running the agent and it starts them, so it looks like puppet is running OK. It was just how to "include" the downloaded module that I don't get, and the fact it went to /home/user/.puppet rather than /etc/puppet/modules. Maybe $modulepath is what I need to look at. Cheers :) - tinyhammers
In that case, I can help, answer incoming.. - jaxxstorm

1 Answers

3
votes

So by default, the puppet module command will download modules into a local directory.

Assuming your master is running correctly, you need to install the module into your $modulepath, you can find your $modulepath on the master by doing:

puppet config print modulepath

Which depending on your version of Puppet (I'm running v4, so if you're on v3 it may be slightly different), will return something like this:

/etc/puppetlabs/code/environments/production/vendor:/etc/puppetlabs/code/environments/production/modules:/etc/puppetlabs/code/modules:/opt/puppetlabs/puppet/modules

Install your module into one of those directories using the Puppet Module command like so:

puppet module install -i /etc/puppetlabs/code/modules

Now, your master will understand and be able to read to resolv_conf module, but you need to apply it to your nodes. In order to do that you need to set up node definitions

So within one of your $modulepaths you'll need to have a directory manifests containing a single manifest, site.pp which is called the "main manifest"

Inside there, create a node definition for your agent similar to the one in the example:

node 'www1.example.com' {
  include resolv_conf
}

This is the simplest set up you can have. Some further reading:

  • r10k can automate the downloading of modules for you
  • a control repo is a suggested way of laying out your puppet repo
  • an ENC is a better way of classifying your nodes than using the site.pp

Good luck!