rundeck python script calling powershell script fails to execute

171 views
Skip to first unread message

Osman Javed

unread,
Jun 24, 2018, 12:43:43 PM6/24/18
to rundeck-discuss


Hello,

I am pretty new at rundeck. I decided to move all the scripts to rundeck , and rundeck would connect to the server via winRM and execute them in-line. The target server is windows 2012. 

This works fine for all dozen or so scripts except for one of my python scripts. The difference is that it calls subprocess.Popen, subprocess.communicate() to execute a powershell script hosted in the target node  and read output. The powershell script connects to MS-Online and reads tenant account information. (mop.ps1)

When running the same code locally on the server I get a valid output:

DEBUG:__main__:This is r "SkuPartNumber","ActiveUnits","ConsumedUnits"
"VISIOCLIENT","3","3"
"POWER_BI_PRO","13","13"
"ENTERPRISEPACK","0","0"
"EXCHANGESTANDARD","4","4"
"O365_BUSINESS_PREMIUM","134","129"
"POWER_BI_STANDARD","1000000","10"
"OFFICESUBSCRIPTION","0","0"
"AAD_PREMIUM","1","0"
"EXCHANGEARCHIVE_ADDON","1","1"
, error is e
DEBUG:__main__:Got ['"AAD_PREMIUM"', '"1"', '"0"'] from MOP

But running it via rundeck, if I print stderr I see :

Get-MsolPartnerContract : You must call the Connect-MsolService cmdlet before calling any other cmdlets.

Please refer to screenshots. 

I checked the ps file and the Import-Module cmd works just fine, the ps file runs fine when executed outside of python as well. It has worked for months without touching the code. 

Rundeck executes the scripts on this node in the same execution directory where prior to rundeck the scripts used to work from. What am I doing wrong?

Appreciate some assistance. 
rundeck_error.png
mop.ps1
execute_direct.png

edu...@rundeck.com

unread,
Jun 27, 2018, 11:47:19 AM6/27/18
to rundeck-discuss
Hi Osman

From your description,  since you are able to run get a valid output when running the script directly from the server, it may be possible that you error could be related to the “Second Hop” that you use to login into MS-Online. Currently, the Rundeck Python-Winrm plugin supports Basic, ntlm or CredSSP Authentication, and CredSSP authentication allows you to perform the second hop successfully.

Hope it helps!

Eduardo Carrasco

javed...@gmail.com

unread,
Jun 29, 2018, 12:17:16 PM6/29/18
to rundeck...@googlegroups.com
Thank you Eduardo with your suggestions. I'll try them out. 

--
You received this message because you are subscribed to the Google Groups "rundeck-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rundeck-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to rundeck-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rundeck-discuss/0314a0b5-8b9d-46b2-825c-77f59b0b2124%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages