Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Puppet 5 Beginner???s Guide
Puppet 5 Beginner???s Guide

Puppet 5 Beginner???s Guide: Go from newbie to pro with Puppet 5 , Third Edition

eBook
€17.99 €26.99
Paperback
€32.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Puppet 5 Beginner???s Guide

Chapter 2. Creating your first manifests

 

Beginnings are such delicate times.

 
 --Frank Herbert, 'Dune'

In this chapter, you'll learn how to write your first manifest with Puppet, and how to put Puppet to work configuring a server. You'll also understand how Puppet compiles and applies a manifest. You'll see how to use Puppet to manage the contents of files, how to install packages, and how to control services.

Creating your first manifests

Hello, Puppet – your first Puppet manifest

The first example program in any programming language, by tradition, prints hello, world. Although we can do that easily in Puppet, let's do something a little more ambitious, and have Puppet create a file on the server containing that text.

On your Vagrant box, run the following command:

sudo puppet apply /examples/file_hello.pp
Notice: Compiled catalog for ubuntu-xenial in environment production in 0.07 seconds
Notice: /Stage[main]/Main/File[/tmp/hello.txt]/ensure: defined content as '{md5}22c3683b094136c3398391ae71b20f04'
Notice: Applied catalog in 0.01 seconds

We can ignore the output from Puppet for the moment, but if all has gone well, we should be able to run the following command:

cat /tmp/hello.txt
hello, world

Understanding the code

Let's look at the example code to see what's going on (run cat /example/file_hello.pp, or open the file in a text editor):

file { '/tmp/hello.txt':
  ensure  => file...

Managing packages

Another key resource type in Puppet is the package. A major part of configuring servers by hand involves installing packages, so we will also be using packages a lot in Puppet manifests. Although every operating system has its own package format, and different formats vary quite a lot in their capabilities, Puppet represents all these possibilities with a single package type. If you specify in your Puppet manifest that a given package should be installed, Puppet will use the appropriate package manager commands to install it on whatever platform it's running on.

As you've seen, all resource declarations in Puppet follow this form:

RESOURCE_TYPE { TITLE:
  ATTRIBUTE => VALUE,
  ...
}

package resources are no different. The RESOURCE_TYPE is package, and the only attribute you usually need to specify is ensure, and the only value it usually needs to take is installed:

package { 'cowsay':
  ensure => installed,
}

Try this example:

sudo puppet apply /examples...

Services

The third most important Puppet resource type is the service: a long-running process that either does some continuous kind of work, or waits for requests and then acts on them. For example, on most systems, the sshd process runs all the time and listens for SSH login attempts.

Puppet models services with the service resource type. The service resources look like the following example (you can find this in service.pp in the /examples/ directory. From now on, I'll just give the filename of each example, as they are all in the same directory):

service { 'sshd':
  ensure => running,
  enable => true,
}

The ensure parameter governs whether the service should be running or not. If its value is running, then as you might expect, Puppet will start the service if it is not running. If you set ensure to stopped, Puppet will stop the service if it is running.

Services may also be set to start when the system boots, using the enable parameter. If enable is set to true, the...

Summary

In this chapter, we've seen how a manifest is made up of Puppet resources. You've learned how to use Puppet's file resource to create and modify files, how to install packages using the package resource, and how to manage services with the service resource. We've looked at the common package-file-service pattern and seen how to use the notify attribute on a resource to send a message to another resource indicating that its configuration has been updated. We've covered the use of the require attribute to make dependencies between resources explicit, when necessary.

You've also learned to use puppet resource to inspect the current state of the system according to Puppet, and puppet describe to get command-line help on all Puppet resources. To check what Puppet would change on the system without actually changing it, we've introduced the --noop and --show_diff options to puppet apply.

In the next chapter, we'll see how to use the version control...

Left arrow icon Right arrow icon

Key benefits

  • Develop skills to run Puppet 5 on single or multiple servers without hiccups
  • Use Puppet to create and manage cloud resources such as Amazon EC2 instances
  • Take full advantage of powerful new features of Puppet including loops, data types, Hiera integration, and container management

Description

Puppet 5 Beginner’s Guide, Third Edition gets you up and running with the very latest features of Puppet 5, including Docker containers, Hiera data, and Amazon AWS cloud orchestration. Go from beginner to confident Puppet user with a series of clear, practical examples to help you manage every aspect of your server setup. Whether you’re a developer, a system administrator, or you are simply curious about Puppet, you’ll learn Puppet skills that you can put into practice right away. With practical steps giving you the key concepts you need, this book teaches you how to install packages and config files, create users, set up scheduled jobs, provision cloud instances, build containers, and so much more. Every example in this book deals with something real and practical that you’re likely to need in your work, and you’ll see the complete Puppet code that makes it happen, along with step-by-step instructions for what to type and what output you’ll see. All the examples are available in a GitHub repo for you to download and adapt for your own server setup.

Who is this book for?

Puppet 5 Beginner’s Guide, Third Edition is designed for those who are new to Puppet, including system administrators and developers who are looking to manage computer server systems for configuration management. No prior programming or system administration experience is assumed.

What you will learn

  • •Understand the latest Puppet 5 features
  • •Install and set up Puppet and discover the latest and most advanced features
  • •Configure, build, and run containers in production using Puppet's industry-leading Docker support
  • •Deploy configuration files and templates at super-fast speeds and manage user accounts and access control
  • •Automate your IT infrastructure
  • •Use the latest features in Puppet 5 onward and its official modules
  • •Manage clouds, containers, and orchestration
  • •Get to know the best practices to make Puppet more reliable and increase its performance

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Oct 05, 2017
Length: 266 pages
Edition : 3rd
Language : English
ISBN-13 : 9781788472906
Vendor :
Puppet
Languages :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Oct 05, 2017
Length: 266 pages
Edition : 3rd
Language : English
ISBN-13 : 9781788472906
Vendor :
Puppet
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 133.97
Puppet 5 Essentials Third Edition
€36.99
Puppet 5 Beginner???s Guide
€32.99
Puppet: Mastering Infrastructure Automation
€63.99
Total 133.97 Stars icon

Table of Contents

13 Chapters
1. Getting started with Puppet Chevron down icon Chevron up icon
2. Creating your first manifests Chevron down icon Chevron up icon
3. Managing your Puppet code with Git Chevron down icon Chevron up icon
4. Understanding Puppet resources Chevron down icon Chevron up icon
5. Variables, expressions, and facts Chevron down icon Chevron up icon
6. Managing data with Hiera Chevron down icon Chevron up icon
7. Mastering modules Chevron down icon Chevron up icon
8. Classes, roles, and profiles Chevron down icon Chevron up icon
9. Managing files with templates Chevron down icon Chevron up icon
10. Controlling containers Chevron down icon Chevron up icon
11. Orchestrating cloud resources Chevron down icon Chevron up icon
12. Putting it all together Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.5
(13 Ratings)
5 star 61.5%
4 star 23.1%
3 star 15.4%
2 star 0%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Joshua Oct 24, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I've been using Puppet for some time now, and picked this book up after many great recommendations across the internet.John is such a kind hearted and pedagogically focussed individual, and his book reflects this. Though this is titled as a Puppet Beginners Guide, don't let that put you off. Having read this cover to cover, I've found that my own Puppet knowledge has increased, and I've started rewriting and making use of a lot of the concepts introduced in this book, some of which are idiomatic.I would recommend this book to anyone looking for a guide on how to use Puppet from start to finish, whether you 'think you know it all', or whether you are just curious. The style of John's writing makes it a real page turner, and the content does not become dry at any point.I have learned a lot from this book, and would urge John to write a follow-up, or 'Intermediates Guide to Puppet'.
Amazon Verified review Amazon
Ridgeback Dad Dec 13, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
It really doesn’t matter if you’re new to the team or a grizzled DevOps veteran - if you’re wanting to learn more about Puppet, “Puppet 5 Beginner’s Guide” will quickly make you productive and proficient in Puppet 5.Puppet 5 Beginner’s Guide walks you through it all! From installing Puppet and packages, manifests, configuration files as well as how to schedule jobs all the while showing you how to provisioning systems (and containers) locally or in the cloud. Did I mention that he also walks you through git?!?On a side note, I typically don't do reviews of any of the books I purchase, but I felt that book deserved a review!
Amazon Verified review Amazon
Dieter Lievens Jul 23, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book is arguably one of the finest technical books I've ever read on what is arguably a pretty vast subject. What I truly like about it is that the aim of the book is clearly to just show the reader how it's done. Some other books dedicate entire chapters on edge-cases and feel more like Phd-style reference books. Not this one.This book will not make you a puppet-guru. Nor does it claim to have this as a goal. This book will give you a fine starting point to become one, however. And anything not mentioned in this book will most likely be covered on stackoverflow.
Amazon Verified review Amazon
Lev Shulman Jan 30, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
As an experienced programmer and recent devops engineer, this was a great find for a total Puppet newbie like myself. Well written, with straightforward examples that work, and ends with a demo of how to put it all together. The book provides some sample code on github to use as a skeleton for Puppet projects -- exactly what I needed.
Amazon Verified review Amazon
M. Dimitrov Feb 24, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Für den einstieg in Puppet sehr gut. Auch wenn zum teil nicht mehr auf dem allerneusten Stand.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.