From 6578e0c9188fd41a9c9e066dbd984b79bb8961a3 Mon Sep 17 00:00:00 2001 From: mh Date: Wed, 4 Dec 2013 22:54:44 +0100 Subject: fix deprecation warning 'Puppet::Util.execute is deprecated; please use Puppet::Util::Execution.execute' --- lib/puppet/parser/functions/ssh_keygen.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/puppet/parser/functions') diff --git a/lib/puppet/parser/functions/ssh_keygen.rb b/lib/puppet/parser/functions/ssh_keygen.rb index 597315e..d411a28 100644 --- a/lib/puppet/parser/functions/ssh_keygen.rb +++ b/lib/puppet/parser/functions/ssh_keygen.rb @@ -19,7 +19,9 @@ Puppet::Parser::Functions::newfunction(:ssh_keygen, :type => :rvalue, :doc => FileUtils.mkdir_p(dir, :mode => 0700) end unless [private_key_path,public_key_path].all?{|path| File.exists?(path) } - output = Puppet::Util.execute(['/usr/bin/ssh-keygen','-t', 'rsa', '-b', '4096', '-f', private_key_path, '-P', '', '-q']) + output = Puppet::Util::Execution.execute( + ['/usr/bin/ssh-keygen','-t', 'rsa', '-b', '4096', + '-f', private_key_path, '-P', '\'\'', '-q']) raise Puppet::ParseError, "Something went wrong during key generation! Output: #{output}" unless output.empty? end [File.read(private_key_path),File.read(public_key_path)] -- cgit v1.2.3 From e2c0b37c7ec9aa730c3a219707b9bc00529dbd91 Mon Sep 17 00:00:00 2001 From: mh Date: Wed, 4 Dec 2013 22:57:47 +0100 Subject: no need to have these quotes --- lib/puppet/parser/functions/ssh_keygen.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/puppet/parser/functions') diff --git a/lib/puppet/parser/functions/ssh_keygen.rb b/lib/puppet/parser/functions/ssh_keygen.rb index d411a28..b732b87 100644 --- a/lib/puppet/parser/functions/ssh_keygen.rb +++ b/lib/puppet/parser/functions/ssh_keygen.rb @@ -21,7 +21,7 @@ Puppet::Parser::Functions::newfunction(:ssh_keygen, :type => :rvalue, :doc => unless [private_key_path,public_key_path].all?{|path| File.exists?(path) } output = Puppet::Util::Execution.execute( ['/usr/bin/ssh-keygen','-t', 'rsa', '-b', '4096', - '-f', private_key_path, '-P', '\'\'', '-q']) + '-f', private_key_path, '-P', '', '-q']) raise Puppet::ParseError, "Something went wrong during key generation! Output: #{output}" unless output.empty? end [File.read(private_key_path),File.read(public_key_path)] -- cgit v1.2.3 From 5c9ce49321f4ea5d502eca98d9e9a23bae57b1da Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Thu, 18 Dec 2014 11:50:32 -0500 Subject: change the ssh_keygen function to use different methods depending on if its puppet 3 or puppet 2 --- lib/puppet/parser/functions/ssh_keygen.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/puppet/parser/functions') diff --git a/lib/puppet/parser/functions/ssh_keygen.rb b/lib/puppet/parser/functions/ssh_keygen.rb index b732b87..e304f24 100644 --- a/lib/puppet/parser/functions/ssh_keygen.rb +++ b/lib/puppet/parser/functions/ssh_keygen.rb @@ -19,10 +19,12 @@ Puppet::Parser::Functions::newfunction(:ssh_keygen, :type => :rvalue, :doc => FileUtils.mkdir_p(dir, :mode => 0700) end unless [private_key_path,public_key_path].all?{|path| File.exists?(path) } - output = Puppet::Util::Execution.execute( + executor = (Facter.value(:puppetversion).to_i < 3) ? Puppet::Util : Puppet::Util::Execution + output = executor.execute( ['/usr/bin/ssh-keygen','-t', 'rsa', '-b', '4096', '-f', private_key_path, '-P', '', '-q']) raise Puppet::ParseError, "Something went wrong during key generation! Output: #{output}" unless output.empty? end [File.read(private_key_path),File.read(public_key_path)] end + -- cgit v1.2.3