Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 2 down vote accepted

Solution was to use undef instead of nil/null.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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