From c69e455e9b51055067c258b4c6d574a0a2dbdb7e Mon Sep 17 00:00:00 2001 From: Garrett Honeycutt Date: Wed, 7 Oct 2015 14:04:57 -0400 Subject: [PATCH] WIP - Add facts for ssh version Contains two facts, ssh_version and ssh_version_numeric. Examples: ssh_version = 'OpenSSH_6.2p2' ssh_version_numeric = '6.2' --- lib/facter/ssh.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 lib/facter/ssh.rb diff --git a/lib/facter/ssh.rb b/lib/facter/ssh.rb new file mode 100644 index 0000000..ef51e24 --- /dev/null +++ b/lib/facter/ssh.rb @@ -0,0 +1,16 @@ +Facter.add('ssh_version') do + setcode do + if Facter::Util::Resolution.which('ssh') + Facter::Util::Resolution.exec('ssh -V 2>&1').match(/^[A-Za-z0-9._]+/)[0] + end + end +end + +Facter.add('ssh_version_numeric') do + setcode do + ssh_version = Facter.value(:ssh_version) + if ssh_version + ssh_version.match(/\d+\.\d+/)[0] + end + end +end