A collection of task oriented solutions in Puppet

 

Fileserver In Template call

Challenge

Puppet reports "module names must be alphanumeric (plus '-'), not 'puppet:"

Solution

    # this is invalid
    file { '/tmp/filesources':
      content => template('puppet:///modules/mymodule/mymodule.conf.erb'),
    }

    # and will cause an error like this to appear
    # Invalid module name; module names must be alphanumeric (plus '-'), not 'puppet:'
    # at /my/path/init.pp:4 on node pcb.unixdaemon.private

    # instead it should look like this
    file { '/tmp/filesources':
      content => template('mymodule/mymodule.conf.erb'),
    }

Explanation

When running puppet you see lines that look like this on your screen or in the logs:

    Invalid module name; module names must be alphanumeric (plus '-'), not 'puppet:'
    at /my/path/init.pp:4 on node pcb.unixdaemon.private

This is often caused when you confuse the 'content' and 'source' attributes and mostly when you are refactoring a resource from a static file to one that uses a template for dynamic content. This is an annoying mistake as you can easily miss it due to the syntax being correct - just not in this context.