Create and run executable scripts

Mist.io allows you to store and run executable scripts to configure newly created systems or modify existing servers. In order to achieve that, Mist.io needs SSH access to the specified machines. By providing a central place to store scripts, Mist.io can act as a library to store and reuse configurations and actions.

Adding executable scripts

You can add executable scripts to Mist.io in three ways:

Inline Editor

The simplest way, handy when we only have a few scripts to add. In the Scripts section, select Executable as the type, Inline as Source and paste your script. Press Add to save the script.

Github

To use a github repository as the source of our scripts, you need to specify the github repo (e.g.  https://github.com/mistio/ansible-examples), and an entry point (which script to run, e.g. install.sh). 

If the repository is private, we'll have to give access to user   https://github.com/mistio-bot so it can clone it. 

Importing through URL

Alternatively, we can specify a URL which is either a script, or a zip/tar file. If the URL is a zip/tar file, we will need to set the entrypoint (the path of the script) (e.g. scripts/main/install.sh)

If we specify a single script via URL, it has to result to the script in text. For example

https://gist.githubusercontent.com/mgogoulos/f7bed21367a20fcc66d8/raw/d4d32e065a6a0ca052a342a40a4c9e4bb4e4ad1c/simple.sh

Running executable scripts

Now that we have added our scripts, it is time to see how we can run them. We can do that on a newly created system, or on existing systems that Mist.io already has SSH access. 

Running a script on a newly created machine

While we are creating a new machine through the Create Machine wizard, on the Script section we can add our script. Once the server is deployed, it will run the playbook.

Running a script on an existing system

We can also run our executable scripts on existing servers. Enter the scripts section, select the script, and select Run script. Then, select the machine from the list and click on Run. The script will be run on that machine. The list shows only the machines that Mist.io can connect to via SSH.

Still need help? Contact Us Contact Us