vicki
2012-Apr-05 19:06 UTC
[Puppet Users] newly added ruby function executes on the server instead of the node
Hi, 1) I added this test function tom my /etc/puppet/modules/write_line_to_file/lib/puppet/parser/functions/write_line_to_file.rb : *module Puppet::Parser::Functions newfunction(:write_line_to_file) do |args| filename = args[0] str = args[1] File.open(args[0], ''a'') {|fd| fd.puts str } end end* 2) I invoked it in the /etc/puppet/modules/write_line_to_file/manifest/init.pp like this: *class write_line_to_file{ write_line_to_file(''/tmp/some_file'', "Hello world!") }* 3) And I also included this module into my /etc/puppet/manifests/nodes.pp under the correct node: *node default {} node ''testnode.domain.com'' { include hosts include uninstall_screen include write_line_to_file }* * *The function does execute, but on the puppetmaster - not on the remote node. Other two functions execute on the correct node. What am I missing? Thank you! Vicki -- 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/-/2-Z1S6Xci2IJ. 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.
Nan Liu
2012-Apr-05 19:14 UTC
Re: [Puppet Users] newly added ruby function executes on the server instead of the node
On Thu, Apr 5, 2012 at 7:06 PM, vicki <vickikozel@gmail.com> wrote:> Hi, > 1) I added this test function tom my > /etc/puppet/modules/write_line_to_file/lib/puppet/parser/functions/write_line_to_file.rb > : > > module Puppet::Parser::Functions newfunction(:write_line_to_file) do |args| > filename = args[0] > str = args[1] > File.open(args[0], ''a'') {|fd| fd.puts str } > end > end > > 2) I invoked it in the > /etc/puppet/modules/write_line_to_file/manifest/init.pp like this: > > class write_line_to_file{ > write_line_to_file(''/tmp/some_file'', "Hello world!") > } > > 3) And I also included this module into my /etc/puppet/manifests/nodes.pp > under the correct node: > node default {} > node ''testnode.domain.com'' > { > include hosts > include uninstall_screen > include write_line_to_file > } > > The function does execute, but on the puppetmaster - not on the remote node. > Other two functions execute on the correct node. What am I missing?Functions run on puppet master, facts and resource provider run on puppet agent. Writing functions won''t allow you to change puppet agent files (unless you clone module and run puppet apply). If you are trying to write line to a file either use augeas type or puppet file_line from stdlib: http://forge.puppetlabs.com/puppetlabs/stdlib HTH, Nan -- 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.
Christopher Wood
2012-Apr-05 19:18 UTC
Re: [Puppet Users] newly added ruby function executes on the server instead of the node
On Thu, Apr 05, 2012 at 07:14:10PM +0000, Nan Liu wrote:> On Thu, Apr 5, 2012 at 7:06 PM, vicki <vickikozel@gmail.com> wrote: > > Hi, > > 1) I added this test function tom my > > /etc/puppet/modules/write_line_to_file/lib/puppet/parser/functions/write_line_to_file.rb > > : > > > > module Puppet::Parser::Functions newfunction(:write_line_to_file) do |args| > > filename = args[0] > > str = args[1] > > File.open(args[0], ''a'') {|fd| fd.puts str } > > end > > end > > > > 2) I invoked it in the > > /etc/puppet/modules/write_line_to_file/manifest/init.pp like this: > > > > class write_line_to_file{ > > write_line_to_file(''/tmp/some_file'', "Hello world!") > > } > > > > 3) And I also included this module into my /etc/puppet/manifests/nodes.pp > > under the correct node: > > node default {} > > node ''testnode.domain.com'' > > { > > include hosts > > include uninstall_screen > > include write_line_to_file > > } > > > > The function does execute, but on the puppetmaster - not on the remote node. > > Other two functions execute on the correct node. What am I missing? > > Functions run on puppet master, facts and resource provider run on > puppet agent. Writing functions won''t allow you to change puppet agent > files (unless you clone module and run puppet apply). If you are > trying to write line to a file either use augeas type or puppet > file_line from stdlib: > > http://forge.puppetlabs.com/puppetlabs/stdlibFor more complicated things than a single line in a file (like RedHat- style network configs), I''ve had success with using a template to emit YAML and then having a puppetized script on the node execute to complete the configuration. It''s a half-decent way of puppetizing an arbitrary number of files at once.> HTH, > > Nan > > -- > 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. > >-- 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.
vicki
2012-Apr-05 19:27 UTC
[Puppet Users] Re: newly added ruby function executes on the server instead of the node
Thank you for the quick reply! This explains the the behavior I see. On Thursday, April 5, 2012 12:06:00 PM UTC-7, vicki wrote:> > Hi, > 1) I added this test function tom my > /etc/puppet/modules/write_line_to_file/lib/puppet/parser/functions/write_line_to_file.rb > : > > *module Puppet::Parser::Functions newfunction(:write_line_to_file) do > |args| > filename = args[0] > str = args[1] > File.open(args[0], ''a'') {|fd| fd.puts str } > end > end* > > 2) I invoked it in the > /etc/puppet/modules/write_line_to_file/manifest/init.pp like this: > > *class write_line_to_file{ > write_line_to_file(''/tmp/some_file'', "Hello world!") > }* > > 3) And I also included this module into my /etc/puppet/manifests/nodes.pp > under the correct node: > *node default {} > node ''testnode.domain.com'' > { > include hosts > include uninstall_screen > include write_line_to_file > }* > * > *The function does execute, but on the puppetmaster - not on the remote > node. Other two functions execute on the correct node. What am I missing? > > Thank you! > Vicki > >On Thursday, April 5, 2012 12:06:00 PM UTC-7, vicki wrote:> > Hi, > 1) I added this test function tom my > /etc/puppet/modules/write_line_to_file/lib/puppet/parser/functions/write_line_to_file.rb > : > > *module Puppet::Parser::Functions newfunction(:write_line_to_file) do > |args| > filename = args[0] > str = args[1] > File.open(args[0], ''a'') {|fd| fd.puts str } > end > end* > > 2) I invoked it in the > /etc/puppet/modules/write_line_to_file/manifest/init.pp like this: > > *class write_line_to_file{ > write_line_to_file(''/tmp/some_file'', "Hello world!") > }* > > 3) And I also included this module into my /etc/puppet/manifests/nodes.pp > under the correct node: > *node default {} > node ''testnode.domain.com'' > { > include hosts > include uninstall_screen > include write_line_to_file > }* > * > *The function does execute, but on the puppetmaster - not on the remote > node. Other two functions execute on the correct node. What am I missing? > > Thank you! > Vicki > >On Thursday, April 5, 2012 12:06:00 PM UTC-7, vicki wrote:> > Hi, > 1) I added this test function tom my > /etc/puppet/modules/write_line_to_file/lib/puppet/parser/functions/write_line_to_file.rb > : > > *module Puppet::Parser::Functions newfunction(:write_line_to_file) do > |args| > filename = args[0] > str = args[1] > File.open(args[0], ''a'') {|fd| fd.puts str } > end > end* > > 2) I invoked it in the > /etc/puppet/modules/write_line_to_file/manifest/init.pp like this: > > *class write_line_to_file{ > write_line_to_file(''/tmp/some_file'', "Hello world!") > }* > > 3) And I also included this module into my /etc/puppet/manifests/nodes.pp > under the correct node: > *node default {} > node ''testnode.domain.com'' > { > include hosts > include uninstall_screen > include write_line_to_file > }* > * > *The function does execute, but on the puppetmaster - not on the remote > node. Other two functions execute on the correct node. What am I missing? > > Thank you! > Vicki > >On Thursday, April 5, 2012 12:06:00 PM UTC-7, vicki wrote:> > Hi, > 1) I added this test function tom my > /etc/puppet/modules/write_line_to_file/lib/puppet/parser/functions/write_line_to_file.rb > : > > *module Puppet::Parser::Functions newfunction(:write_line_to_file) do > |args| > filename = args[0] > str = args[1] > File.open(args[0], ''a'') {|fd| fd.puts str } > end > end* > > 2) I invoked it in the > /etc/puppet/modules/write_line_to_file/manifest/init.pp like this: > > *class write_line_to_file{ > write_line_to_file(''/tmp/some_file'', "Hello world!") > }* > > 3) And I also included this module into my /etc/puppet/manifests/nodes.pp > under the correct node: > *node default {} > node ''testnode.domain.com'' > { > include hosts > include uninstall_screen > include write_line_to_file > }* > * > *The function does execute, but on the puppetmaster - not on the remote > node. Other two functions execute on the correct node. What am I missing? > > Thank you! > Vicki > >On Thursday, April 5, 2012 12:06:00 PM UTC-7, vicki wrote:> > Hi, > 1) I added this test function tom my > /etc/puppet/modules/write_line_to_file/lib/puppet/parser/functions/write_line_to_file.rb > : > > *module Puppet::Parser::Functions newfunction(:write_line_to_file) do > |args| > filename = args[0] > str = args[1] > File.open(args[0], ''a'') {|fd| fd.puts str } > end > end* > > 2) I invoked it in the > /etc/puppet/modules/write_line_to_file/manifest/init.pp like this: > > *class write_line_to_file{ > write_line_to_file(''/tmp/some_file'', "Hello world!") > }* > > 3) And I also included this module into my /etc/puppet/manifests/nodes.pp > under the correct node: > *node default {} > node ''testnode.domain.com'' > { > include hosts > include uninstall_screen > include write_line_to_file > }* > * > *The function does execute, but on the puppetmaster - not on the remote > node. Other two functions execute on the correct node. What am I missing? > > Thank you! > Vicki > >On Thursday, April 5, 2012 12:06:00 PM UTC-7, vicki wrote:> > Hi, > 1) I added this test function tom my > /etc/puppet/modules/write_line_to_file/lib/puppet/parser/functions/write_line_to_file.rb > : > > *module Puppet::Parser::Functions newfunction(:write_line_to_file) do > |args| > filename = args[0] > str = args[1] > File.open(args[0], ''a'') {|fd| fd.puts str } > end > end* > > 2) I invoked it in the > /etc/puppet/modules/write_line_to_file/manifest/init.pp like this: > > *class write_line_to_file{ > write_line_to_file(''/tmp/some_file'', "Hello world!") > }* > > 3) And I also included this module into my /etc/puppet/manifests/nodes.pp > under the correct node: > *node default {} > node ''testnode.domain.com'' > { > include hosts > include uninstall_screen > include write_line_to_file > }* > * > *The function does execute, but on the puppetmaster - not on the remote > node. Other two functions execute on the correct node. What am I missing? > > Thank you! > Vicki > >On Thursday, April 5, 2012 12:06:00 PM UTC-7, vicki wrote:> > Hi, > 1) I added this test function tom my > /etc/puppet/modules/write_line_to_file/lib/puppet/parser/functions/write_line_to_file.rb > : > > *module Puppet::Parser::Functions newfunction(:write_line_to_file) do > |args| > filename = args[0] > str = args[1] > File.open(args[0], ''a'') {|fd| fd.puts str } > end > end* > > 2) I invoked it in the > /etc/puppet/modules/write_line_to_file/manifest/init.pp like this: > > *class write_line_to_file{ > write_line_to_file(''/tmp/some_file'', "Hello world!") > }* > > 3) And I also included this module into my /etc/puppet/manifests/nodes.pp > under the correct node: > *node default {} > node ''testnode.domain.com'' > { > include hosts > include uninstall_screen > include write_line_to_file > }* > * > *The function does execute, but on the puppetmaster - not on the remote > node. Other two functions execute on the correct node. What am I missing? > > Thank you! > Vicki > >On Thursday, April 5, 2012 12:06:00 PM UTC-7, vicki wrote:> > Hi, > 1) I added this test function tom my > /etc/puppet/modules/write_line_to_file/lib/puppet/parser/functions/write_line_to_file.rb > : > > *module Puppet::Parser::Functions newfunction(:write_line_to_file) do > |args| > filename = args[0] > str = args[1] > File.open(args[0], ''a'') {|fd| fd.puts str } > end > end* > > 2) I invoked it in the > /etc/puppet/modules/write_line_to_file/manifest/init.pp like this: > > *class write_line_to_file{ > write_line_to_file(''/tmp/some_file'', "Hello world!") > }* > > 3) And I also included this module into my /etc/puppet/manifests/nodes.pp > under the correct node: > *node default {} > node ''testnode.domain.com'' > { > include hosts > include uninstall_screen > include write_line_to_file > }* > * > *The function does execute, but on the puppetmaster - not on the remote > node. Other two functions execute on the correct node. What am I missing? > > Thank you! > Vicki > >-- 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/-/QIaIYgvZ3WsJ. 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.