Table of Contents
Inputs are used to create easily customizable and reusable scripts. Inputs are essentially variables within a script that allow you to substitute specific, user-defined values for the input when an associated script is run on a server. You should create an input for any value that should be customizable within a script. This way, the same script can be used in multiple cloud environments and on across multiple servers to produce different results depending on the context in which it's used.
A ServerTemplate's Inputs tab shows all of the inputs declared in any of its scripts (RightScripts or Chef Recipes) located under its Scripts tab. Users can define values that should be used in place of the declared input when the related script is executed. The following diagram shows how inputs are used by RightScripts however the same variable substitution rules apply to Chef recipes.
There are several different input types. You can select the input type from the dropdown menu when editing them under an Inputs tab.
There are several different input types. You can select the input type from the dropdown menu when editing them under an inputs tab.
Type | Description |
Inherit | To inherit a value, select the "inherit" option and specify from where you would like to inherit. For more information on the hierarchy of inputs, see Inheritance of Inputs. |
Env | Environment Variable. Select one of the predefined environment variables from a cloud infrastructure or RightScale. When you select an environment variable, the associated value will be passed to the server. For example, if you need to use a unique identifier, you can select the 'EC2_INSTANCE_ID' input, which is a unique ID that's assigned by Amazon when an instance is launched (e.g. i-baad23d3). You have the option of using either the server's own environment variables or one from another server in the deployment. See List of Environment Inputs. |
Text | Enter a valid text value for the input parameter. Inputs that are required in order to execute a script will be highlighted in red if values are missing. Make sure there are no trailing whitespaces at the end of the text value. Values set at higher levels in the inputs hierarchy will be inherited. For more information on the hierarchy of inputs, see Inheritance of Inputs. |
Array | Enter an array/string of comma-separated values. You should only use this option for Chef recipes, not RightScripts. If you use this option for a RightScript, the array of values will be collapsed into a single, comma-separated string. So, you will need to parse the values within your script if you choose to use an array type with a RightScript. |
Cred | Select one of the credentials that you've previously created and defined in your account. Typically you will create and use credentials for referencing private/sensitive information like your AWS Secret Access Key or the login/password to access your database or SVN repository. |
Key | A list of valid SSH Keys for a cloud/region. Only SSH Keys that contain key material will be listed. |
No Value/Ignore | The input will be ignored. No value will be passed to the server in the context of a RightScript. This can only be applied in the event of an optional input, and cannot be used for required inputs. |
Ambiguous Inputs occur if two or more RightScripts both call for the same input name, but have different values. This will create ambiguous inputs and you will be given error messages in the UI and you will not be able to launch until this is fixed.
Note: When you launch a server all of the inputs and their values are displayed. Missing inputs are displayed in red.
If you are creating new scripts (RightScripts or Chef Recipes), be sure to follow best practices for creating new inputs.
Before you create new inputs it's strongly recommended that you check RightScale's latest published ServerTemplates to see if a similar input already exists. For example, to reference the fully qualified domain of the master database, use MASTER_DB_DNSNAME, which is used by many RightScale scripts instead of creating your own input with a slightly different name.
If you are creating your own private RightScripts and need to create new inputs, it's strongly recommended that you use unique (not generic) input variable names to avoid unintentional confusion and collision with other scripts. For example, if you need to create a set of inputs that is specific to your company or project, you should consider using a common prefix for each unique input so that all of your inputs are easily identifiable and grouped together. (e.g. COMPANY_INPUT_1). If the name is too long, consider using a meaningful acronym instead.
However, there are several input prefixes that are reserved and cannot be used to create your own inputs.
The syntax that is used to declare an input inside the code of a script differs slightly depending on the language. Most RightScripts published by RightScale are written in Bash, whereas most of the Chef Recipes are written in Ruby. It's recommended that you also use underscores (_) and not spaces or dashes to separate two words. (e.g. MY_INPUT)
When you are looking at a RightScript's Inputs tab, the inputs in the code are automatically identified if they are defined with the correct syntax. The identified inputs display as user-defined input parameters under the Inputs tabs. The following example shows how inputs are identified within a bash script.
If you are in Edit mode, you can use the Identify button to parse through the new code and display all properly declared inputs. As a best practice, you should always provide helpful descriptions that appear as tooltip hints when a user declares values for the inputs.
Below are a few examples of different types of inputs.
Unlike RightScripts, there are no reserved prefixes that you are not allowed to use in Chef recipes.
To declare an input (also called a "Chef attribute") in a Chef recipe, use the following syntax: [:part1][:part2][:partN]
Below is the code from one of our Chef cookbooks. Notice the three inputs (Chef attributes) that are declared in the code.
'db::setup_privileges_admin.rb'
# # Cookbook Name:: db # # Copyright RightScale, Inc. All rights reserved. All access and use subject to the # RightScale Terms of Service available at http://www.rightscale.com/terms.php and, # if applicable, other agreements such as a RightScale Master Subscription Agreement. rightscale_marker :begin DATA_DIR = node[:db][:data_dir] user = node[:db][:admin][:user] log "Adding #{user} with administrator privileges for all databases." db DATA_DIR do privilege "administrator" privilege_username user privilege_password node[:db][:admin][:password] privilege_database "*.*" # All databases action :set_privileges end rightscale_marker :end
Even though an input (Chef attribute) is declared in a Chef recipe, RightScale will not identify it as such until it's been properly declared in the cookbook's metadata. If you create a new input in a Chef recipe you must also remember to manually update the metadata file (metadata.rb). Before you commit your changes to your cookbook repository, you must first rake the metadata, which updates the metadata.json file (from the metadata.rb file). RightScale only displays inputs if they are found in the cookbook's metadata (specifically the metadata.json file).
The following is an example of two properly documented inputs within the cookbook's metadata.
'db::metadata.rb'
attribute "db/admin/user", :display_name => "Database Admin Username", :description => "The username of the database user with 'admin' privileges (e.g., cred:DBADMIN_USER).", :required => "required", :recipes => [ "db::install_server", "db::setup_privileges_admin" ] attribute "db/admin/password", :display_name => "Database Admin Password", :description => "The password of the database user with 'admin' privileges (e.g., cred:DBADMIN_PASSWORD).", :required => "required", :recipes => [ "db::install_server", "db::setup_privileges_admin" ]
If the recipe and metadata are properly constructed, the Chef attributes will appear as user-definable inputs in the Dashboard.
For more information about how to update the Chef metadata correctly, see Chef Metadata.
As a best practice, you should define a majority of your inputs at either the ServerTemplate or deployment level.
You should only define inputs at the server or server array levels for performing tests or under unique circumstances. In a production environment, all inputs should inherit their values from previous levels (deployment level and below). The key benefit of defining inputs at the deployment level or below is that you can more easily maintain consistent server configurations across your entire deployment and associated arrays, because you can go to a single location (the deployment's Inputs tab) to see which input values are being used and know where those values are being inherited from. It's easier to troubleshoot problems within a deployment if you follow strict processes for defining inputs. For example, a problem within a deployment could be caused by the wrong input value being used by a server because the incorrect value was overwritten at the server level.
Although you have the flexibility to define inputs at the server or server array level, it's not a recommended best practice for most use cases. Unless you're an advanced user with unique configuration circumstances, you should only set an input parameter at the server level for development and testing purposes. An example might be that you've cloned a server and want to test it with a slightly different input parameter. One of the problems with defining input values at the server or server array (highest precedence) level is that it's difficult to keep track of a server's inputs. For example, if you need to troubleshoot a configuration problem you might have to manually check each server's Inputs tab to investigate the cause of the problem. However, setting input parameters at the Server level can prove to be quite useful in the right situation.
As a best practice, you should always define any inputs that are required by any boot/decommission scripts before you try to launch a server or enable a server array. Ideally, when a server is launched either manually or automatically, it inherits input values that were previously defined at one of the inheritance levels.
As a safety precaution, you are not allowed to manually launch a server if there are required inputs with missing values. If you try to launch a server that contains missing inputs, you will receive an error message that prompts you to provide values for any missing inputs that are highlighted in red. The following example screenshot shows an error message for missing inputs.
If you receive this error message, you should cancel the server launch. At this point, you should go back and define values for any missing (required) inputs under the deployment's Inputs tab before launching the server again.
Although you can provide values for any missing inputs on this screen and continue the launch process, it's not a recommended best practice. See the following section for details.
When you manually launch a single server from the Dashboard, the "Inputs Confirmation" screen displays which user-defined values are used for the declared inputs. When values have been provided for the missing inputs, you can continue the launch process.
At this point, you have two options if are going to continue launching the server. It's important to understand the difference between these two distinct actions.
Yes, although it is not a recommended best practice for most use cases.
Ideally, you should only have a single input to represent a particular value. If you're using RightScale's published ServerTemplates, you should verify whether or not an input already exists that represents the value you're trying to parametize before you create a new one. Avoid creating multiple inputs that are designed to represent the same value. For example, inside of a single script or across multiple scripts, you shouldn't have two inputs that are used to pass the name of your application (e.g. Application Name, Application). If you are using several different ServerTemplates within a single deployment, you can go to the deployment's Inputs tab to see if there are multiple inputs where the same value is being used. If such cases do exist, you may want to consider consolidating the inputs.
At the deployment level, you can only define one value for an input. However, you may have a deployment that contains servers where different values are used for the same input depending on its ServerTemplate. This type of configuration might be appropriate in certain use cases. For example, you may have two different types of application servers that connect to a database server on different ports. As long as you don't override the input at the deployment or server/array level, each server can inherit a different value if it's set at the ServerTemplate level. The following example screesnshot shows the ServerTemplate inheritance in a deployment.
Remember, where you define inputs determines which value is used. By using the input hierarchy correctly, you can accurately control which values are ultimately inherited and used by a script.
Yes. RightScale's Credential Store (Design -> Credentials) allows you to create credentials for hiding sensitive values where you can hide the actual value from users in the Dashboard, but still allow that value to be passed to a script at execution time. For example, as a database system administrator, you might want to hide your database's administrator username and password from other members of your team, however those secret credentials need to be applied to the database setup scripts in order to properly launch and configure the database servers. In such cases, you can create a credential for each sensitive value.
A user will need 'designer' user role privileges to create a credential. Only the user who created the credential and other users with 'admin' user role privileges will be able to see the hidden value of a credential.
Remember, a server receives its inputs when it's launched. Once a server becomes operational, the inputs that it was originally launched with are static and can be seen under the "current" server's Inputs tab. (The "next" server's Inputs tab shows which inputs will be used to launch the next iteration of that server that results from either a launch or relaunch action.) You can execute any of the scripts defined by the server's ServerTemplate during runtime, even boot and decommission scripts.
If you want to change one of the inputs on the current server, you can run a script that uses the input. However, you must specify the new value for the input under the "current" server's Inputs tab before you run the script. Input hierarchy rules do not apply anymore because the server is already operational.
Typically, you will only need to run one of the boot/operational/decommission scripts. However, you can also use the 'Any Script' option to execute any script in your RightScale account.
Note: When you use the 'Any Script' option, the new inputs will not be saved to the "current" server's Inputs tab, however they will be recorded in the audit entry.
It's important to remember that when you change the input on a running server, the change is not automatically preserved. If you want to save the modified input for future iterations of that server, you need to update the Inputs tab at one of the input inheritance levels, preferably the deployment level.
No. Remember, since you can change an input on a running server, the "current" server's Inputs tab can change over the lifetime of the server. As a result, the "current" server's Inputs tab may not reflect which inputs were used to originally launch the server. However, you can check the server's audit entries for details.
© 2006-2014 RightScale, Inc. All rights reserved.
RightScale is a registered trademark of RightScale, Inc. All other products and services may be trademarks or servicemarks of their respective owners.