Uploaded image for project: 'Puppet Task Runner'
  1. Puppet Task Runner
  2. BOLT-202

When running bolt task on a WIndows node without Puppet installed, the error message is very obscure.

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: BOLT 0.6.1
    • Fix Version/s: BOLT 0.8.0
    • Component/s: UX, Windows
    • Labels:
      None
    • Environment:
    • Template:
    • Acceptance Criteria:
      • The error message thrown by bolt should indicate configuration errors and how to correct them
    • Sprint:
      Tasks Kanban
    • Method Found:
      Customer Feedback
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      Hide
      When running a script or task over WinRM, Bolt previously would have failed with an obscure message when the interpreter necessary to execute the file was unavailable. For instance, if unable to find Puppet when running .pp files. Error messaging has been improved.
      Show
      When running a script or task over WinRM, Bolt previously would have failed with an obscure message when the interpreter necessary to execute the file was unavailable. For instance, if unable to find Puppet when running .pp files. Error messaging has been improved.
    • QA Risk Assessment:
      Needs Assessment

      Description

      I was testing a reboot task (https://github.com/puppetlabs/puppetlabs-reboot/pull/139) with bolt and came across what looks like a bad user experience.

      When the target windows node did not have puppet-agent installed running bolt showed this error.

      Ran on 1 node in 0.03 seconds
      C:\Source\puppetlabs-reboot-dylan\reboot [master ≡ +0 ~1 -0 !]> be bolt task run reboot --modules .. --nodes winrm://192.168.200.55 --user Administrator --password Password1
      192.168.200.55:
       
       
      Exception calling "Start" with "1" argument(s): "The system cannot find the file specified"
      At line:11 char:17
      + $LASTEXITCODE = Invoke-Interpreter @invokeArgs
      +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
          + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-Interpreter
       
      Ran on 1 node in 17.21 seconds
      

      What's really confusing is, I gave it a ruby file, but the error is coming from a PowerShell script.

      After running bolt in debug I got:

      C:\Source\puppetlabs-reboot-dylan\reboot [master ≡ +0 ~1 -0 !]> be bolt task run reboot --modules .. --nodes winrm://192.168.200.55 --user Administrator --password Password1 --debug
      Debug: puppetlabs-reboot initialized for i18n: #<FastGettext::TranslationRepository::Po:0x0000000747ff70>
      2017-10-31T10:11:58.631069  DEBUG 192.168.200.55: Opened session
      2017-10-31T10:11:58.631069  INFO 192.168.200.55: Running task 'C:/Source/puppetlabs-reboot-dylan/reboot/tasks/init.rb'
      2017-10-31T10:11:58.632057  DEBUG 192.168.200.55: arguments: {}
      input_method: both
      2017-10-31T10:11:58.632057  DEBUG 192.168.200.55: Executing command: $parent = [System.IO.Path]::GetTempPath()
      $name = [System.IO.Path]::GetRandomFileName()
      $path = Join-Path $parent $name
      New-Item -ItemType Directory -Path $path | Out-Null
      $path
       
      2017-10-31T10:11:58.852077  DEBUG 192.168.200.55: stdout: C:\Users\Administrator\AppData\Local\Temp\mkkcnpdf.pgo
       
      2017-10-31T10:11:58.853095  DEBUG 192.168.200.55: stderr:
      2017-10-31T10:11:58.875075  DEBUG 192.168.200.55: Command returned successfully
      2017-10-31T10:11:58.875075  DEBUG 192.168.200.55: Uploading C:/Source/puppetlabs-reboot-dylan/reboot/tasks/init.rb to C:\Users\Administrator\AppData\Local\Temp\mkkcnpdf.pgo\init.rb
      2017-10-31T10:12:03.184516  DEBUG 192.168.200.55: Executing command:
      $ENV:PATH += ";${ENV:ProgramFiles}\Puppet Labs\Puppet\sys\ruby\bin\"
      $ENV:RUBYLIB = "${ENV:ProgramFiles}\Puppet Labs\Puppet\puppet\lib;" +
        "${ENV:ProgramFiles}\Puppet Labs\Puppet\facter\lib;" +
        "${ENV:ProgramFiles}\Puppet Labs\Puppet\hiera\lib;" +
        $ENV:RUBYLIB
       
      function Invoke-Interpreter
      {
        [CmdletBinding()]
        Param (
          [Parameter()]
          [String]
          $Path,
       
          [Parameter()]
          [String]
          $Arguments,
       
          [Parameter()]
          [Int32]
          $Timeout,
       
          [Parameter()]
          [String]
          $StdinInput = $Null
        )
       
        $startInfo = New-Object System.Diagnostics.ProcessStartInfo($Path, $Arguments)
        $startInfo.UseShellExecute = $false
        if ($StdinInput) { $startInfo.RedirectStandardInput = $true }
        $startInfo.RedirectStandardOutput = $true
        $startInfo.RedirectStandardError = $true
       
        try
        {
          $process = [System.Diagnostics.Process]::Start($startInfo)
        }
        catch
        {
          Write-Error $_
          return 1
        }
       
        if ($StdinInput)
        {
          $process.StandardInput.WriteLine($StdinInput)
          $process.StandardInput.Close()
        }
       
        # streams must have .ReadToEnd() called prior to process .WaitForExit()
        # to prevent deadlocks per MSDN
        # https://msdn.microsoft.com/en-us/library/system.diagnostics.process.standarderror(v=vs.110).aspx#Anchor_2
        $process.StandardOutput.ReadToEnd() | Out-Host
        $stderr = $process.StandardError.ReadToEnd()
        if ($stderr) { Write-Error $stderr }
        $process.WaitForExit($Timeout) | Out-Null
       
        return $process.ExitCode
      }
       
      2017-10-31T10:12:03.326526  DEBUG 192.168.200.55: Command returned successfully
      2017-10-31T10:12:03.326526  DEBUG 192.168.200.55: Executing command: $invokeArgs = @{
        Path = "ruby.exe"
        Arguments = "-S ""C:\Users\Administrator\AppData\Local\Temp\mkkcnpdf.pgo\init.rb"""
        Timeout = 600000
        StdinInput = @'
      {}
      '@
      }
       
      # winrm gem relies on $LASTEXITCODE
      $LASTEXITCODE = Invoke-Interpreter @invokeArgs
       
      2017-10-31T10:12:03.687575  DEBUG 192.168.200.55: stdout:
      2017-10-31T10:12:03.688576  DEBUG 192.168.200.55: stderr: Exception calling "Start" with "1" argument(s): "The system cannot find the file specified"
      At line:11 char:17
      + $LASTEXITCODE = Invoke-Interpreter @invokeArgs
      +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
          + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-Interpreter
       
      2017-10-31T10:12:03.710564  DEBUG 192.168.200.55: Command returned successfully
      2017-10-31T10:12:03.710564  DEBUG 192.168.200.55: Executing command: Remove-Item -Force "C:\Users\Administrator\AppData\Local\Temp\mkkcnpdf.pgo\init.rb"
      Remove-Item -Force "C:\Users\Administrator\AppData\Local\Temp\mkkcnpdf.pgo"
       
      2017-10-31T10:12:03.803586  DEBUG 192.168.200.55: Command returned successfully
      2017-10-31T10:12:03.818581  DEBUG 192.168.200.55: Closed session
      192.168.200.55:
       
       
      Exception calling "Start" with "1" argument(s): "The system cannot find the file specified"
      At line:11 char:17
      + $LASTEXITCODE = Invoke-Interpreter @invokeArgs
      +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
          + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-Interpreter
       
      Ran on 1 node in 16.43 seconds
      

      Clearly I can now see it was trying to run ruby.exe via a PATH search however as I didn't have puppet-agent installed it failed to find it.

      But the fact remains that the error message from bolt is so completely obscure that it could not be used by a "normal" user to figure out what went wrong.

      Also, it would be trivial to add the command detection so bolt could say "Hey, you tried to run this ruby script but puppet-agent isn't installed. You need to install that first" e.g.

      $rubyExe = (Get-Command 'ruby.exe' -ErrorAction SilentlyContinue)
      if ($rubyExe -eq $null) { 
        Throw "Could not find ruby.exe.  Please ensure the node has Puppet Agent installed prior to running this task"
        Return $null
      }
      

        Attachments

          Activity

            jsd-sla-details-panel

              People

              • Assignee:
                Unassigned
                Reporter:
                glenn.sarti Glenn Sarti
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: