If I could run a shell script in the workflow to add our custom provisioning message then the template would not need customized. I would like to be able to set the value of instance.statusMessage in a provisoning workflow so when completed successfully I could have the default template send an email with the message body including something like, “Please wait 10 minutes for the system reconfiguration to complete”
It’s possible to alter morpheus vars via script. Typical examples could be changing things like instance name and hostname, and usually during the config phase since this phase allows data to be modified that is passed to the provisioning job
You could try setting it in that phase, but I’d caveat that. It may be something updated when provisioning is complete or failed. You may need to use provision or post-provision phase, and even then it would depend on whether the email is sent, prior to workflows in those phases being executed
One to test.
To help, this script in Python, should give you enough info to create a task & provisioning workflow to test your ability to update that variable prior to the email getting sent.
Thank you for the link and pointer. I can from the example a good start for connecting back to the Morpheus API with the instance token. I will need to dig through the documentation to see where the instance endpoint exists and see if I can set that.
I created a Python automation script with the simple code below:
morpheus['instance']['statusMessage'] = "The instance will restart in 15 minutes after the puppet configuration has completed"
And when that is set the workflow is complete but the statusMessage has nothing extra. I dumped all the python vars and I see instance.server.statusMessage = null.
But when i try and set the value in Automation using morpheus.instance.server.statusMessage I get an error in the script. If i correct and complete the automation step I get a message, but it’s the same error on the Provisioning History (below). My guess is “statusMessage” for the instance is something only morpheus can touch, so we’ll just extend the email template and look for the OS instance; and if it is RHEL to include our puppet message for the pending satellite configuration steps.
Error
Traceback (most recent call last): File “”, line 5, in KeyError: ‘server’
That could be the case. If you can, please post up your full script and state in which phase it is running. No promises, but someone may be able to test/validate the script when get a moment.
That is amazing. I did not make the connection with the new spec. I’m trying it on our environment but I think I’m working through some other issues. When I put this script in config mode workflow I could not provision new instances.