2

I am looking for generic software which performs the following:

  1. Spins up a server on a cloud (vendor agnostic) or local VM (ideally)
  2. Transfers a bash script to the new server
  3. Runs the bash script, waiting as long as is necessary before
  4. Performs post-script actions such as downloading a file

It could look like this:

./runOnCloud.sh
    --credentials=filecontainingcloudcredentials.json
    --cloud=amazon
    --type=x3.3large
    --preemptible=true
    --download=/tmp/filetodownloadfromremotemachine.tar.gz
    scriptToRunOnRemoteMachine.sh

runOnCloud.sh doesn't have to be a Bash script of course, it could be Java or a binary or anything, as long as it automates and takes the trouble out of provisioning the machine, I don't really mind.

  • Have you tried vagrant? vagrantup.com – chicks Apr 12 '19 at 17:45
  • No, that seems very close to what I need. A few years ago I read about Vagrant, never used it, and then forgot about it, so thanks for the reminder! Feel free to add a proper answer (especially the bit about retrieving a generated file from the VM) and I'll accept it. – Rich Apr 15 '19 at 7:36
1

Vagrant

Vagrant seems like the perfect choice for your needs.

Multi-cloud

Vagrant supports numerous cloud providers and local virtualization technologies. Built-in support exists for "VirtualBox, Hyper-V, and Docker". There is a plugin architecture which has allowed a diverse set of folks to build support for cloud providers. Plugins and tutorials for AWS with Vagrant, or Google Cloud are easy to find.

Shell scripts

Vagrant has a Shell Provisioner that seems to cover what you're looking for.

Combined with a little bit more Ruby, this makes it very easy to embed your shell scripts directly within your Vagrantfile. Another example below:

$script = <<-SCRIPT
echo I am provisioning...
date > /etc/vagrant_provisioned_at
SCRIPT

Vagrant.configure("2") do |config|
  config.vm.provision "shell", inline: $script
end

Downloading a file

Vagrant supports ssh/scp so it is easy to download or upload files anytime.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.