inspec / train

Transport Interface to unify communication over SSH, WinRM, and friends.
Apache License 2.0
119 stars 87 forks source link

Required dependencies for vmware transport not shipped. #693

Closed rlakey closed 2 years ago

rlakey commented 3 years ago

Version:

3.5.2 and also seen in 3.7.2

Environment:

Running from a Windows 10 machine with workstation installed.

Scenario:

Executing profiles that use the vmware transport.

Steps to Reproduce:

Attempt to execute a profile with the vmware transport.

Expected Result:

The profile will execute using the vmware transport.

Actual Result:

The execution fails with an error that the vmware transport cannot load a dependency on the local.rb file which does not seem to be included in workstation or inspec installations in the right locations for the vmware transport.

The vmware transport is in the train-3.5.2 gem while local and the rest are in the train-core-3.5.2 gem. Maybe an issue with using require_relative for local instead of require?

Adding error info:

PS > inspec exec D:\inspec\Profiles\vmware-vsphere-vm-7.0-stig-baseline -t vmware:// --input vmName=**** --show-progress --reporter=cli

Traceback (most recent call last): 16: from D:/inspec/bin/inspec:272:in <main>' 15: from D:/inspec/bin/inspec:272:inload' 14: from D:/inspec/embedded/lib/ruby/gems/2.7.0/gems/inspec-bin-4.37.30/bin/inspec:11:in <top (required)>' 13: from D:/inspec/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.37.30/lib/inspec/base_cli.rb:35:instart' 12: from D:/inspec/embedded/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor/base.rb:485:in start' 11: from D:/inspec/embedded/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor.rb:392:indispatch' 10: from D:/inspec/embedded/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor/invocation.rb:127:in invoke_command' 9: from D:/inspec/embedded/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor/command.rb:27:inrun' 8: from D:/inspec/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.37.30/lib/inspec/cli.rb:282:in exec' 7: from D:/inspec/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.37.30/lib/inspec/cli.rb:282:innew' 6: from D:/inspec/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.37.30/lib/inspec/runner.rb:78:in initialize' 5: from D:/inspec/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.37.30/lib/inspec/runner.rb:86:inconfigure_transport' 4: from D:/inspec/embedded/lib/ruby/gems/2.7.0/gems/inspec-core-4.37.30/lib/inspec/backend.rb:38:in create' 3: from D:/inspec/embedded/lib/ruby/gems/2.7.0/gems/train-3.7.2/lib/train/transports/vmware.rb:16:inconnection' 2: from D:/inspec/embedded/lib/ruby/gems/2.7.0/gems/train-3.7.2/lib/train/transports/vmware.rb:16:in new' 1: from D:/inspec/embedded/lib/ruby/gems/2.7.0/gems/train-3.7.2/lib/train/transports/vmware.rb:37:ininitialize' D:/inspec/embedded/lib/ruby/gems/2.7.0/gems/train-3.7.2/lib/train/transports/vmware.rb:37:in `require_relative': cannot load such file -- D:/inspec/embedded/lib/ruby/gems/2.7.0/gems/train-3.7.2/lib/train/transports/local (LoadError)

rlakey commented 3 years ago

@clintoncwolfe any thoughts?

tas50 commented 3 years ago

If there's a dep we need to add to workstation we can certainly do that, but we want to make sure we don't pull in every dep for train itself since sometimes these deps are quite enormous and get pulled into Chef Infra Client. It causes a lot of packaging problems and blocks us upgrading ruby.

rlakey commented 3 years ago

Yea my original description may not be as accurate now. I didn't realize train was split up into multiple gems. In this case train and train-core and it seems that may be part of the issue traversing to the other gem to find the requirements.

aaronlippold commented 3 years ago

What if we split the VMware transport into a plug-in?

Bialogs commented 3 years ago

@tas50 the issue is not a missing dependency. Seems like this use-case of VMware transport over powershell is not tested since this issue will only arise when running on powershell. This line attempts to load local.rb transport which is not included in the built gem, nor are plugins and errors which local.rb will attempt to include. See the gemspec regex

aaronlippold commented 3 years ago

It also seems like this need to pull in the enhancements for powershell on linux as we did for local as well - if we are poking at code in this area.

Aaron Lippold

@.***

260-255-4779

twitter/aim/yahoo,etc. 'aaronlippold'

On Tue, Sep 7, 2021 at 12:25 PM Kyle @.***> wrote:

@tas50 https://github.com/tas50 the issue is not a missing dependency. Seems like this use-case of VMware transport over powershell is not tested since this issue will only arise when running on powershell. This line https://github.com/inspec/train/blob/main/lib/train/transports/vmware.rb#L37 attempts to load local.rb transport which is not included in the built gem, nor are plugins and errors which local.rb will attempt to include. See the gemspec regex https://github.com/inspec/train/blob/main/train-core.gemspec#L23-L25

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/inspec/train/issues/693#issuecomment-914449301, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALK42GTE6BTYVOGLP6EF5LUAY4HXANCNFSM47BYEMWA .

rlakey commented 3 years ago

One other piece of data I went through the process of setting up Powershell/PowerCLI on Ubuntu 20.04 today to test this and did not have a problem on InSpec 4.26.13 or 4.41.20 so it seems isolated to Windows.

aaronlippold commented 3 years ago

So how do we want to keep this moving forward? Break things into a plugin or some other path?

jorgensoby commented 2 years ago

Any update on this issue? I'm using the below resource pack to run profiles against our vmware enviroment, and inspec can't connect to vCenter on newer versions.

https://github.com/chef-boneyard/inspec-vmware

Vasu1105 commented 2 years ago

@rlakey does this problem occurs even when we use PowerCli on Windows as mentioned here https://github.com/chef-boneyard/inspec-vmware#install-powercli-on-windows-10-2016?

Vasu1105 commented 2 years ago

@jorgensoby Is your problem also the same that you are on Windows and have the PowerCli setup as mentioned in the readme docs of inspec-vmware repo and it's not working for you?

rlakey commented 2 years ago

@rlakey does this problem occurs even when we use PowerCli on Windows as mentioned here https://github.com/chef-boneyard/inspec-vmware#install-powercli-on-windows-10-2016?

Yea PowerCLI was installed from the Powershell gallery with that command. The "Set-PSRepository -Name "PSGallery" -InstallationPolicy "Trusted"" part I've never done but other than trying to use the vmware transport I've never had issues with PowerCLI.