Good day,
I am reviewing a type and provider and would like input or help to better understand.
The provider is
require 'puppet/util'
Puppet::Type.type(:winad_group).provide(:powershell) do
confine :operatingsystem => :windows
defaultfor :operatingsystem => :windows
commands :powershell => Puppet::Util::Powershell.getPowershellCommand
The type is
Puppet::Type.newtype(:winad_group) do
Then lastly there is a file /puppet/util/powershell.rb
class Powershell
def self.getPowershellCommand()
if File.exists?("#{ENV['SYSTEMROOT']}\\sysnative\\WindowsPowershell\\v1.0\\powershell.exe")
"#{ENV['SYSTEMROOT']}\\sysnative\\WindowsPowershell\\v1.0\\powershell.exe"
elsif File.exists?("#{ENV['SYSTEMROOT']}\\system32\\WindowsPowershell\\v1.0\\powershell.exe")
"#{ENV['SYSTEMROOT']}\\system32\\WindowsPowershell\\v1.0\\powershell.exe"
else
'powershell.exe'
end
end
end
If i copy the syntax
commands :powershell =>
if File.exist?("#{ENV['SYSTEMROOT']}\\sysnative\\WindowsPowershell\\v1.0\\powershell.exe")
"#{ENV['SYSTEMROOT']}\\sysnative\\WindowsPowershell\\v1.0\\powershell.exe"
elsif File.exist?("#{ENV['SYSTEMROOT']}\\system32\\WindowsPowershell\\v1.0\\powershell.exe")
"#{ENV['SYSTEMROOT']}\\system32\\WindowsPowershell\\v1.0\\powershell.exe"
else
'powershell.exe'
end
Into my provider i am able to run the command correctly, why can i not autoload the powershell.rb file and properly use it across multiple providers?
Thank you for any help.