lib/beaker/dsl/wrappers.rb in beaker-1.21.0 vs lib/beaker/dsl/wrappers.rb in beaker-2.0.0
- old
+ new
@@ -14,23 +14,35 @@
#
# @api dsl
def facter(*args)
options = args.last.is_a?(Hash) ? args.pop : {}
options['ENV'] ||= {}
- options['ENV'] = options['ENV'].merge( Command::DEFAULT_GIT_ENV )
+ options[:cmdexe] = true
Command.new('facter', args, options )
end
# This is hairy and because of legacy code it will take a bit more
# work to disentangle all of the things that are being passed into
# this catchall param.
#
# @api dsl
+ def cfacter(*args)
+ options = args.last.is_a?(Hash) ? args.pop : {}
+ options['ENV'] ||= {}
+ options[:cmdexe] = true
+ Command.new('cfacter', args, options )
+ end
+
+ # This is hairy and because of legacy code it will take a bit more
+ # work to disentangle all of the things that are being passed into
+ # this catchall param.
+ #
+ # @api dsl
def hiera(*args)
options = args.last.is_a?(Hash) ? args.pop : {}
options['ENV'] ||= {}
- options['ENV'] = options['ENV'].merge( Command::DEFAULT_GIT_ENV )
+ options[:cmdexe] = true
Command.new('hiera', args, options )
end
# @param [String] command_string A string of to be interpolated
# within the context of a host in
@@ -47,11 +59,11 @@
#
# @api dsl
def puppet(*args)
options = args.last.is_a?(Hash) ? args.pop : {}
options['ENV'] ||= {}
- options['ENV'] = options['ENV'].merge( Command::DEFAULT_GIT_ENV )
+ options[:cmdexe] = true
# we assume that an invocation with `puppet()` will have it's first argument
# a face or sub command
cmd = "puppet #{args.shift}"
Command.new( cmd, args, options )
end
@@ -92,9 +104,35 @@
end
# @!visibility private
def puppet_filebucket(*args)
puppet( 'filebucket', *args )
+ end
+
+ # Returns a {Beaker::Command} object for executing powershell commands on a host
+ #
+ # @param [String] command The powershell command to execute
+ # @param [Hash] args The commandline paramaeters to be passed to powershell
+ #
+ # @example Setting the contents of a file
+ # powershell("Set-Content -path 'fu.txt' -value 'fu'")
+ #
+ # @example Using an alternative execution policy
+ # powershell("Set-Content -path 'fu.txt' -value 'fu'", {'ExecutionPolicy' => 'Unrestricted'})
+ #
+ # @return [Command]
+ def powershell(command, args={})
+ ps_opts = {
+ 'ExecutionPolicy' => 'Bypass',
+ 'InputFormat' => 'None',
+ 'NoLogo' => '',
+ 'NoProfile' => '',
+ 'NonInteractive' => ''
+ }
+ ps_opts.merge!(args)
+
+ arguments = " #{ps_opts.sort.map{|k,v| v.eql?('') ? "-#{k}" : "-#{k} #{v}" }.join(' ')} -Command \"#{command}\""
+ Command.new('powershell.exe', arguments, {})
end
end
end
end