Book Image

Puppet Cookbook - Third Edition

Book Image

Puppet Cookbook - Third Edition

Overview of this book

Table of Contents (17 chapters)
Puppet Cookbook Third Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Using Augeas to reliably edit config files


Sometimes it seems like every application has its own subtly different config file format, and writing regular expressions to parse and modify all of them can be a tiresome business.

Thankfully, Augeas is here to help. Augeas is a system that aims to simplify working with different config file formats by presenting them all as a simple tree of values. Puppet's Augeas support allows you to create augeas resources that can make the required config changes intelligently and automatically.

How to do it…

Follow these steps to create an example augeas resource:

  1. Modify your base module as follows:

      class base {
        augeas { 'enable-ip-forwarding':
          incl    => '/etc/sysctl.conf',
          lens    => 'Sysctl.lns',
          changes => ['set net.ipv4.ip_forward 1'],
        }
      }
  2. Run Puppet:

    [root@cookbook ~]# puppet agent -t
    Info: Applying configuration version '1412130479'
    Notice: Augeas[enable-ip-forwarding](provider=augeas): 
    --- /etc/sysctl.conf	2014-09...