I am having a problem getting the Guest Script Manager to execute a simple bash script:
cp /tmp/gg /tmp/gg2
Is there a reason why this bash command will not run? Is it the way that it's being interpreted when it is passed...I'm unsure. I am able to run this basic bash script:
sudo useradd [userName]
So I know that everything is working...just seems something is weird with how things are parsed when it runs. Any ideas?
Hi,
Could you provide more details, like how exactly this script fails (errors/exceptions/stacktraces), how exactly do you start it (which workflow, what inputs, etc.), what is our environment (vRO version, etc.)?
vRO Version: 7.3.0.5481809
Test VM OS: CentOS Linux 7.3.1611
Inputs
Virtual Machine: name of test vm
Guest OS Username: root
Guest OS Password: ************
script type: bash
script: cp /tmp/gg /tmp/gg2
Script fails when I try to use the above command (any script input with /), however, workflow successfully completes with simple commands like mkdir or adduser so I know communication and workflow is working. Seems like there is a problem with interpreting the syntax for the command cp /tmp/gg /tmp/gg2
Logs:
2017-10-24 09:11:36.768] [E] Error in (Workflow:Run program in guest / Scriptable task (item1)#15) The guest operations agent could not be contacted.
[2017-10-24 09:11:36.797] [E] Workflow execution stack:
***
item: 'Run program in guest/item1', state: 'failed', business state: 'Create temporary file in guest', exception: 'The guest operations agent could not be contacted. (Workflow:Run program in guest / Scriptable task (item1)#15)'
workflow: 'Run Script In Guest' (f8cd5692-92a0-46b6-a98d-53ffd878d779)
| 'attribute': name=errorMessage type=string value=
| 'attribute': name=scriptArguments type=string value=-c "bash > /tmp/vmware-root/vmware156/vco_vmware125 2>&1 -c \"cp /tmp/gg /tmp/gg2\""
| 'attribute': name=scriptProgramPath type=string value=/bin/bash
| 'attribute': name=scriptPid type=number value=null
| 'attribute': name=scriptProcessInfo type=Array/CompositeType(pid:number,name:string,owner:string,cmdLine:string,startTime:Date,endTime:Date,exitCode:number):GuestProcessInfoType value=__NULL__
| 'attribute': name=scriptFinished type=boolean value=false
| 'attribute': name=scriptTimeoutCounter type=number value=0.0
| 'attribute': name=scriptOutputFile type=string value=/tmp/vmware-root/vmware156/vco_vmware125
| 'attribute': name=scriptOutputPrefix type=string value=vco_
| 'attribute': name=vcoCopiedFileResult type=boolean value=false
| 'attribute': name=vcoTempFile type=string value=
| 'attribute': name=cmdAnsi type=ResourceElement value=dunes://service.dunes.ch/ResourceElement?id='352d998c-6af5-4af9-8c4f-da4a2a2dff2b'&dunesName='ResourceElement'
| 'attribute': name=cmdAnsiVcoPath type=string value=
| 'attribute': name=cmdAnsiGuestPath type=string value=
| 'attribute': name=overwrite type=boolean value=true
| 'attribute': name=useCmdAnsi type=boolean value=false
| 'attribute': name=powershellScriptGuestPath type=string value=
| 'attribute': name=powershellScript type=string value=
| 'attribute': name=powershellScriptVcoPath type=string value=
| 'attribute': name=powershellSuffix type=string value=.ps1
| 'attribute': name=errorCode type=string value=
| 'attribute': name=guestTempDirectory type=string value=/tmp/vmware-root/vmware156
| 'attribute': name=recirsive type=boolean value=true
| 'attribute': name=delay type=number value=__NULL__
| 'input': name=vm type=VC:VirtualMachine value=dunes://service.dunes.ch/CustomSDKObject?id='vc01t-ops-08.server.com%2Cid:vm-11321'&dunesName='VC:VirtualMachine'
| 'input': name=username type=string value=root
| 'input': name=password type=SecureString value=__NULL__
| 'input': name=scriptType type=string value=bash
| 'input': name=script type=string value=cp /tmp/gg /tmp/gg2
| 'input': name=scriptTimeout type=number value=60.0
| 'input': name=scriptRefreshTime type=number value=null
| 'input': name=scriptWorkingDirectory type=string value=
| 'input': name=interactiveSession type=boolean value=true
| 'output': name=scriptOutputText type=string value=null
| 'output': name=scriptExitCode type=number value=null
--workflow: 'Run program in guest' (C98080808080808080808080808080805E80808001322751030482b80adf61e7c)
| 'input': name=vmUsername type=string value=root
| 'input': name=vmPassword type=SecureString value=8BT21V40G51J57V39J30O6FZ70QF836AFAU632D879KC5B88D0YF875DBET7C8768BM14A8F92LD4337FET9142767Z5D90169JB1F7E33N27228B3Z6C8E311RD54E541T247494Z5B9B399XAB7740DH6C7461BI4AD3E08W939400DGD80873AIDE38C3EZ4B43126X607F47DO9D0FDB1M
| 'input': name=vm type=VC:VirtualMachine value=dunes://service.dunes.ch/CustomSDKObject?id='vc01t-ops-08.server.com%2Cid:vm-11321'&dunesName='VC:VirtualMachine'
| 'input': name=interactiveSession type=boolean value=true
| 'input': name=programPath type=string value=/bin/bash
| 'input': name=arguments type=string value=-c "bash > /tmp/vmware-root/vmware156/vco_vmware125 2>&1 -c \"cp /tmp/gg /tmp/gg2\""
| 'input': name=workingDirectory type=string value=
| 'input': name=environment type=Array/string value=null
| 'output': name=result type=number value=null
| 'no attributes'
*** End of execution stack.
You need to change the value of one of the input parameters - script context interactivity - from Yes/true to No/false.
Great...that helped the workflow complete without error(s), but it did not execute the script. I can copy and paste the script command that it is passing into a SSH session with the VM and it completes fine. Unsure what else it could be.
Hmm, I tested it in my environment (same vRO version, SuSE test vm), and it seems to work.
Could you test using the vRO appliance as the test vm (that is, test with SuSE instead of CentOS)? Also, which versions of Guest Script Manager and the corresponding workflows do you use?
Very strange, the script completed on the vRO appliance as the test VM per your suggestion. I provisioned a fresh SuSE VM and tried to run it there, but no luck. Workflow completes (green check) but does not carry out the script.
I am using guestscriptmanager-version-0.0.3 and for this example running the Run Script in Guest workflow
Have you tried using the functionality in the guest script manager that allows you to upload a script then execute it that way? I've done this with some complex scripts that seemed to have issues. When you create your script configuration just make the script that runs something like this. Say you uploaded the script to ~/sometestscript.sh. In the configuration make the script to run just a couple of lines:
chmod +x ~/sometestscript.sh
~/sometestscript.sh
You said SSH works? Have you tried using the Run SSH command workflow in place of Guest Script Manager? For Linux machines I think it's much cleaner to use that workflow versus GSM which requires VMware tools being installed. You don't have to track a PID with Run SSH command either; it should wrap up after the command is done invoking. I only use GSM for Windows devices.