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 - Puppet Tutorial
From the course: Puppet Essential Training
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
Resources5m 41s
-
(Locked)
Classes5m 23s
-
(Locked)
The node graph4m 36s
-
(Locked)
Generate a node graph2m 50s
-
(Locked)
Defined resource types1m 51s
-
(Locked)
Variables and conditionals5m 29s
-
(Locked)
Iteration2m 17s
-
(Locked)
Facts and functions4m 18s
-
(Locked)
More resources2m 54s
-
(Locked)
✓ Challenge: Simplify a manifest21s
-
(Locked)
✓ Solution: Simplify a manifest1m 13s
-
-
-
-
-
-
-