Sending a File to an Instance from the appliance

Hello All,

I’m here to see if it’s possible or if morpheus has a built-in tool to to send a file Generated from a script during the deploy or post provisioning phase to the actual instance itself. I know there is ways to manually do this. But I’m wondering if there is a way to send that file to that server after it runs.

We have the concepts of file templates and script templates. The former can provide configuration for applications, while script templates are executed on the instance, and perform configuration actions like download software. Both will accept morpheus variables which will be interpolated and added to the scripts.

https://docs.morpheusdata.com/en/latest/library/templates/file_templates.html?highlight=file%20templates

https://docs.morpheusdata.com/en/latest/library/templates/scripts.html?highlight=file%20templates

Would these serve your use case?

2 Likes

I would generally go with @Ollie_Phillips answer here as that would also allow you the capability to edit the file in real time provided your instance type is set to allow settings.

However, if it does not meet your needs, we also have the concept of Archives which can be found at Tools → Archives. This can be linked to a storage bucket which you can then access via private or public links.

You can have a task that pulls a file or binary from an archive in a provisioning workflow.

to put some clarification we are tattooing the server writing the info to a file and then saving it to a location on the instance or VM itself. So Morpheus would gather the info and then after all the info is collected. just place it in said location. I think the File templates might actually work may need toy with it.

To add to the party. Based on your last comment @Derp0ps, I think File Templates is what you want like @Ollie_Phillips said.

I just wanted to add one more feature in Morpheus that might help if you (or others) have a larger set of files or binaries that need to be copied across. In addition to Archives that @sjabro mentioned, you can also use Deployments. This utilizes Archives in the background that can be set to transfer different versions of files to your instance, for example if you need to install or upgrade an app.

OP,

The suggested File Templates feature is most likely what will work for you. But you can also do more interesting things like:

  • Create a Task that runs during the provisioning phase on the Morpheus appliance (or any other remote server). This task could create the file(s) that you need with whatever contents they need to contain.
  • Have the Task use base64 to encode the file. If multiple files, uses tar/ZIP to create an archive and then base64 encode that tar/ZIP.
  • Have the Task stuff the resulting base64 string into a JSON value of a key/value and output the JSON to standard out.
  • The next Task in the workflow would be a Task running on the Endpoint
  • This Endpoint Task can access the keys/values of the JSON result string of the previous Task as variables.
  • Have the Endpoint Task run the base64 decode on the known JSON key/value to save the file or the tar/ZIP if sending multiple files to the Endpoint.
  • Endpoint Task can then manipulate the file / archive as needed.

I’m not sure if there are any size limitations on the JSON being passed between Tasks, but for simple and smaller files the above could work if output from Tasks ran on different systems within the same Workflow need to be passed around.

-Yaron.

Sorry for reviving, but a quick question on the File Templates.
If a script template and a file template are say both set to the same Phase, which one applies first?

If you are using file and script templates attached to a node type, you would have to set them in different phases to get them to apply in a certain order.
However, if you use a provisioning workflow attached to a layout, you can use the Library Script (which holds a script template) and Library Template (which holds a file template) tasks in the same phase, and select the order in which you want these to execute.

2 Likes