Create and Manage StackScripts - A Tutorial

Updated , by Linode

Traducciones al Español
Estamos traduciendo nuestros guías y tutoriales al Español. Es posible que usted esté viendo una traducción generada automáticamente. Estamos trabajando con traductores profesionales para verificar las traducciones de nuestro sitio web. Este proyecto es un trabajo en curso.

What are StackScripts?

StackScripts provide Linode users with the ability to automate the deployment of custom systems on top of Linode’s default Linux distribution images. For example, every time you deploy a new Linode you might execute the same tasks, including:

  • Updating your system’s software
  • Installing your favorite Linux tools
  • Adding a limited user account

These tasks can be automated using a StackScript that performs these actions for you as part of your Linode’s first boot process.

All StackScripts are stored in the Linode Cloud Manager and can be accessed whenever you deploy a Linode. A StackScript authored by you is an Account StackScript. While a Community StackScript is a StackScript created by a Linode community member that has made their StackScript publicly available in the Linode Cloud Manager.

In this Guide

This guide shows you how to do the following:

Note
For information on authoring a script to be used in a Linode StackScript, see the Writing Scripts for Use with Linode StackScripts.

Create a New StackScript

  1. Log into the Linode Cloud Manager.

  2. Click on the StackScripts link in the left-hand navigation menu. You are brought to the StackScripts page.

    Click on the StackScripts link in the left-hand navigation menu

  3. Viewing the Account StackScripts section, click on the Create New StackScript link at the top of the page.

    Click on the Create New StackScript link

  4. On the Create New StackScript page, provide the required configurations to create your StackScript.

    FieldDescription
    StackScript LabelThe name with which to identify your StackScript. Required.
    DescriptionAn overview of what your StackScript does.
    Target ImagesThe Linux distributions that can run this StackScript. Required.
    ScriptThe body of the script. See the Writing Scripts for Use with Linode StackScripts section for more details. Required.
    Revision NoteA short description of the updates made to your StackScript in this version of your script.

    The file below displays an example of a simple script that executes some basic set up steps on a Linode. Review the example’s comments for details on what each line of the script does.

    File: Example Script

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    
    #!/bin/bash
    # This block defines the variables the user of the script needs to provide
    # when deploying using this script.
    #
    #
    #<UDF name="hostname" label="The hostname for the new Linode.">
    # HOSTNAME=
    #
    #<UDF name="fqdn" label="The new Linode's Fully Qualified Domain Name">
    # FQDN=
    

    # This sets the variable $IPADDR to the IP address the new Linode receives. IPADDR=$(/sbin/ifconfig eth0 | awk '/inet / { print $2 }' | sed 's/addr://')

    # This updates the packages on the system from the distribution repositories. apt-get update apt-get upgrade -y

    # This section sets the hostname. echo $HOSTNAME > /etc/hostname hostname -F /etc/hostname

    # This section sets the Fully Qualified Domain Name (FQDN) in the hosts file. echo $IPADDR $FQDN $HOSTNAME >> /etc/hosts

    The file below displays an example of a simple script that executes some basic set up steps on a …

  5. Click Save when you are done (and you can always edit your script later if needed). You are brought back to the StackScripts page, where your new StackScript is visible and ready to use with a new Linode deployment.

    Note
    To deploy a new Linode with your StackScript, follow the steps in the Deploying a New Linode Using a StackScript guide.

    View your new StackScript on the StackScripts page

Manage StackScripts

Edit an Account StackScript

After you’ve created an Account StackScript, you can go back and edit it as required. These instructions show you how to access a StackScript for editing.

  1. Log into the Linode Cloud Manager.

  2. Click on the StackScripts link in the left-hand navigation menu. You are brought to the StackScripts page.

    Click on the StackScripts link in the left-hand navigation menu

  3. A list of all of your account’s StackScripts appears under the Account StackScripts tab. This includes both private and public StackScripts. Click on the more options ellipsis corresponding to the StackScript you’d like to modify and select Edit from the dropdown menu.

    Select Edit from the dropdown menu to edit your StackScript

  4. On your StackScript’s Edit page, modify it as needed and click Save to keep your changes.

Make an Account StackScript Public

You can make any of your Account StackScripts public. When an account StackScript is public it becomes available to the rest of the Linode Community in the Cloud Manager as a Community StackScript.

Caution
Once you make an Account StackScript public, you are not be able to make it private again or to delete it. You can, however, edit your public StackScript, if needed.
  1. Log into the Linode Cloud Manager.

  2. Click on the StackScripts link in the left-hand navigation menu. You are brought to the StackScripts page.

    Click on the StackScripts link in the left-hand navigation menu

  3. A list of all of your account’s StackScripts appears under the Account StackScripts tab. This includes both private and public StackScripts. Click on the more options ellipsis corresponding to the StackScript you’d like to make public and select Make StackScript Public from the dropdown menu.

    Select Make StackScript Public from the dropdown menu

    A dialog box appears asking you to confirm the action. Click on Yes, make me a star! if you would like to proceed. You are brought back to the Account StackScripts page.

    Note
    Your public Account StackScript is available to you for use on the Account StackScripts page. For Linode Community members, your StackScript is available to them from the Community StackScripts page.

Delete an Account StackScript

Note
You cannot delete Account StackScripts that have been made public.
  1. Click on the StackScripts link in the left-hand navigation menu. You are brought to the StackScripts page.

    Click on the StackScripts link in the left-hand navigation menu

  2. A list of all of your account’s StackScripts appears under the Account StackScripts tab. Click on the more options ellipsis corresponding to the StackScript you’d like to delete and select Delete from the dropdown menu.

    Select Make StackScript Public from the dropdown menu

    A dialog box appears asking you to confirm the action. Click on Delete if you would like to proceed.

Next Steps

Now that you have created a StackScript, you can deploy a Linode using your StackScript. See the Deploying a New Linode Using a StackScript guide for details.

This page was originally published on

Try this guide to receive $100 at signup on a new account.

Your Feedback Is Important

Let us know if this guide made it easy to get the answer you needed.