Hello there, Just wanted to know if class will be able to have parameters ? Right now i use: define resolver( $options =''rotate'', $nameserver, $search='''',$domain='''',$sortlist=''''){ file{ ''/etc/resolv.conf'': content => template(''/var/puppet/templates/System/etc/resolv.conf''), owner => ''root'', mode => 644, alias => ''resolv.conf'' } } but it feel like a class to but each site as different nameservers so i cannot use a class here. Also i am a bit loss in the erb template to say : if $search is not '''' then print this, else print nothing, right now it allways print a DAM BLANK LINE ;-) anyone knows how to prevent this ? Seems not possible if i look at the doc but who knows with the fast paced enhancements of puppet :) -- Cordialement, Ghislain _______________________________________________ Puppet-users mailing list Puppet-users@madstop.com https://mail.madstop.com/mailman/listinfo/puppet-users
On Thu, Apr 26, 2007 at 12:49:17PM +0200, ADNET Ghislain wrote:> Just wanted to know if class will be able to have parameters ?I think Luke has said in the past that each class, being a singleton, can''t be parameterised easily.> cannot use a class here. Also i am a bit loss in the erb template to say : > > if $search is not '''' then print this, else print nothing, right now it > allways print a DAM BLANK LINE ;-)Surely <%= search %> will do it for you? The <%= construct won''t print a newline after printing the evaluated value of the code inside the tags, so everything should be OK. If you''re doing something like <% print search %>, then (a) you shouldn''t be doing that, since you''ve got ''<%='', and (b) you can use ''-%>'' as the closing tag to suppress the trailing newline on empty lines. - Matt -- "For once, Microsoft wasn''t exaggerating when they named it the ''Jet Engine'' -- your data''s the seagull." -- Chris Adams
> Surely <%= search %> will do it for you? The <%= construct won''t print a > newline after printing the evaluated value of the code inside the tags, so > everything should be OK. If you''re doing something like <% print search %>, > then (a) you shouldn''t be doing that, since you''ve got ''<%='', and (b) you > can use ''-%>'' as the closing tag to suppress the trailing newline on empty > lines. > > - Matt > >well i was symplifying for exemple i have <% if search != '''' %> search <%= search %> <% end %> (in fact there is a loop but lets put it that way ;) ) perhaps it could be <% search =''search ''+ search %><%= search %> ? -- Cordialement, Ghislain _______________________________________________ Puppet-users mailing list Puppet-users@madstop.com https://mail.madstop.com/mailman/listinfo/puppet-users
On Apr 26, 2007, at 5:49 AM, ADNET Ghislain wrote:> Hello there, > > Just wanted to know if class will be able to have parameters ? > > Right now i use: > > define resolver( $options =''rotate'', $nameserver, $search='''', > $domain='''',$sortlist=''''){ > > file{ ''/etc/resolv.conf'': > content => template(''/var/puppet/templates/ > System/etc/resolv.conf''), > owner => ''root'', > mode => 644, > alias => ''resolv.conf'' > } > > } > > > but it feel like a class to but each site as different nameservers > so i cannot use a class here. Also i am a bit loss in the erb > template to say :With the new scoped variables, you should be able to get close enough to what you want. E.g., you could have: class nameservice { $nameserver = "..." ... } class resolver { $nameserver = $nameservice::nameserver file { ''/etc/resolv.conf'': ... } } I expect that''s the closest we''re going to get to class parameters, and it''s probably as close as we need to get. -- I think that all good, right thinking people in this country are sick and tired of being told that all good, right thinking people in this country are fed up with being told that all good, right thinking people in this country are fed up with being sick and tired. I''m certainly not, and I''m sick and tired of being told that I am. -- Monty Python --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com
On Thu, Apr 26, 2007 at 02:42:36PM +0200, ADNET Ghislain wrote:> > >Surely <%= search %> will do it for you? The <%= construct won''t print a > >newline after printing the evaluated value of the code inside the tags, so > >everything should be OK. If you''re doing something like <% print search > >%>, > >then (a) you shouldn''t be doing that, since you''ve got ''<%='', and (b) you > >can use ''-%>'' as the closing tag to suppress the trailing newline on empty > >lines. > > > >- Matt > > > > > well i was symplifying for exemple i have > > <% if search != '''' %> > search <%= search %> > <% end %>Oh, I see. Yes, the ''-%>'' construct is what you want here: <% if search != '''' -%> search <%= search %> <% end -%> Check the ERB docs (or list archives) for an explanation of what ''-%>'' is doing for you there. - Matt -- If Alan Turing was alive today, the homosexuality would be OK but he''d be in trouble for codebreaking. -- Martin Bacon
> Oh, I see. Yes, the ''-%>'' construct is what you want here: > > <% if search != '''' -%> > search <%= search %> > <% end -%> > > Check the ERB docs (or list archives) for an explanation of what ''-%>'' is > doing for you there. > > - Matt > >it works great , thanks ! I have reread the docs of erb: http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/ and i seee nowhere the -%> but i could have missed it. -- Cordialement, Ghislain _______________________________________________ Puppet-users mailing list Puppet-users@madstop.com https://mail.madstop.com/mailman/listinfo/puppet-users