Puppet make parameters optional and assign default if null

puppet

You can pass in parameters into puppet like so…..

class foo ($install_version) }

#checkout git branch depending on $install_version 

}

How do you set a default value of $install_version if no $install_version is passed in?

Ideally the manifest will checkout the desired git branch, but if a branch is not specified, it will checkout the master branch.

http://docs.puppetlabs.com/guides/parameterized_classes.html

Best Answer

You need to read that page you linked again :-)

Quoting:

You can also give default values for any parameter in the list:

class webserver( $vhost_dir = '/etc/httpd/conf.d', $packages = 'httpd' ) {
  ...
}

So, in your case:

class foo ($install_version = 'master') }
Related Topic