Ruby list all files within a UNC path via WinRM - ruby

I am attempting to execute a ruby script via WinRM
ruby "R:\Scripts\testDir.rb"
that contains the following code:
Dir.foreach("\\\\FileServer\\TestDir\\") { |x|
puts "Found #{x}"
}
I have no problems executing the script locally on the server, but it fails with the following Permission Denied error via WinRM:
ruby : R:/Scripts/testDir.rb:1:in `open': Permission denied # dir_initialize - \\FileServer\TestDir\ (Errno::EACCES)
+ CategoryInfo : NotSpecified: (R:/Scripts...(Errno::EACCES):String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
from R:/Scripts/testDir.rb:1:in `foreach'
from R:/Scripts/testDir.rb:1:in `<main>'
When running the script locally, I get the following output.
Found .
Found ..
Found test.txt
Found test.tar.xz
My guess is that my script is failing because of the . and .. returned values being passed through WinRM, but I am not sure why.

The issue I was having was caused by double-hopping. The command I was running to execute the ruby script was from my local machine via WinRm.

Related

Ansible (2.11 +) error with winrm when path invalid in environment variable (win_stat task)

we have an Ansible script to deploy software on Windows. One of the task if to check the existence of a folder with win_stat command.
However, om some servers, the task throws an error when a path that doesn't exist is defined in the 'LIB' environment variable on the windows server (the path has nothing to do with what we check)
I'm able to reproduce with a dead simple script:
- hosts: all
gather_facts: no
tasks:
- name: Check addon folder
win_stat:
path: 'C:\temp\'
and the error is (with verbose):
The full traceback is:
(0) : Warning as Error: Invalid search path 'System.Collections.DictionaryEntry' specified in 'LIB environment variable' -- 'The system cannot find the path specified. '
(1) : using Microsoft.Win32.SafeHandles;
At line:408 char:5
+ Add-Type -TypeDefinition $link_util
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (Microsoft.Power...peCompilerError:AddTypeCompilerError) [Add-Type], Exception
+ FullyQualifiedErrorId : SOURCE_CODE_ERROR,Microsoft.PowerShell.Commands.AddTypeCommand
ScriptStackTrace:
at Load-LinkUtils, <No file>: line 408
at <ScriptBlock>, <No file>: line 76
fatal: [IADCMP019]: FAILED! => {
"changed": false,
"msg": "Unhandled exception while executing module: (0) : Warning as Error: Invalid search path 'System.Collections.DictionaryEntry' specified in 'LIB environment variable' -- 'The system cannot find the path specified. '\n\n(1) : using Microsoft.Win32.SafeHandles;\n"
}
Problems happens with 2.11.6 and 2.11.4 of Ansible core, but not with 2.10 (at least 2.10.9)
I'm wondering if it's a new check in 2.11 or if it's something I should open a bug report about.
EDIT1: changed 'c:' to 'c:\temp' as the win_stat command is long on the former, much faster on the later
I wasn't looking in the right repository for this. The bug is already opened, on ansible.windows collection : https://github.com/ansible-collections/ansible.windows/issues/297

Quarkus " Running the application" Tutorial

I try to follow the tutorial for the First Application of Quarkus.
When I try to run this command: ./mvnw compile quarkus:dev:
I've the following error:
The specified path could not be found. "D" is not recognized as an
internal or external command, an executable program or a batch file.
The specified path could not be found.
Exception during "DownloadFile" call with "2" argument (s): "Exception during a WebClient request." In line: 1 car: 282
... pe] :: Tls12; $ webclient.DownloadFile ('https://repo.maven.apache.org/ma ...
CategoryInfo: NotSpecified: (:) [], MethodInvocationException
FullyQualifiedErrorId: WebException
Error: cannot find or load the main class org.apache.maven.wrapper.MavenWrapperMain"
The problem was used the command prompt of Windows instead the Linux Command Line.

Opennebula error monitoring host KVM

I've started opennebula sunstone on Ubuntu 15.04 with one host on KVM.
I can add the host on the server via sunstone, but i've an "MONITORED_ERROR" and when I look at the log I've this error:
/var/tmp/one/im/run_probes: line 34: 24669 Aborted ./$i $ARGUMENTS Error executing collectd-client.rb
And if I go on the host oneadmin can log whitout password and if I execute the command: /var/tmp/one/im/run_probes kvm /var/lib/one/datastores 4124 20 2 host I've this error:
./collectd-client.rb:122:in <main>': undefined method split' for nil:NilClass (NoMethodError)
ERROR MESSAGE --8<------
Error executing collectd-client.rb
ERROR MESSAGE ------>8--
From https://forum.opennebula.org/t/solved-error-monitoring-host-2-error-executing-probes/738/3
well, enable disable didn't work.
I had to delete /var/tmp/one on affected host and then :
su - oneadmin
onehost sync --force
I also deleted /etc/cron.daily/tmpwatch

Vagrant unable to mount SMB after upgrade to 1.7.4

I'm using vagrant on windows 8, with the hyper-v provider starting a windows server 2012 box.
Before I updated to vagrant 1.7.4 I was on version 1.7.2, and everything worked.
But after updating I am getting an error when it is trying to mount the shared folder:
The following WinRM command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
cmdkey /add:xxx.xxx.xxx.xxx /user:DOMAIN\user /pass:Password
Stdout from the command:
Stderr from the command:
Exception calling "RegisterTaskDefinition" with "7" argument(s): "The user
name or password is incorrect. (Exception from HRESULT: 0x8007052E)"
At C:\tmp\vagrant-elevated-shell.ps1:58 char:1
+ $folder.RegisterTaskDefinition($task_name, $task, 6, $username, $password,
1, $n ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ComMethodTargetInvocation
I have replaced the details from the line:
cmdkey /add:xxx.xxx.xxx.xxx /user:DOMAIN\user /pass:Password
With placeholders for obvious reasons. I did try and run the command above in the VM and I get the following output:
CMDKEY: Credential added successfully.
So I assume it is working correctly. Has something changed or broken in 1.7.4?
I have figured out a fix for this.
Our password contained dollar signs ($), these were being stripped out in the vagrant-elevated-shell.ps1 script.
I have forked the vagrant repo and made the change and made a pull request - https://github.com/mitchellh/vagrant/pull/6452
To patch your local environment, you can find the communicator.rb file on your local machine at:
C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.7.4\plugins\communicators\winrm\communicator.rb
(provided you used the default setting in the installer)

Vagrant Error on Windows 10 with Hyper-V

After upgrading to windows 10 then running:
$ vagrant up
We get the following error message
An error occurred while executing a PowerShell script. This error
is shown below. Please read the error message and see if this is
a configuration error with your system. If it is not, then please
report a bug.
Script: get_vm_status.ps1
Error:
C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.7.4\plugins\providers\hyperv\scripts\get_vm_status.ps1 : Unable to
find type [Microsoft.HyperV.PowerShell.VirtualizationOperationFailedException].
At line:1 char:1
+ &('C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.7.4\plugins\prov ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Microsoft.Hyper...FailedException:TypeName) [get_vm_status.ps1], Ru
ntimeException
+ FullyQualifiedErrorId : TypeNotFound,get_vm_status.ps1
With Vagrant 1.7.4.
Any ideas?
I had the same problem on a fresh install of Vagrant 1.7.4 on Windows 10 Enteprise (first time using Vagrant).
It looks like the type VirtualizationOperationFailedException has been replaced with VirtualizationException in the latest version of PowerShell.
I changed line 15 of C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.7.4\plugins\providers\hyperv\scripts\get_vm_status.ps1 from:
} catch [Microsoft.HyperV.PowerShell.VirtualizationOperationFailedException] {
to
} catch [Microsoft.HyperV.PowerShell.VirtualizationException] {
Now I'm able to use vagrant up and vagrant status without errors. This is obviously not a long term solution but got things working again. There may be other scripts that are broken as well but I haven't run in to them yet.
I had the same error after destroying then recreating a VM.
I removed the .vagrant/machines/hyperv folder and all went ok.
If a solution by #jeff-r doesn't work for you, you can try changing:
} catch [Microsoft.HyperV.PowerShell.VirtualizationOperationFailedException] {
to:
} catch [Exception] {
Be careful, it may also cause some side-effects.
on win 10 you must disable "Hyper-V" to run vagrant/virtualbox

Resources