Created
September 10, 2013 16:58
-
-
Save zanloy/6512331 to your computer and use it in GitHub Desktop.
To add a simple noatime to each ext3 mount point in Puppet.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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