Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Puppet Cookbook - Third Edition
  • Table Of Contents Toc
  • Feedback & Rating feedback
Puppet Cookbook - Third Edition

Puppet Cookbook - Third Edition - Third Edition

By : Thomas Uphill, John Arundel
5 (2)
close
close
Puppet Cookbook - Third Edition

Puppet Cookbook - Third Edition

5 (2)
By: Thomas Uphill, John Arundel

Overview of this book

This book is for anyone who builds and administers servers, especially in a web operations context. It requires some experience of Linux systems administration, including familiarity with the command line, file system, and text editing. No programming experience is required.
Table of Contents (12 chapters)
close
close
11
Index

Passing parameters from Hiera


Like the parameter defaults we introduced in the previous chapter, Hiera may be used to provide default values to classes. This feature requires Puppet Version 3 and higher.

Getting ready

Install and configure hiera as we did in Chapter 2, Puppet Infrastructure. Create a global or common yaml file; this will serve as the default for all values.

How to do it...

  1. Create a class with parameters and no default values:

    t@mylaptop ~/puppet $ mkdir -p modules/mysql/manifests t@mylaptop ~/puppet $ vim modules/mysql/manifests/init.pp
    class mysql ( $port, $socket, $package ) {
      notify {"Port: $port Socket: $socket Package: $package": }
    }
    
  2. Update your common .yaml file in Hiera with the default values for the mysql class:

    ---
    mysql::port: 3306
    mysql::package: 'mysql-server'
    mysql::socket: '/var/lib/mysql/mysql.sock'
    

    Apply the class to a node, you can add the mysql class to your default node for now.

    node default {
      class {'mysql': }
    }
    
  3. Run puppet agent and verify the output...

Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Puppet Cookbook - Third Edition
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon