From the course: Puppet Essential Training

Unlock the full course today

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

Variables and conditionals

Variables and conditionals - Puppet Tutorial

From the course: Puppet Essential Training

Start my 1-month free trial

Variables and conditionals

- [Instructor] The Puppet language supports complex logic using things like variables and conditionals. We've already seen a little bit of this in the lesson on classes. In this lesson, we'll go much deeper. You're probably already familiar with the concept of a variable. It's just a way of dynamically assigning a bit of data to a keyword that you can use in your code. In most programming languages, you can reassign a variable. So you might start with X=2, and then later update that to X=4. In Puppet, variables are immutable. You can't reassign a variable. Or put another way, Puppet variables don't vary. This can be really confusing, so let's take a moment to talk about why Puppet works this way. When Puppet runs, it first gathers information about your system, called facts. These are then used to compile what's called a catalog, based on a combination of the facts, your Puppet code, and a few other things. The variables and conditional logic happen at compilation time. So it doesn't…

Contents