如何从木偶pipe理挂载的分区(fstab +挂载点)

我想从puppetpipe理安装的分区,其中包括修改/etc/fstab和创build用作挂载点的目录。 mount资源types更新fstab就好了,但使用file来创build挂载点有点棘手。

例如,默认情况下,目录的所有者是root ,如果挂载的分区的根目录(/)有另一个所有者,puppet将尝试更改它,我不想要这个。 我知道我可以设置该目录的所有者,但为什么我应该关心挂载的分区上的内容? 我想要做的就是挂载它。 有没有办法让木偶不关心用作挂载点的目录的权限?

这就是我现在使用的:

 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", } 

万一它很重要,我使用puppet-0.25.4-1.fc13.noarch.rpm和puppet-server-0.25.4-1.fc13.noarch.rpm。


PS的undef适用于所有者,组和权限,但不适用于SELinux。 如果分区已经安装,木偶抱怨:

 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' 

挂载的分区的权限是:

 drwxr-xr-x. root root unconfined_u:object_r:public_content_t:s0 /mnt/sda3/ 

而puppet创build的挂载点的权限是:

  drwxr-xr-x. root root system_u:object_r:mnt_t:s0 /mnt/sda3/ 

PPS我已经报告了这个奇怪的行为的错误 。

你可以告诉Puppet不要pipe理给定的元参数,通过设置为undef

 file { "${location}/${name}": ensure => directory, owner => undef, group => undef, mode => undef, selinux_ignore_defaults => true, } 

在这种情况下,如果目录在挂载之前不存在,它将被创build为puppetd启动的用户和组(可能是root:wheel),并使用默认的umask。 木偶不会在创build时或后续运行时关心这些设置。


或者,如果您想要保证一点复杂性,则可以使用自定义事实来确定活动挂载的内容,并根据是否挂载前置或后置来设置目录权限。

不是一个真正的答案,但这已被固定在木偶2.6.7: http : //projects.puppetlabs.com/issues/3999

我有一个自定义的事实(只适用于Linux的ATM),将返回系统上当前所有本地挂载。 这非常简单,但适合我 – 看起来你可能会发现它的一些用途。 无论如何,我扔在github: https : //github.com/justintime/puppet/tree/master/justintime-localmounts