How to manage mounted partitions (fstab + mount points) from puppet
- by Cristian Ciupitu
I want to manage the mounted partitions from puppet which includes both modifying /etc/fstab and creating the directories used as mount points. The mount resource type updates fstab just fine, but using file for creating the mount points is bit tricky.
For example, by default the owner of the directory is root and if the root (/) of the mounted partition has another owner, puppet will try to change it and I don't want this. I know that I can set the owner of that directory, but why should I care what's on the mounted partition? All I want to do is mount it. Is there a way to make puppet not to care about the permissions of the directory used as the mount point?
This is what I'm using right now:
define extra_mount_point(
$device,
$location = "/mnt",
$fstype = "xfs",
$owner = "root",
$group = "root",
$mode = 0755,
$seltype = "public_content_t"
$options = "ro,relatime,nosuid,nodev,noexec",
) {
file { "${location}/${name}":
ensure => directory,
owner => "${owner}",
group => "${group}",
mode => $mode,
seltype => "${seltype}",
}
mount { "${location}/${name}":
atboot => true,
ensure => mounted,
device => "${device}",
fstype => "${fstype}",
options => "${options}",
dump => 0,
pass => 2,
require => File["${location}/${name}"],
}
}
extra_mount_point { "sda3":
device => "/dev/sda3",
fstype => "xfs",
owner => "ciupicri",
group => "ciupicri",
$options = "relatime,nosuid,nodev,noexec",
}
In case it matters, I'm using puppet-0.25.4-1.fc13.noarch.rpm and puppet-server-0.25.4-1.fc13.noarch.rpm.