• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Configuration surgery with Augeas (OggCamp 12)
 

Configuration surgery with Augeas (OggCamp 12)

on

  • 1,058 views

Lightning talk for an intro to Augeas at OggCamp 12. Briefly explains the library, examples of what it can do and where it's used. Based on a presentation by Raphaël Pinson (search for RMLL 2012).

Lightning talk for an intro to Augeas at OggCamp 12. Briefly explains the library, examples of what it can do and where it's used. Based on a presentation by Raphaël Pinson (search for RMLL 2012).

Statistics

Views

Total Views
1,058
Views on SlideShare
1,058
Embed Views
0

Actions

Likes
0
Downloads
1
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution-ShareAlike LicenseCC Attribution-ShareAlike License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Configuration surgery with Augeas (OggCamp 12) Configuration surgery with Augeas (OggCamp 12) Presentation Transcript

    • Configuration surgerywith AugeasDominic Clealdcleal@redhat.comOggCamp 12, Liverpool19th August 2012Presentation forked from Raphaël Pinsons at RMLL 2012
    • Tired of ugly sed and awk one liners?or of using tons of different parsing libraries orbrittle tricks? OggCamp | 2 | Dominic Cleal
    • Become a configuration surgeon with Augeas OggCamp | 3 | Dominic Cleal
    • What is the need?● Many different syntaxes● Securely editing configuration files with a unified API OggCamp | 4 | Dominic Cleal
    • A tree, its branches and leavesAugeas turns configuration files into a treestructure:/etc/hosts -> /files/etc/hosts... and their parameters into branches andleaves:augtool> print /files/etc/hosts/files/etc/hosts/files/etc/hosts/1/files/etc/hosts/1/ipaddr = "127.0.0.1"/files/etc/hosts/1/canonical = "localhost" OggCamp | 5 | Dominic Cleal
    • Augeas provides many stock parsersThey are called lenses:Access Cron Host_ConfAliases Crypttab HostnameAnacron debctrl Hosts_AccessApprox Desktop IniFileAptConf Dhcpd InputrcAutomaster Dpkg IptablesAutomounter Exports KdumpBackupPCHosts FAI_DiskConfig Keepalivedcgconfig Fonts Keepalivedcgrules Fuse Login_defsChannels Grub Mke2fs...$ augtool print /augeas//path | wc -l788 OggCamp | 6 | Dominic Cleal
    • augtool lets you inspect the tree$ augtoolaugtool> ls /augeas/ = (none)files/ = (none)augtool> print /files/etc/passwd/root//files/etc/passwd/root/files/etc/passwd/root/password = "x"/files/etc/passwd/root/uid = "0"/files/etc/passwd/root/gid = "0"/files/etc/passwd/root/name = "root"/files/etc/passwd/root/home = "/root"/files/etc/passwd/root/shell = "/bin/bash" OggCamp | 7 | Dominic Cleal
    • The tree can be queried using XPathaugtool> print /files/etc/passwd/*[uid=0][1]/files/etc/passwd/root/files/etc/passwd/root/password = "x"/files/etc/passwd/root/uid = "0"/files/etc/passwd/root/gid = "0"/files/etc/passwd/root/name = "root"/files/etc/passwd/root/home = "/root"/files/etc/passwd/root/shell = "/bin/bash" OggCamp | 8 | Dominic Cleal
    • But also modified$ grep root /etc/fstab/dev/mapper/vgiridium-lvroot / ext4 defaults 1 1$ augtoolaugtool> match /files/etc/fstab/*[file=/]/opt/files/etc/fstab/1/opt = defaultsaugtool> set /files/etc/fstab/*[file=/]/opt noatimeaugtool> match /files/etc/fstab/*[file=/]/opt/files/etc/fstab/1/opt = noatimeaugtool> saveSaved 1 file(s)augtool> exit$ grep root /etc/fstab/dev/mapper/vgiridium-lvroot / ext4 noatime 1 1 OggCamp | 9 | Dominic Cleal
    • Bindings include Perl, Python, Java, PHP, Ruby......OCaml, Haskell, Lua, Vala...#!/usr/bin/env rubyrequire augeasaug = Augeas.open# Print each mountaug.match("/files/etc/fstab/*[file]").each do |m| mount = aug.get("#{m}/file") dev = aug.get("#{m}/spec") puts "#{dev} is mounted at #{mount}"end# Edit / mount optionaug.set("/files/etc/fstab/*[file=/]/opt", "noatime")aug.save! OggCamp | 10 | Dominic Cleal
    • Puppet has a native provideraugeas { export /foo: context => /files/etc/exports, changes => [ "set dir[. = /foo] /foo", "set dir[. = /foo]/client weeble", "set dir[. = /foo]/client/option[1] ro", "set dir[. = /foo]/client/option[2] all_squash", ],}$ cat /etc/exports/foo weeble(ro,all_squash) OggCamp | 11 | Dominic Cleal
    • Other projects using Augeas● libguestfs● virt-tools, e.g. p2v, v2v● NUT● ZYpp● Config::Model● Augeas::Validator OggCamp | 13 | Dominic Cleal
    • Questions? http://augeas.netaugeas-devel@redhat.com freenode: #augeas OggCamp | 14 | Dominic Cleal