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

Tasks run on Windows via PCP do not resolve all executable paths correctly

    Details

    • Template:
    • Acceptance Criteria:
      Hide

      Path resolution for programs in PowerShell scripts should match as closely as possible, regardless of the transport used to execute the script.

      Show
      Path resolution for programs in PowerShell scripts should match as closely as possible, regardless of the transport used to execute the script.
    • Team:
      Bolt
    • Method Found:
      Customer Feedback
    • QA Risk Assessment:
      Needs Assessment

      Description

      When a PowerShell task is run on a Windows machine, there are differences in how it resolves paths to some executable files between runs via WinRM and PCP. 

      When running a task that executes the following PowerShell snippet the results are as follows. Notice the path to puppet.bat resolves all the way down to the bat file:
       

      (Get-Command puppet) | Select-object *
      (Get-Command whoami) | Select-object *
      whoami
      

       The result via WinRM:

      HelpUri            : 
      FileVersionInfo    : File:             C:\Program Files\Puppet Labs\Puppet\bin\puppet.bat
                           InternalName:     
                           OriginalFilename: 
                           FileVersion:      
                           FileDescription:  
                           Product:          
                           ProductVersion:   
                           Debug:            False
                           Patched:          False
                           PreRelease:       False
                           PrivateBuild:     False
                           SpecialBuild:     False
                           Language:         
                           
      Path               : C:\Program Files\Puppet Labs\Puppet\bin\puppet.bat
      Extension          : .bat
      Definition         : C:\Program Files\Puppet Labs\Puppet\bin\puppet.bat
      Source             : C:\Program Files\Puppet Labs\Puppet\bin\puppet.bat
      Version            : 0.0.0.0
      Visibility         : Public
      OutputType         : {System.String}
      Name               : puppet.bat
      CommandType        : Application
      ModuleName         : 
      Module             : 
      RemotingCapability : PowerShell
      Parameters         : 
      ParameterSets      : 
       
      HelpUri            : 
      FileVersionInfo    : File:             C:\Windows\system32\whoami.exe
                           InternalName:     whoami.exe
                           OriginalFilename: whoami.exe.mui
                           FileVersion:      10.0.14393.0 (rs1_release.160715-1616)
                           FileDescription:  whoami - displays logged on user information
                           Product:          Microsoft® Windows® Operating System
                           ProductVersion:   10.0.14393.0
                           Debug:            False
                           Patched:          False
                           PreRelease:       False
                           PrivateBuild:     False
                           SpecialBuild:     False
                           Language:         English (United States)
                           
      Path               : C:\Windows\system32\whoami.exe
      Extension          : .exe
      Definition         : C:\Windows\system32\whoami.exe
      Source             : C:\Windows\system32\whoami.exe
      Version            : 10.0.14393.0
      Visibility         : Public
      OutputType         : {System.String}
      Name               : whoami.exe
      CommandType        : Application
      ModuleName         : 
      Module             : 
      RemotingCapability : PowerShell
      Parameters         : 
      ParameterSets      : 
       
      r5oifq86l1517gl\administrator
      

       
      Result via PCP. Notice here that the path to the bat file is not shown. Only the folder it resides in:

      HelpUri            : 
      FileVersionInfo    : File:             C:\Program Files\Puppet 
                           Labs\Puppet\puppet\bin\puppet
                           InternalName:     
                           OriginalFilename: 
                           FileVersion:      
                           FileDescription:  
                           Product:          
                           ProductVersion:   
                           Debug:            False
                           Patched:          False
                           PreRelease:       False
                           PrivateBuild:     False
                           SpecialBuild:     False
                           Language:         
                           
      Path               : C:\Program Files\Puppet Labs\Puppet\puppet\bin\puppet
      Extension          : 
      Definition         : C:\Program Files\Puppet Labs\Puppet\puppet\bin\puppet
      Source             : C:\Program Files\Puppet Labs\Puppet\puppet\bin\puppet
      Version            : 0.0.0.0
      Visibility         : Public
      OutputType         : {System.String}
      Name               : puppet
      CommandType        : Application
      ModuleName         : 
      Module             : 
      RemotingCapability : PowerShell
      Parameters         : 
      ParameterSets      : 
       
      HelpUri            : 
      FileVersionInfo    : File:             C:\Windows\system32\whoami.exe
                           InternalName:     whoami.exe
                           OriginalFilename: whoami.exe.mui
                           FileVersion:      10.0.14393.0 (rs1_release.160715-1616)
                           FileDescription:  whoami - displays logged on user 
                           information
                           Product:          Microsoftr Windowsr Operating System
                           ProductVersion:   10.0.14393.0
                           Debug:            False
                           Patched:          False
                           PreRelease:       False
                           PrivateBuild:     False
                           SpecialBuild:     False
                           Language:         English (United States)
                           
      Path               : C:\Windows\system32\whoami.exe
      Extension          : .exe
      Definition         : C:\Windows\system32\whoami.exe
      Source             : C:\Windows\system32\whoami.exe
      Version            : 10.0.14393.0
      Visibility         : Public
      OutputType         : {System.String}
      Name               : whoami.exe
      CommandType        : Application
      ModuleName         : 
      Module             : 
      RemotingCapability : PowerShell
      Parameters         : 
      ParameterSets      : 
       
      nt authority\system
      

      The effect for the user is that they are unable to run some commands that they would otherwise expect to be able to run from a bolt task if the task is run via PCP.

      The workaround is to invoke the full path to the file to be executed. Something like:

      & 'C:\Program Files\Puppet Labs\Puppet\bin\puppet.bat' agent -t
      

      But this puts the onus on the user to either trust that hard coded paths will work for well known programs, or to do the search for the program beforehand within the task.

        Attachments

          Activity

            jsd-sla-details-panel

              People

              • Assignee:
                Unassigned
                Reporter:
                william.hurt William Hurt
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: