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.

Templates

Templates - Puppet Tutorial

From the course: Learning Puppet (2017)

Start my 1-month free trial

Templates

- [Lecturer] In order to set the install directory we need our minecraft.service file to be dynamically generated. Templates allow you to be more flexible in how your text files are defined. And you can use things like facts, variables and parameters to change the output. First we'll copy the contents of the minecraft.service module. So I'll go to site, minecraft, files, minecraft.service and I'll just select this and copy it. Then I want to paste this into a template so I'll go back to the root of my module and then create a new file called templates minecraft.service.epp. And then I'm going to paste the contents of the service file. eep is the puppet template format. And puppet also supports ruby erb style templates but they can be a bit more confusing. The eep syntax is pretty simple. We can just go in and replace this install directory with an epp tag. So we'll start with a less than symbol, and a parentheses, then the equal sign. Then we'd say $install_dir which is the variable…

Contents