haraldchris@gmail.com
2013-Jul-29 21:26 UTC
[Puppet Users] Augeas, fstab and duplicate lines: How to test ? (onlyif ? not_include ?) ... Examples ?
Hi, I am trying to define a new type that will insert a new filesystem line into /etc/fstab. However, no matter what I tried, it will insert a new line each time. Something like this doesn''t work augeas { $title: context => ''/files/etc/fstab'', changes => [ "set 01/spec $fs_dev", "set 01/file $fs_mount", "set 01/vfstype $fs_type", "set 01/opt $fs_opts", "set 01/dump $fs_dump", "set 01/passno $fs_fsck", "set 01/#comment $fs_comment", ], onlyif => "match */spec[. = $fs_dev] size == 0" # also tried "match *[spec] not_include $fs_dev" } The "not_include" option doesn''t seem to work either ... or maybe I din''t know how to use it (very few examples around to say the least) unless is not available with augeas (I believe) Any suggestions ? (I already know about the available fstab module but I want to understand what is going on here) Many thanks. Cheers. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.
Sneha More
2013-Jul-30 12:58 UTC
[Puppet Users] Re: Augeas, fstab and duplicate lines: How to test ? (onlyif ? not_include ?) ... Examples ?
On Tuesday, July 30, 2013 2:56:59 AM UTC+5:30, haral...@gmail.com wrote:> > Hi, > > I am trying to define a new type that will insert a new filesystem line > into /etc/fstab. > > However, no matter what I tried, it will insert a new line each time. > > Something like this doesn''t work > > augeas { $title: > context => ''/files/etc/fstab'', > changes => [ > "set 01/spec $fs_dev", > "set 01/file $fs_mount", > "set 01/vfstype $fs_type", > "set 01/opt $fs_opts", > "set 01/dump $fs_dump", > "set 01/passno $fs_fsck", > "set 01/#comment $fs_comment", > ], > onlyif => "match */spec[. = $fs_dev] size == 0" # also > tried "match *[spec] not_include $fs_dev" > } > > The "not_include" option doesn''t seem to work either ... or maybe I din''t > know how to use it (very few examples around to say the least) > > unless is not available with augeas (I believe) > > Any suggestions ? > > (I already know about the available fstab module but I want to understand > what is going on here) > > Many thanks. > > Cheers. >Hi, Here your onlyif condition is the cause of inserting a new line each time. you can try this: *onlyif => "match*[spec=$fs_dev] size == 0"* This will match your $fs_dev and will not insert it second time. Regards, Sneha More, NTT DATA GTS, Pune. (OSS Center) -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.
Sneha More
2013-Jul-30 13:54 UTC
Re: [Puppet Users] Re: Augeas, fstab and duplicate lines: How to test ? (onlyif ? not_include ?) ... Examples ?
Hi, The solution which i have given you is nothing but the another form of what you have done. So i think in your case this will not work either. The problem is not with your logic of onlyif condition, its syntactical problem. I found following things while solving your problem: If i use the condition 1. onlyif => "match */spec[. = proc] size == 0" It will insert the line with spec = proc every time in puppet run. 2. if i use the condition: onlyif => "match */spec[. = ''proc''] size == 0" It will insert only once. So answer to your query is --> your varible must be in '''' (single inverted comma) Now try this: *onlyif => "match */spec[. = ''$fs_dev''] size == 0" * This will definitely work. Sorry for creating confusion in previous reply. Regards, Sneha More, NTT DATA GTS, Pune. (OSS Center) On Tue, Jul 30, 2013 at 6:28 PM, Sneha More <snehamore204@gmail.com> wrote:> On Tuesday, July 30, 2013 2:56:59 AM UTC+5:30, haral...@gmail.com wrote: >> >> Hi, >> >> I am trying to define a new type that will insert a new filesystem line >> into /etc/fstab. >> >> However, no matter what I tried, it will insert a new line each time. >> >> Something like this doesn''t work >> >> augeas { $title: >> context => ''/files/etc/fstab'', >> changes => [ >> "set 01/spec $fs_dev", >> "set 01/file $fs_mount", >> "set 01/vfstype $fs_type", >> "set 01/opt $fs_opts", >> "set 01/dump $fs_dump", >> "set 01/passno $fs_fsck", >> "set 01/#comment $fs_comment", >> ], >> onlyif => "match */spec[. = $fs_dev] size == 0" # also >> tried "match *[spec] not_include $fs_dev" >> } >> >> The "not_include" option doesn''t seem to work either ... or maybe I din''t >> know how to use it (very few examples around to say the least) >> >> unless is not available with augeas (I believe) >> >> Any suggestions ? >> >> (I already know about the available fstab module but I want to understand >> what is going on here) >> >> Many thanks. >> >> Cheers. >> > > Hi, > Here your onlyif condition is the cause of inserting a new line each > time. > you can try this: > > *onlyif => "match*[spec=$fs_dev] size == 0"* > > This will match your $fs_dev and will not insert it second time. > > Regards, > Sneha More, > NTT DATA GTS, > Pune. (OSS Center) > > > > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Puppet Users" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/puppet-users/m9LZ-gKvLZ8/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > puppet-users+unsubscribe@googlegroups.com. > To post to this group, send email to puppet-users@googlegroups.com. > Visit this group at http://groups.google.com/group/puppet-users. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.
Kristof Willaert
2013-Jul-30 16:12 UTC
Re: [Puppet Users] Re: Augeas, fstab and duplicate lines: How to test ? (onlyif ? not_include ?) ... Examples ?
Hi, you probably already tested this already, but how about: onlyif => "match *[spec = \"${fs_dev}\"] size == 0" Regards, k ** ** On Tue, Jul 30, 2013 at 3:54 PM, Sneha More <snehamore204@gmail.com> wrote:> Hi, > The solution which i have given you is nothing but the another form of > what you have done. > So i think in your case this will not work either. > The problem is not with your logic of onlyif condition, its syntactical > problem. > I found following things while solving your problem: > If i use the condition > 1. onlyif => "match */spec[. = proc] size == 0" > It will insert the line with spec = proc every time in puppet run. > 2. if i use the condition: > onlyif => "match */spec[. = ''proc''] size == 0" > It will insert only once. > > So answer to your query is --> your varible must be in '''' (single inverted > comma) > Now try this: > *onlyif => "match */spec[. = ''$fs_dev''] size == 0" > * > This will definitely work. > Sorry for creating confusion in previous reply. > > Regards, > Sneha More, > NTT DATA GTS, > Pune. (OSS Center) > > > On Tue, Jul 30, 2013 at 6:28 PM, Sneha More <snehamore204@gmail.com>wrote: > >> On Tuesday, July 30, 2013 2:56:59 AM UTC+5:30, haral...@gmail.com wrote: >>> >>> Hi, >>> >>> I am trying to define a new type that will insert a new filesystem line >>> into /etc/fstab. >>> >>> However, no matter what I tried, it will insert a new line each time. >>> >>> Something like this doesn''t work >>> >>> augeas { $title: >>> context => ''/files/etc/fstab'', >>> changes => [ >>> "set 01/spec $fs_dev", >>> "set 01/file $fs_mount", >>> "set 01/vfstype $fs_type", >>> "set 01/opt $fs_opts", >>> "set 01/dump $fs_dump", >>> "set 01/passno $fs_fsck", >>> "set 01/#comment $fs_comment", >>> ], >>> onlyif => "match */spec[. = $fs_dev] size == 0" # >>> also tried "match *[spec] not_include $fs_dev" >>> } >>> >>> The "not_include" option doesn''t seem to work either ... or maybe I >>> din''t know how to use it (very few examples around to say the least) >>> >>> unless is not available with augeas (I believe) >>> >>> Any suggestions ? >>> >>> (I already know about the available fstab module but I want to >>> understand what is going on here) >>> >>> Many thanks. >>> >>> Cheers. >>> >> >> Hi, >> Here your onlyif condition is the cause of inserting a new line each >> time. >> you can try this: >> >> *onlyif => "match*[spec=$fs_dev] size == 0"* >> >> This will match your $fs_dev and will not insert it second time. >> >> Regards, >> Sneha More, >> NTT DATA GTS, >> Pune. (OSS Center) >> >> >> >> >> -- >> You received this message because you are subscribed to a topic in the >> Google Groups "Puppet Users" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/puppet-users/m9LZ-gKvLZ8/unsubscribe. >> To unsubscribe from this group and all its topics, send an email to >> puppet-users+unsubscribe@googlegroups.com. >> >> To post to this group, send email to puppet-users@googlegroups.com. >> Visit this group at http://groups.google.com/group/puppet-users. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to puppet-users+unsubscribe@googlegroups.com. > To post to this group, send email to puppet-users@googlegroups.com. > Visit this group at http://groups.google.com/group/puppet-users. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.
Sneha More
2013-Jul-31 05:27 UTC
Re: [Puppet Users] Re: Augeas, fstab and duplicate lines: How to test ? (onlyif ? not_include ?) ... Examples ?
On Tue, Jul 30, 2013 at 9:42 PM, Kristof Willaert < kristof.willaert@gmail.com> wrote:> Hi, > > you probably already tested this already, but how about: > > onlyif => "match *[spec = \"${fs_dev}\"] size == 0" > > Regards, > > k > >Hi Kristof, Even your solution : onlyif => "match *[spec = \"${fs_dev}\"] size == 0" will work perfectly. Regards, Sneha More. NTT DATA GTS. (OSS Center) Pune. On Tue, Jul 30, 2013 at 9:42 PM, Kristof Willaert < kristof.willaert@gmail.com> wrote:> Hi, > > you probably already tested this already, but how about: > > onlyif => "match *[spec = \"${fs_dev}\"] size == 0" > > Regards, > > k > ** > ** > > > On Tue, Jul 30, 2013 at 3:54 PM, Sneha More <snehamore204@gmail.com>wrote: > >> Hi, >> The solution which i have given you is nothing but the another form of >> what you have done. >> So i think in your case this will not work either. >> The problem is not with your logic of onlyif condition, its syntactical >> problem. >> I found following things while solving your problem: >> If i use the condition >> 1. onlyif => "match */spec[. = proc] size == 0" >> It will insert the line with spec = proc every time in puppet run. >> 2. if i use the condition: >> onlyif => "match */spec[. = ''proc''] size == 0" >> It will insert only once. >> >> So answer to your query is --> your varible must be in '''' (single >> inverted comma) >> Now try this: >> *onlyif => "match */spec[. = ''$fs_dev''] size == 0" >> * >> This will definitely work. >> Sorry for creating confusion in previous reply. >> >> Regards, >> Sneha More, >> NTT DATA GTS, >> Pune. (OSS Center) >> >> >> On Tue, Jul 30, 2013 at 6:28 PM, Sneha More <snehamore204@gmail.com>wrote: >> >>> On Tuesday, July 30, 2013 2:56:59 AM UTC+5:30, haral...@gmail.com wrote: >>>> >>>> Hi, >>>> >>>> I am trying to define a new type that will insert a new filesystem line >>>> into /etc/fstab. >>>> >>>> However, no matter what I tried, it will insert a new line each time. >>>> >>>> Something like this doesn''t work >>>> >>>> augeas { $title: >>>> context => ''/files/etc/fstab'', >>>> changes => [ >>>> "set 01/spec $fs_dev", >>>> "set 01/file $fs_mount", >>>> "set 01/vfstype $fs_type", >>>> "set 01/opt $fs_opts", >>>> "set 01/dump $fs_dump", >>>> "set 01/passno $fs_fsck", >>>> "set 01/#comment $fs_comment", >>>> ], >>>> onlyif => "match */spec[. = $fs_dev] size == 0" # >>>> also tried "match *[spec] not_include $fs_dev" >>>> } >>>> >>>> The "not_include" option doesn''t seem to work either ... or maybe I >>>> din''t know how to use it (very few examples around to say the least) >>>> >>>> unless is not available with augeas (I believe) >>>> >>>> Any suggestions ? >>>> >>>> (I already know about the available fstab module but I want to >>>> understand what is going on here) >>>> >>>> Many thanks. >>>> >>>> Cheers. >>>> >>> >>> Hi, >>> Here your onlyif condition is the cause of inserting a new line each >>> time. >>> you can try this: >>> >>> *onlyif => "match*[spec=$fs_dev] size == 0"* >>> >>> This will match your $fs_dev and will not insert it second time. >>> >>> Regards, >>> Sneha More, >>> NTT DATA GTS, >>> Pune. (OSS Center) >>> >>> >>> >>> >>> -- >>> You received this message because you are subscribed to a topic in the >>> Google Groups "Puppet Users" group. >>> To unsubscribe from this topic, visit >>> https://groups.google.com/d/topic/puppet-users/m9LZ-gKvLZ8/unsubscribe. >>> To unsubscribe from this group and all its topics, send an email to >>> puppet-users+unsubscribe@googlegroups.com. >>> >>> To post to this group, send email to puppet-users@googlegroups.com. >>> Visit this group at http://groups.google.com/group/puppet-users. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Puppet Users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to puppet-users+unsubscribe@googlegroups.com. >> >> To post to this group, send email to puppet-users@googlegroups.com. >> Visit this group at http://groups.google.com/group/puppet-users. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Puppet Users" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/puppet-users/m9LZ-gKvLZ8/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > puppet-users+unsubscribe@googlegroups.com. > To post to this group, send email to puppet-users@googlegroups.com. > Visit this group at http://groups.google.com/group/puppet-users. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.
jcbollinger
2013-Jul-31 13:58 UTC
[Puppet Users] Re: Augeas, fstab and duplicate lines: How to test ? (onlyif ? not_include ?) ... Examples ?
On Monday, July 29, 2013 4:26:59 PM UTC-5, haral...@gmail.com wrote:> > Hi, > > I am trying to define a new type that will insert a new filesystem line > into /etc/fstab. >This is a large part of what the built-in Mount type is for. Do you need something it does not provide?> > However, no matter what I tried, it will insert a new line each time. > >I can''t really help you with Augeas details, but for what little it''s worth, I don''t see what''s wrong with what you''ve attempted so far. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.
haraldchris@gmail.com
2013-Jul-31 23:57 UTC
[Puppet Users] Re: Augeas, fstab and duplicate lines: How to test ? (onlyif ? not_include ?) ... Examples ?
Many thanks to all for your replies. Yeah, I finally got it. Something like: onlyif => "match */spec[ . = ''$fs_spec'' ] size == 0" for fstab entries and onlyif => "match */spec[ . = ''$fs_spec'' ]/../opt[ . = ''$fs_opt''] size == 0" for handling options Cheers. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.
Ryan Coleman
2013-Aug-01 00:00 UTC
Re: [Puppet Users] Re: Augeas, fstab and duplicate lines: How to test ? (onlyif ? not_include ?) ... Examples ?
On Wed, Jul 31, 2013 at 4:57 PM, <haraldchris@gmail.com> wrote:> Many thanks to all for your replies. > > Yeah, I finally got it. >It looks like I''m too late to really help, but I wanted to offer an alternative. domcleal/augeasproviders on the Forge offers a new provider to the built-in mounttab type that relies on the power of augeas while allowing you to use the Puppet DSL to express the configuration. Here are a few code examples: http://augeasproviders.com/documentation/examples.html#mounttab_provider http://forge.puppetlabs.com/domcleal/augeasproviders Even if you don''t use that module for this, check it out. It also provides a number of awesome resource types like sshd_config and sysctl. Regards, -- Ryan Coleman | Modules & Forge | ryanycoleman on twitter & #puppet IRC -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.
haraldchris@gmail.com
2013-Aug-01 00:06 UTC
[Puppet Users] Re: Augeas, fstab and duplicate lines: How to test ? (onlyif ? not_include ?) ... Examples ?
On Wednesday, July 31, 2013 11:58:47 PM UTC+10, jcbollinger wrote:> This is a large part of what the built-in Mount type is for. Do you need > something it does not provide? > >AFAIK Mount does not provide support for encrypted filesystems (/etc/crypttab) There are some good basic reasons for using encrypted filesystems: - if I have to return a failed disk to factory (warranty) - if it gets stolen - if I need to discard an old disk etc. Cheers, -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.