Sha256: 2b49f583b8c2f3119251dd22900469947485a3824c2d87c8bf9c83c2a48d79f9

Contents?: true

Size: 1.77 KB

Versions: 134

Compression:

Stored size: 1.77 KB

Contents

require 'puppet/provider/exec'

Puppet::Type.type(:exec).provide :windows, :parent => Puppet::Provider::Exec do

  confine    :operatingsystem => :windows
  defaultfor :operatingsystem => :windows

  desc <<-'EOT'
    Execute external binaries on Windows systems. As with the `posix`
    provider, this provider directly calls the command with the arguments
    given, without passing it through a shell or performing any interpolation.
    To use shell built-ins --- that is, to emulate the `shell` provider on
    Windows --- a command must explicitly invoke the shell:

        exec {'echo foo':
          command => 'cmd.exe /c echo "foo"',
        }

    If no extension is specified for a command, Windows will use the `PATHEXT`
    environment variable to locate the executable.

    **Note on PowerShell scripts:** PowerShell's default `restricted`
    execution policy doesn't allow it to run saved scripts. To run PowerShell
    scripts, specify the `remotesigned` execution policy as part of the
    command:

        exec { 'test':
          path    => 'C:/Windows/System32/WindowsPowerShell/v1.0',
          command => 'powershell -executionpolicy remotesigned -file C:/test.ps1',
        }

  EOT

  # Verify that we have the executable
  def checkexe(command)
    exe = extractexe(command)

    if absolute_path?(exe)
      if !Puppet::FileSystem.exist?(exe)
        raise ArgumentError, "Could not find command '#{exe}'"
      elsif !File.file?(exe)
        raise ArgumentError, "'#{exe}' is a #{File.ftype(exe)}, not a file"
      end
      return
    end

    if resource[:path]
      Puppet::Util.withenv( {'PATH' => resource[:path].join(File::PATH_SEPARATOR)}, :windows) do
        return if which(exe)
      end
    end

    raise ArgumentError, "Could not find command '#{exe}'"
  end
end

Version data entries

134 entries across 134 versions & 2 rubygems

Version Path
puppet-retrospec-1.8.0 vendor/pup410/lib/puppet/provider/exec/windows.rb
puppet-retrospec-1.7.0 vendor/pup410/lib/puppet/provider/exec/windows.rb
puppet-4.10.12 lib/puppet/provider/exec/windows.rb
puppet-4.10.12-x86-mingw32 lib/puppet/provider/exec/windows.rb
puppet-4.10.12-x64-mingw32 lib/puppet/provider/exec/windows.rb
puppet-4.10.12-universal-darwin lib/puppet/provider/exec/windows.rb
puppet-4.10.11 lib/puppet/provider/exec/windows.rb
puppet-4.10.11-x86-mingw32 lib/puppet/provider/exec/windows.rb
puppet-4.10.11-x64-mingw32 lib/puppet/provider/exec/windows.rb
puppet-4.10.11-universal-darwin lib/puppet/provider/exec/windows.rb
puppet-4.10.10 lib/puppet/provider/exec/windows.rb
puppet-4.10.10-x86-mingw32 lib/puppet/provider/exec/windows.rb
puppet-4.10.10-x64-mingw32 lib/puppet/provider/exec/windows.rb
puppet-4.10.10-universal-darwin lib/puppet/provider/exec/windows.rb
puppet-retrospec-1.6.1 vendor/pup410/lib/puppet/provider/exec/windows.rb
puppet-retrospec-1.6.0 vendor/pup410/lib/puppet/provider/exec/windows.rb
puppet-4.10.9 lib/puppet/provider/exec/windows.rb
puppet-4.10.9-x86-mingw32 lib/puppet/provider/exec/windows.rb
puppet-4.10.9-x64-mingw32 lib/puppet/provider/exec/windows.rb
puppet-4.10.9-universal-darwin lib/puppet/provider/exec/windows.rb