Hello all, While we can use generate() to get the output of a command into a puppet manifest, it has limitations. In particular, no subshell is used to run the command, so you can''t use the pipe symbol, "|", to connect two commands together. So how would one go about getting the output of "command1 | command2" into a puppet variable in a manifest? Thanks. John Guthrie jguthrie@limewire.com -- 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.
On Thu, Oct 28, 2010 at 2:06 PM, John T. Guthrie <jguthrie@limewire.com> wrote:> Hello all, > > While we can use generate() to get the output of a command into a puppet > manifest, it has limitations. In particular, no subshell is used to run > the command, so you can''t use the pipe symbol, "|", to connect two > commands together. So how would one go about getting the output of > "command1 | command2" into a puppet variable in a manifest?I use wrapper scripts for this. Then have generate() call the wrapper script. #! /bin/bash # script to be used for generate() function set -e set -u command1 | command2 -- Jeff McCune http://www.puppetlabs.com/ -- 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.
On 10/28/2010 02:26 PM, Jeff McCune wrote:> On Thu, Oct 28, 2010 at 2:06 PM, John T. Guthrie <jguthrie@limewire.com> wrote: > >> Hello all, >> >> While we can use generate() to get the output of a command into a puppet >> manifest, it has limitations. In particular, no subshell is used to run >> the command, so you can''t use the pipe symbol, "|", to connect two >> commands together. So how would one go about getting the output of >> "command1 | command2" into a puppet variable in a manifest? >> > I use wrapper scripts for this. Then have generate() call the wrapper script. > > #! /bin/bash > # script to be used for generate() function > set -e > set -u > command1 | command2 > >I wish I had figured this out earlier. What also seems to work is the following: $my_variable = inline_template("<%= %x{command1 | command2} %>") and this way, there is no need to distribute a file onto the puppetmaster server. (I should note that I do give full path names to both commands to be safe.) Thank you very much for your help. John Guthrie jguthrie@limewire.com -- 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.
On Thu, Oct 28, 2010 at 4:17 PM, John T. Guthrie <jguthrie@limewire.com> wrote:> On 10/28/2010 02:26 PM, Jeff McCune wrote: >> On Thu, Oct 28, 2010 at 2:06 PM, John T. Guthrie <jguthrie@limewire.com> wrote: >> >>> Hello all, >>> >>> While we can use generate() to get the output of a command into a puppet >>> manifest, it has limitations. In particular, no subshell is used to run >>> the command, so you can''t use the pipe symbol, "|", to connect two >>> commands together. So how would one go about getting the output of >>> "command1 | command2" into a puppet variable in a manifest? >>> >> I use wrapper scripts for this. Then have generate() call the wrapper script. >> >> #! /bin/bash >> # script to be used for generate() function >> set -e >> set -u >> command1 | command2 >> >> > I wish I had figured this out earlier. What also seems to work is the > following: > > $my_variable = inline_template("<%= %x{command1 | command2} %>")That''s quite slick. Thanks for following up to the list with the alternative solution to the problem. -- Jeff McCune http://www.puppetlabs.com/ -- 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.