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 a 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.
P.S. undef
works fine for owner, group and permissions, but not for SELinux. If the partitions are already mounted, puppet complains:
puppetd[18052]: Failed to set SELinux context system_u:object_r:public_content_t:s0 on /mnt/sda3
puppetd[18052]: (/File[/mnt/sda3]/seluser) seluser changed 'unconfined_u' to 'system_u'
puppetd[18052]: Failed to set SELinux context unconfined_u:object_r:mnt_t:s0 on /mnt/sda3
puppetd[18052]: (/File[/mnt/sda3]/seltype) seltype changed 'public_content_t' to 'mnt_t'
The permissions of the mounted partition are:
drwxr-xr-x. root root unconfined_u:object_r:public_content_t:s0 /mnt/sda3/
while the permissions of mount point created by puppet are:
drwxr-xr-x. root root system_u:object_r:mnt_t:s0 /mnt/sda3/
P.P.S. I have reported a bug for this strange behavior.