diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/facter/ssh_version.rb | 5 | ||||
| -rw-r--r-- | lib/puppet/parser/functions/ssh_keygen.rb | 6 | 
2 files changed, 10 insertions, 1 deletions
diff --git a/lib/facter/ssh_version.rb b/lib/facter/ssh_version.rb new file mode 100644 index 0000000..51d8a00 --- /dev/null +++ b/lib/facter/ssh_version.rb @@ -0,0 +1,5 @@ +Facter.add("ssh_version") do +  setcode do +    ssh_version = Facter::Util::Resolution.exec('ssh -V 2>&1 1>/dev/null').chomp.split(' ')[0].split('_')[1] +  end +end diff --git a/lib/puppet/parser/functions/ssh_keygen.rb b/lib/puppet/parser/functions/ssh_keygen.rb index 597315e..e304f24 100644 --- a/lib/puppet/parser/functions/ssh_keygen.rb +++ b/lib/puppet/parser/functions/ssh_keygen.rb @@ -19,8 +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.execute(['/usr/bin/ssh-keygen','-t', 'rsa', '-b', '4096', '-f', private_key_path, '-P', '', '-q']) +      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 +  | 
