two mounts with the same name (one present, one absent)

114 views
Skip to first unread message

iamauser

unread,
Jan 18, 2013, 1:11:42 PM1/18/13
to puppet...@googlegroups.com
What's the best practice to define two mount resources with same name, but different fstypes or ensure parameter ? In my particular case, I have the following :

Two mounts defined as virtual resources with same name but different fstype. One is is ensuring present, other absent. Puppet doesn't like it,
Looking at a bug report earlier ( http://projects.puppetlabs.com/issues/7491 ), I followed the suggestion, but it doesn't help. puppet throws this error :

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Puppet::Parser::AST::Resource failed with error ArgumentError: Cannot alias Mount[umnt_sdisk_3] to ["/data/01"] at /etc/puppet/modules/mname/manifests/datavers.pp:190; resource ["Mount", "/data/01"] already declared at /etc/puppet/modules/mname/manifests/datavers.pp:162 at /etc/puppet/modules/mname/manifests/datavers.pp:190 on node node_name


  @mount {
      "mnt_sdisk_3" :
        device => "/dev/sdb1",
        name => "/data/01",
        fstype => "auto",
        options => "defaults",
        dump => "0",
        pass => "0",
        ensure => present;
   }
 @mount {
      "umnt_sdisk_3" :
        device => "/dev/sdb1",
        name => "/data/01",
        fstype => "ext3",
        options => "defaults",
        dump => "0",
        pass => "0",
        ensure => absent;
    }

Dan White

unread,
Jan 18, 2013, 1:52:11 PM1/18/13
to puppet...@googlegroups.com
How about declaring a single resource and change the value of the ensure parameter as necessary ?

“Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us.”
Bill Waterson (Calvin & Hobbes)

jcbollinger

unread,
Jan 18, 2013, 2:31:03 PM1/18/13
to puppet...@googlegroups.com


On Friday, January 18, 2013 12:11:42 PM UTC-6, iamauser wrote:
What's the best practice to define two mount resources with same name, but different fstypes or ensure parameter ? In my particular case, I have the following :

Two mounts defined as virtual resources with same name but different fstype. One is is ensuring present, other absent. Puppet doesn't like it,
Looking at a bug report earlier ( http://projects.puppetlabs.com/issues/7491 ), I followed the suggestion, but it doesn't help. puppet throws this error :


You cannot declare multiple configurations of the same resource for the same target node.  This constraint covers all resource declarations equally, including those of virtual and exported resources.  Where it knows how to do so, Puppet intentionally recognizes and blocks attempts to disguise multiple declarations by use of different resource titles (contrary to some of the comments on issue 7491, but imho correctly).

Instead, declare the resource once, and either set its parameters conditionally or override them, where needed, by one of the supported mechanisms for doing so.


John

iamauser

unread,
Jan 18, 2013, 3:00:22 PM1/18/13
to puppet...@googlegroups.com

Two mounts defined as virtual resources with same name but different fstype. One is is ensuring present, other absent. Puppet doesn't like it,
Looking at a bug report earlier ( http://projects.puppetlabs.com/issues/7491 ), I followed the suggestion, but it doesn't help. puppet throws this error :


You cannot declare multiple configurations of the same resource for the same target node.  This constraint covers all resource declarations equally, including those of virtual and exported resources.  Where it knows how to do so, Puppet intentionally recognizes and blocks attempts to disguise multiple declarations by use of different resource titles (contrary to some of the comments on issue 7491, but imho correctly).

 
I agree with your opinion here because the comments on issue 7941 doesn't work. My case is a bit strange though. As you could see, I want to make the same mount "absent" only if the fstype is different from what was defined originally for "present". And both these operation should happen in the same node.

I had tried declaring a single virtual resource and then change the fstype and ensure parameter. It doesn't work as I want. It removes the mount point "/data/01" that was initially present and simply ignores the change in the fstype. See e.g.,

class cl::mount {
 @mount {
      "mnt_sdisk_3" :
        device => "/dev/sdb1",
        name => "/data/01",
        fstype => "auto",
        options => "defaults",
        dump => "0",
        pass => "0",
        ensure => present;
   }
}

class cl::test_mount inherits cl::mount {
    realize(Mount["mnt_sdisk_3"])
    Mount["mnt_sdisk_3"] {
      fstype => "ext3",
      ensure => absent,
    }
}

Notice: /Stage[main]/Cl::Mount/Mount[mnt_sdisk_3]/ensure: current_value mounted, should be absent (noop)


Note that I am testing this on a machine where the change shouldn't happen because there is no "ext3" fstype with name "/data/01" in /etc/fstab.

I guess this is a very special case and probably I have to deal with this by editing fstab using Exec.


Cheers

Dan White

unread,
Jan 18, 2013, 3:44:44 PM1/18/13
to puppet...@googlegroups.com
Let's try re-stating the original problem:

Manage one mount point
File type can be one of multiple types
May or may not actually be mounted.

Instead of a virtual resource, how about a define or parametrized class that takes fstype and mount/don't-mount as input parameters ?


“Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us.”
Bill Waterson (Calvin & Hobbes)


From: "iamauser" <tapas....@gmail.com>
To: puppet...@googlegroups.com
Sent: Friday, January 18, 2013 3:00:22 PM
Subject: [Puppet Users] Re: two mounts with the same name (one present, one absent)
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/qnFIsP5uO4AJ.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Dan White

unread,
Jan 18, 2013, 3:52:33 PM1/18/13
to puppet...@googlegroups.com
Found a clue:

http://docs.puppetlabs.com/references/latest/type.html#mount

ensure
Control what to do with this mount. Set this attribute to umounted to make sure the filesystem is in the filesystem table but not mounted (if the filesystem is currently mounted, it will be unmounted). Set it to absent to unmount (if necessary) and remove the filesystem from the fstab. Set to mounted to add it to the fstab and mount it. Set to present to add to fstab but not change mount/unmount status. Valid values are defined (also called present), unmounted, absent, mounted.

So maybe you want to use mounted/unmounted rather than present/absent !


“Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us.”
Bill Waterson (Calvin & Hobbes)


From: "iamauser" <tapas....@gmail.com>
To: puppet...@googlegroups.com
Sent: Friday, January 18, 2013 3:00:22 PM
Subject: [Puppet Users] Re: two mounts with the same name (one present, one absent)


Aaron Grewell

unread,
Jan 18, 2013, 8:33:19 PM1/18/13
to puppet-users


On Jan 18, 2013 11:31 AM, "jcbollinger" <John.Bo...@stjude.org> wrote:
>
>
>
> On Friday, January 18, 2013 12:11:42 PM UTC-6, iamauser wrote:
>>
>> What's the best practice to define two mount resources with same name, but different fstypes or ensure parameter ? In my particular case, I have the following :
>>
>> Two mounts defined as virtual resources with same name but different fstype. One is is ensuring present, other absent. Puppet doesn't like it,
>> Looking at a bug report earlier ( http://projects.puppetlabs.com/issues/7491 ), I followed the suggestion, but it doesn't help. puppet throws this error :
>

> Instead, declare the resource once, and either set its parameters conditionally or override them, where needed, by one of the supported mechanisms for doing so.
>
>
> John

If I understand correctly the conditional would be based on the current fstype of the mount.  It seems like a custom fact would be needed.

Reply all
Reply to author
Forward
0 new messages