Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 (

    $path,
    $ensure,
    $provider,
    $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

1 Answer 1

up vote 2 down vote accepted

Solution was to use undef instead of nil/null.

share|improve this answer

Your Answer

 
discard

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.