Amos Shapira
2013-Jun-23 10:39 UTC
[Puppet Users] Exec onlyif/unless with internal functions instead of external commands?
Hi, A little annoyance about "exec" that bothers me is that there is no way to use "unless"/"onlyif" except with external commands, even if a simple Ruby function could be used to execute the test. e.g. "onlyif => ''test -d /data''" will fork and exec "test" to do a simple stat(2) which can be done with much less overhead with Ruby''s "File.directory?(''/data'')". How about allowing passing a none-string value to Exec''s onlyif/unless attributes, and consider that as the result? If it''s a string then it will be treated as today, otherwise it will be treated as a boolean. I don''t think this will break any backward compatibility since all Exec''s currently expect strings to execute. Cheers, --Amos -- 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.
Michael Dodwell
2013-Jun-24 01:59 UTC
[Puppet Users] Re: Exec onlyif/unless with internal functions instead of external commands?
Take a look at http://docs.puppetlabs.com/guides/custom_functions.html you could write your own fuctions to give you something like this. Puppet hasn''t really been designed to be low overhead (with more of a focus on simplicity) and i think the least of it''s performance problems come from the fact that it uses an external fork for exec checks. On Sunday, June 23, 2013 8:39:57 PM UTC+10, Amos Shapira wrote:> > Hi, > > A little annoyance about "exec" that bothers me is that there is no way to > use "unless"/"onlyif" except with external commands, even if a simple Ruby > function could be used to execute the test. > > e.g. "onlyif => ''test -d /data''" will fork and exec "test" to do a simple > stat(2) which can be done with much less overhead with Ruby''s > "File.directory?(''/data'')". > > How about allowing passing a none-string value to Exec''s onlyif/unless > attributes, and consider that as the result? If it''s a string then it will > be treated as today, otherwise it will be treated as a boolean. > > I don''t think this will break any backward compatibility since all Exec''s > currently expect strings to execute. > > Cheers, > > --Amos > >-- 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.
David Schmitt
2013-Jun-24 05:40 UTC
Re: [Puppet Users] Re: Exec onlyif/unless with internal functions instead of external commands?
Functions are executed on the master, not on the agent, so they won''t do what you need. If you really want to run code on the client it has to be a type/provider. If it is only "test -e", use "File%creates". Regards, David On 24.06.2013 03:59, Michael Dodwell wrote:> Take a look at > http://docs.puppetlabs.com/guides/custom_functions.html you could write > your own fuctions to give you something like this. > > Puppet hasn''t really been designed to be low overhead (with more of a > focus on simplicity) and i think the least of it''s performance problems > come from the fact that it uses an external fork for exec checks. > > On Sunday, June 23, 2013 8:39:57 PM UTC+10, Amos Shapira wrote: > > Hi, > > A little annoyance about "exec" that bothers me is that there is no > way to use "unless"/"onlyif" except with external commands, even if > a simple Ruby function could be used to execute the test. > > e.g. "onlyif => ''test -d /data''" will fork and exec "test" to do a > simple stat(2) which can be done with much less overhead with Ruby''s > "File.directory?(''/data'')". > > How about allowing passing a none-string value to Exec''s > onlyif/unless attributes, and consider that as the result? If it''s a > string then it will be treated as today, otherwise it will be > treated as a boolean. > > I don''t think this will break any backward compatibility since all > Exec''s currently expect strings to execute. > > Cheers, > > --Amos > > -- > 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.
Amos Shapira
2013-Jun-27 02:17 UTC
[Puppet Users] Re: Exec onlyif/unless with internal functions instead of external commands?
Response inline. On Monday, 24 June 2013 11:59:06 UTC+10, Michael Dodwell wrote:> > Take a look at http://docs.puppetlabs.com/guides/custom_functions.html you > could write your own fuctions to give you something like this. > > Thanks Michael.I was hoping to add such a functionality to Puppet.> Puppet hasn''t really been designed to be low overhead (with more of a > focus on simplicity) and i think the least of it''s performance problems > come from the fact that it uses an external fork for exec checks. >I hope that''s not Puppetlabs'' view on performance. Performance and resource optimisation should be up there at the top of the feature list just like security.> On Sunday, June 23, 2013 8:39:57 PM UTC+10, Amos Shapira wrote: >> >> Hi, >> >> A little annoyance about "exec" that bothers me is that there is no way >> to use "unless"/"onlyif" except with external commands, even if a simple >> Ruby function could be used to execute the test. >> >> e.g. "onlyif => ''test -d /data''" will fork and exec "test" to do a simple >> stat(2) which can be done with much less overhead with Ruby''s >> "File.directory?(''/data'')". >> >> How about allowing passing a none-string value to Exec''s onlyif/unless >> attributes, and consider that as the result? If it''s a string then it will >> be treated as today, otherwise it will be treated as a boolean. >> >> I don''t think this will break any backward compatibility since all Exec''s >> currently expect strings to execute. >> >> Cheers, >> >> --Amos >> >>-- 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.
Amos Shapira
2013-Jun-27 02:19 UTC
Re: [Puppet Users] Re: Exec onlyif/unless with internal functions instead of external commands?
On Monday, 24 June 2013 15:40:14 UTC+10, David Schmitt wrote:> Functions are executed on the master, not on the agent, so they won''t do > what you need. >Yes I keep forgetting that.> > If you really want to run code on the client it has to be a type/provider. >I was hoping to get something like to be considered to be built into Puppet.> > If it is only "test -e", use "File%creates". >I know about "creates" parameter, but there are other tests which could be easily done with a ruby function/system-call (e.g. file size, type, content etc).> Regards, David > > On 24.06.2013 03:59, Michael Dodwell wrote: > > Take a look at > > http://docs.puppetlabs.com/guides/custom_functions.html you could write > > your own fuctions to give you something like this. > > > > Puppet hasn''t really been designed to be low overhead (with more of a > > focus on simplicity) and i think the least of it''s performance problems > > come from the fact that it uses an external fork for exec checks. > > > > On Sunday, June 23, 2013 8:39:57 PM UTC+10, Amos Shapira wrote: > > > > Hi, > > > > A little annoyance about "exec" that bothers me is that there is no > > way to use "unless"/"onlyif" except with external commands, even if > > a simple Ruby function could be used to execute the test. > > > > e.g. "onlyif => ''test -d /data''" will fork and exec "test" to do a > > simple stat(2) which can be done with much less overhead with Ruby''s > > "File.directory?(''/data'')". > > > > How about allowing passing a none-string value to Exec''s > > onlyif/unless attributes, and consider that as the result? If it''s a > > string then it will be treated as today, otherwise it will be > > treated as a boolean. > > > > I don''t think this will break any backward compatibility since all > > Exec''s currently expect strings to execute. > > > > Cheers, > > > > --Amos > > > > -- > > 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...@googlegroups.com <javascript:>. > > To post to this group, send email to puppet...@googlegroups.com<javascript:>. > > > 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.