Skip to content

Instantly share code, notes, and snippets.

@zanloy

zanloy/disks.rb

Created Sep 10, 2013
Embed
What would you like to do?
To add a simple noatime to each ext3 mount point in Puppet.
require 'facter'
require 'augeas'
Facter.add('fstab_missing_noatime') do
list = []
Augeas::open do |aug|
aug.match("/files/etc/fstab/*[label()=~regexp('[0-9]+') and vfstype='ext3' and count(opt[.='noatime']) = 0]").each do |match|
list.push(match)
end
end
setcode do
list.join(',')
end
end
class disks {
define fstab_add_noatime( $entry = $title, $value ) {
augeas { "insert noatime for ${entry}":
context => $entry,
changes => [
"ins opt after opt[last()]",
"set opt[last()] 'noatime'",
];
}
}
$disks = split($::fstab_missing_noatime, ',')
fstab_add_noatime {
$disks:
value => 'noatime';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.