I'm trying to optionally include a parameter in a puppet class instance. If a value is provided, the parameter should be passed to the class, and if it's empty it shouldn't be.

This the code I have so far:

class vcs (

    $source = '',
    $revision = '',
    $user = ''


    vcsrepo { $path:
      ensure   => $ensure,
      provider => $provider,
      source => $source ? {
        '' => nil,
        default => $source


I've tried to set the value of the source parameter to be nil in case it isn't set, but Puppet doesn't seem to understand neither nil nor null. (I get a fatal: repository 'null' does not exist error)

Basically, I want to be able to call the vcs class, with only the path and ensure parameters to be required and all the others to be optional.


Solution was to use undef instead of nil/null.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.