Ask Your Question

Can't successfully build module

asked 2016-01-27 10:24:16 -0500

m_clarkson78 gravatar image

I've tried every tutorial I can find. I can't get puppet to successfully build a very basic module that calls a class and deploys a file from template. I'm running RHEL 7 with Puppet 3.6.2 from the EPEL repository. I can create and apply manifests all day. I can't make a module that works. Here's my steps:

puppet module generate michael-simplemod
mv michael-simplemod simplemod
cd simplemod

Then I start editing files. My directory structure looks like this:

ls -R
manifests  metadata.json  Rakefile  spec  templates  tests


classes  spec_helper.rb




My init.pp contains:

class simplemod::foo {
        file { '/etc/foo':
                ensure => file,
                content => template("simplemod/templates/foo.erb"),
                owner => root,
                group => root,
                mode  => '0644',
class simplemod {
    include simplemod::foo
include simplemod

My foo.erb contains:

This file is based on a Puppet template, foo.erb.
It is deployed on <%= @hostname %>

When I try a puppet apply manifests/init.pp --noop, it fails to find foo.erb. Here's my modulepath:

puppet master --configprint modulepath

Not one single help file or instruction guide answers my simple question, why does no guide I've found give me step by step a beginning to end working solution for building a simple module? They all either dive off into developer jargon without defining what they mean, or their answer is incomplete.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-01-29 06:29:59 -0500

rajeevsharma gravatar image

Hi, Instead of

content => template("simplemod/templates/foo.erb")


content => template("simplemod/foo.erb")

You mistakenly used the absolute path for the erb file which is not the case. Please find the this info in details here:

I hope this will work.

edit flag offensive delete link more


Thank you rajeevsharma. This worked for my template. Module actually tests and builds. The guide I was reading had absolute pathing, which is wrong, and I missed the doc you pointed out. Two thumbs up for your concise and correct answer.

m_clarkson78 gravatar imagem_clarkson78 ( 2016-02-02 09:05:19 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-01-27 10:24:16 -0500

Seen: 68 times

Last updated: Jan 29 '16