change the ssh_keygen function to use different methods depending on if
its puppet 3 or puppet 2
This commit is contained in:
parent
52fd60c9f6
commit
5c9ce49321
1 changed files with 3 additions and 1 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue