NetDocuments-Archive / rd-winrm-plugin

Allows rundeck to execute commands with powershell
Apache License 2.0
31 stars 19 forks source link

Rundeck add chmod an .sh to commands #58

Closed keyser75000 closed 6 years ago

keyser75000 commented 6 years ago

Hi,

I use two plugins to manage via WinRM my Windows servers. I noticed that my jobs, on both plugins, that use Script or ScriptFile failed with same error : The term 'chmod' is not recognized as the name of a cmdlet, function, script file, or operable program.

It seems that rundeck Job add "chmod +x" command and ".sh" at the end to RD_EXEC_COMMAND variable (powershell script in my case). I use Rundeck 2.10.6, plugins rd-winrm-plugin and rundeck-winrm-plugin. This behavior didn't happen in earlier versions (2.9.x and maybe 2.10.2-).

I can bypass this error in file winrmexe.rb by modify a test on chmod (to delete it from command) but I did not update these plugins since. I just updated Rundeck several times. Then I realized this issue happen. I delete "/tmp/" from these lines to make it work again :

exit 0 if command.include? 'chmod +x /tmp/'

if command.include? 'rm -f /tmp/'
  shell = 'powershell'
  command = command.gsub(%r{rm -f /tmp/}, 'rm -force /tmp/')
end

Debug : RD_EXEC_COMMAND => chmod +x c:\temp\228-5513-SMRFGENE8K133-restart_fusioninventory.ps1.sh and

variables:
realm => REALM
endpoint => http://xxxx:5985/wsman
user => DOMAIN\user
pass => ********
timeout => 60
command => chmod +x c:\temp\228-5513-xxxx-restart_fusioninventory.ps1.sh
newcommand => chmod +x c:\temp\228-5513-xxxx-restart_fusioninventory.ps1.sh

Thanks for help (I post too an issue on rundeck Github).

spuder commented 6 years ago

Sorry to hear you are having trouble. Currently we aren't using rundeck, so I can't be much help.

It sounds like a regression in 2.10.x. If you can identify the offending code, pull requests are welcome.

I'll leave this issue open incase someone else is able to identify the problem.

keyser75000 commented 6 years ago

Solved. I change osFamily to "windows" in node config instead of "MSWin32". cf. (rundeck #3144)