> On May 24, 2017, at 10:02 PM, ggun <gaurav.gun...@gmail.com> wrote: > > Hi Experts, > > Need your kind help in command to execute in the puppet provider. Below is > the code snippet of the puppet provider code. > If I run the code with changes as below the code runs without any issue > > cmd="yes | #{create_ssm} create --fs '#{@resource[:fs_type]}' -p > '#{@resource[:volume_group]}' -n '#{@resource[:logical_volume]}' > '#{@resource[:mount_point]}'" > system(cmd)
There are any number of bits of software that call themselves ssm. Assuming this is system storage manager why don’t you pass -f to make it non-interactive? commands => :ssm => ‘/usr/bin/ssm’ args=%W[-f create --fs @resource[:fs_type] -p @resource[:volume_group] -n @resource[:logical_volume] @resource[:mount_point]] ssm(*args) If that isn’t an option you could pass a file containing ‘yes’ cmd=%W[ssm create --fs @resource[:fs_type] -p @resource[:volume_group] -n @resource[:logical_volume] @resource[:mount_point]] Puppet::Util::Execution.execute(cmd, :stdinfile => ‘/path/to/yes-file’) > > But when I run code as below > system('yes | ssm(*args)') # I am building args based on input and ssm > is the commands as shown in below code snippet > puppet run fails with error as > Error > sh: -c: line 0: syntax error near unexpected token `*args' > sh: -c: line 0: `yes | ssm(*args)' > > Please help can I fix above run. > > > Code Snippets > > commands :ssm => '/usr/bin/ssm', > > def create > puts "Creating FileSystem” > args = ['create'] > if @resource[:fs_type] > args.push('--fs', @resource[:fs_type]) > else > args.push('--fs', 'xfs') > end > if @resource[:volume_group] > args.push('-p', @resource[:volume_group]) > else > puts "Default volume group will be creted and user needs to manage it" > end > if @resource[:logical_volume] > args.push('-n', @resource[:logical_volume]) > else > puts "Default logical volume will be creted and user needs to manage it" > end > if @resource[:device] > args << @resource[:device] > end > if @resource[:mount_point] > FileUtils.mkdir_p(@resource[:mount_point]) unless > File.exists?(@resource[:mount_point]) > args << @resource[:mount_point] > end > p args > # p cmd > system('yes | ssm(*args)’) You really shouldn’t do that. Your invocation is off. The system call is not using you definition of ssm above it’s just finding it on the path and you need to expand your args system takes a string. args=%w(this is s a test) [5] pry(main)> system("yes | echo #{args.join(' ')}") this is s a test > rescue Puppet::ExecutionFailure => detail > raise Puppet::Error, "Could not create filesystem, volume group,and > logical group. Due to error:(#{detail.message})" > > end > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Developers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to puppet-dev+unsubscr...@googlegroups.com > <mailto:puppet-dev+unsubscr...@googlegroups.com>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/puppet-dev/6b4548f5-df77-45b8-b6de-849c6ba6144d%40googlegroups.com > > <https://groups.google.com/d/msgid/puppet-dev/6b4548f5-df77-45b8-b6de-849c6ba6144d%40googlegroups.com?utm_medium=email&utm_source=footer>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/C4B5BCC2-32BA-420D-A717-17D911B4A3AB%40oracle.com. For more options, visit https://groups.google.com/d/optout.