iamauser
2013-Jan-18 18:11 UTC
[Puppet Users] two mounts with the same name (one present, one absent)
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; } -- 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/-/GT3RbAlL1nIJ. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Dan White
2013-Jan-18 18:52 UTC
Re: [Puppet Users] two mounts with the same name (one present, one absent)
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) -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
jcbollinger
2013-Jan-18 19:31 UTC
[Puppet Users] Re: two mounts with the same name (one present, one absent)
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 -- 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/-/kDHM2JVxoIsJ. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
iamauser
2013-Jan-18 20:00 UTC
[Puppet Users] Re: two mounts with the same name (one present, one absent)
> 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> >-- 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-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Dan White
2013-Jan-18 20:44 UTC
Re: [Puppet Users] Re: two mounts with the same name (one present, one absent)
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) ----- Original Message ----- From: "iamauser" <tapas.sarangi@gmail.com> To: puppet-users@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) <blockquote> 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). </blockquote> 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 <blockquote> </blockquote> -- 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-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Dan White
2013-Jan-18 20:52 UTC
Re: [Puppet Users] Re: two mounts with the same name (one present, one absent)
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) ----- Original Message ----- From: "iamauser" <tapas.sarangi@gmail.com> To: puppet-users@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) <blockquote> 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). </blockquote> 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 <blockquote> </blockquote> -- 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-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Aaron Grewell
2013-Jan-19 01:33 UTC
Re: [Puppet Users] Re: two mounts with the same name (one present, one absent)
On Jan 18, 2013 11:31 AM, "jcbollinger" <John.Bollinger@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 differentfstype. 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 parametersconditionally or override them, where needed, by one of the supported mechanisms for doing so.> > > JohnIf I understand correctly the conditional would be based on the current fstype of the mount. It seems like a custom fact would be needed. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.