require 'puppet'

Facter.add('cdh_version') do
    setcode "/usr/bin/hadoop version | head -n 1 | awk -F '-cdh' '{print $2}'"
end

Facter.add('hadoop_version') do
    setcode "/usr/bin/hadoop version | head -n 1 | awk '{print $2}' | awk -F '-cdh' '{print $1}'"
end

Facter.add('hive_version') do
    setcode "/usr/bin/hive -e 'set system:sun.java.command;' 2> /dev/null | awk '{print $2}' | awk -F '-' '{print $3}'"
end

Facter.add('oozie_version') do
    setcode "/usr/bin/oozie admin -version | awk -F ': ' '{print $2}' | awk -F '-' '{print $1}'"
end

require 'puppet'

Facter.add('cdh_version') do
    setcode "/usr/bin/dpkg-query --show hadoop | awk -F '+' '{print $2}'"
end

Facter.add('hadoop_version') do
    setcode "/usr/bin/dpkg-query --show hadoop | awk '{print $2}' | awk -F '+' '{print $1}'"
end

Facter.add('hive_version') do
    setcode "/usr/bin/dpkg-query --show hive | awk '{print $2}' | awk -F '+' '{print $1}'"
end

Facter.add('oozie_version') do
    setcode "/usr/bin/dpkg-query --show oozie | awk '{print $2}' | awk -F '+' '{print $1}'"
end

Use dpkg-query to get cdh version facts
Use dpkg-query to get cdh version facts

Change-Id: Iee5ae02f756d084855ff64dc41b52cbf7a5cc422
