AutoFS Recipe
Assumptions
- The file systems you are mounting via autofs live on a box that is CNAME'd to autofs.$domain
- The file systems are exported under /export
Usage
The autofs_foo class is appropriate for nodes that should be autofs mounting /home
The autofs_bar class is appropriate for nodes that should be autofs mounting /data and /db
Of course, these are silly names for classes. Rename them to something appropriate for your environment.
Recipe
# manage autofs configuration
define autofs_master($mounts) {
package { autofs:
ensure => installed
}
file { "/etc/auto.master":
owner => root,
group => root,
mode => 644,
content => template("services/autofs/auto.master.tpl"),
notify => Service[autofs],
}
service { autofs:
ensure => true,
pattern => "automount",
require => Package[autofs],
}
}
define autofs_mount() {
file { "/etc/auto.$name":
ensure => file,
owner => root,
group => root,
mode => 644,
content => template("services/autofs/auto.mount.tpl"),
notify => Service[autofs],
}
}
class autofs_foo {
$mounts = [ "home" ]
autofs_master { "master": mounts => $mounts }
autofs_mount { $mounts: }
}
class autofs_bar {
$mounts = [ "data" "db" ]
autofs_master { "master": mounts => $mounts }
autofs_mount { $mounts: }
}
Templates
auto.master.tpl
<% mounts.each do |val| -%> /<%= val %> /etc/auto.<%= val %> tcp,nodev,nosuid <% end -%>
auto.mount.tpl
* autofs.<%= domain %>:/export/<%= name %>/&