From the course: Learning Puppet (2017)

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Use parameters

Use parameters - Puppet Tutorial

From the course: Learning Puppet (2017)

Start my 1-month free trial

Use parameters

- [Instructor] Our module is functional but it's pretty limited. It would be nice to have different options like setting the install directory or having an alternate jar URL. Just like you can use parameters and resources, classes can also take parameters. It's fairly simple syntax to set up but it can be a bit confusing at first. Let's look at our class and add two parameters. First of all, let's start by pulling out the strings we're dealing with and using variables instead. You'll recognize this syntax from the lesson about Facter. I'll create one variable called url, and I'll set that equal to the string for the URL, which I'll just copy and paste. Then I can use that variable here instead. Next I'll create a variable called install_dir, install underscore dir, and that should be set to opt/minecraft. Now to use this variable, it's going to be a bit more complicated. We'll take that and paste it in everywhere that opt/minecraft is used. For this one, for example, we'll need to use…

Contents