Augeas




A simple idea  => A powerful tool

AUGE...wHAaaaT ?



  •  A configuration editing tool and API


  •  A RedHat emerging technology project


  •  First release  in 2007/12/01 - not a trend - proven reliability, 1.2.0


  •  LGPL / 2197 commits / 67 contributors

wHAT DOES IT SOLVE (1/2)


         Change the port sshd is listening on


 sed -i 's/^Port .*/Port 2222/g' /etc/ssh/sshd_config


         Edit if exists, else append


awk '/^vm.swappiness/ {print "replacement"; found=1} !/^vm.swappiness/ {print $0} END {if (!found) {print "appended" }}' filename

What does it Solve (2/2)


define host{
host_name DROVER
use Servers-Linux
alias DROVER
address 1.2.3.4
hostgroups HOME_OFFICE,IN_SCOPE-SERVER,SERVER_GRP,SLA_SERVER_CORE
check_command check_centreon_ping
contact_groups SERVER_GRP
notification_interval 0
first_notification_delay 5
notification_period 24x7
notification_options d,u,r,f
notifications_enabled 1
}
awk 'NR % 20 == 9 && // { print window[(NR-7)%7] } { window[NR%7]=$2 }' hosts.cfg

http://www.linuxquestions.org/questions/linux-general-1/parsing-through-a-nagios-config-file-to-extract-info-w-sed-awk-vi-etc-837818/

sED / aWK / gREP OLDER THAN YOU


Grep : 1973

Sed : 1973

Awk : 1974


Puppet : 2005

CFEngine3 : 2008

Chef : 2009


Simply not the right tool for the right job - anymore

tEMPLATES / lINEINFILE


Templates : Remains a model.  Limited flexibility.


Lineinfile (Ansible) :  Primitive.



They both miss the point.

Configuration is not simply text, it is bound to a software logic

aUGEAS pRINCIPLES


Specialize (treeify) a configuration file via lenses

Provide an API to manage the tree


192.168.34.194 blog.devopsmtl.ca 
/files/etc/hosts
/files/etc/hosts/1
/files/etc/hosts/1/ipaddr = "192.168.34.194"
/files/etc/hosts/1/canonical = "blog.devopsmtl.ca" 



aUGEAS killer features


Specialization of configuration file / Software logic behavior


Real query language (XPath)


Bindings for all common programming language


Currently 179 lenses

Solutions To Previous problems


set /files/etc/ssh/sshd_config/Port 2222 


set /files/etc/resolv.conf/domain devopsmtl.ca 


print /files/etc/nagios/nagios.cfg/host/*[hostgroups = SERVERGRP]/hostname

Where IS DEVOPS in ALL THAT ?


  Basic Pattern : Installation -> Configuration -> Service start


        Installation :  

 yum install pkg

        Service : 

 service serviced start

       

        Configuration : 99% of the work

Augeas PROVIDERS


    Each bit of configuration file becomes a Puppet ressource


augeas {"add domain" :
context => '/file/etc/resolv.conf', changes => [
"ins domain before nameserver[1]",
"set domain devopsmtl.ca", ],
onlyif => "match domain[.='devopsmtl.ca'] size == 0",
}

AUGEASPROVIDERS PROVIDERs


nrpe_command { "check_updates":
  ensure  => present,
  command => "/usr/bin/check_updates -w 1 -c 5 --security-only",
}
nrpe_command { "check_ssh": ensure => absent,
}

  available AUGEASPROVIDERS


apache_setenv

host

kernel_parameter

mailalias

mounttab

nrpe_command

pg_hba

puppet_auth

shellvar

sshd_config

sshd_config_subsystem


Conclusion


brain { 'new state of mind' :
sed => absent,
grep => absent,
awk => absent,
templates => occasionally,
augeas => installed,
}


Questions ?

Augeas

By spredzy