Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

3 Answers 3

up vote 7 down vote accepted

You can tell Puppet not to manage a given metaparameter by setting it to undef.

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

In this event, if the directory doesn't exist before mounting, it will be created as the user and group which puppetd was started as (presumably root:wheel) and with a default umask. Puppet won't care about what these are set to at the time of creation or on any subsequent runs.


Alternatively, if you wanted to trade a little complexity for assurance, you could use a custom fact to determine what the active mounts are and a switch statement to set the directory permissions depending on whether it is pre- or post- mounted.

share|improve this answer
    
undef did the trick. The directories are created with the following permission rwxr-xr-x. root root system_u:object_r:mnt_t:s0 which is fine with me. –  Cristian Ciupitu May 27 '10 at 22:39
1  
Please add selrange => undef, selrole => undef, seltype => undef, seluser => undef, to the answer. –  Cristian Ciupitu May 27 '10 at 23:07
    
Wouldn't there be a risk to puppet trying to manage the root of the filesystem with "ensure => mounted"? –  user191178 Sep 23 '13 at 21:30

Not really an answer but this has been fixed in puppet 2.6.7: http://projects.puppetlabs.com/issues/3999

share|improve this answer
    
Yes, you're right, I somehow forgot about this question. Thank you! –  Cristian Ciupitu Nov 5 '11 at 13:24

I have a custom fact (works with Linux only ATM) that will return all the currently mounted local mounts on a system. It's horribly simple, but works for me -- looks like you might find some use for it as well. Anyway, I threw it up on github: https://github.com/justintime/puppet/tree/master/justintime-localmounts

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.