About Plan Scripts

Plan Script forms a part of the deployment or capture process. The Plan Scripts are guestfish scripts that are used to accomplish the personalization (deployment) or generalization (capture) processes. Deploy type Plan Script is used to perform a deployment and Capture type Plan Script is used to perform a capture. Deploy type Plan Scripts contain Custom Attributes. Custom attributes are used to provide server-specific configuration information. By default, custom attributes are of Type string and can be later modified in the OS Build Plan.

Follow specific conventions while creating Plan Scripts. One of them is @custom attribute name:custom attribute value@ syntax to specify custom attribute. The following is an example for customizing hostname and SSH server setting for an ESXi host:

#!/usr/bin/guestfish -f 
#set the host name for the server
esxcli system hostname set -H "@HostName:DEFAULT 
#set the SSH server flag
esxcli network firewall ruleset set --ruleset-id 
"@SSH_SERVER:DISABLE@" --enabled yes

During the personalization process, all the Plan Scripts available in the OS Build Plans are combined and the custom attributes are replaced with the specified values. The combined script is then executed in the guestfish environment.

You can include log messages in Plan Scripts to notify the Server administrator of any errors while executing the Plan Script. The log messages are displayed in the server profile activity. You can include these log messages in the following format:

echo "ImageStreamerLog: [log message]"

For more information on guestfish, see http://libguestfs.org/guestfish.1.html.

Recommendations on Plan Script syntax

The following recommendations can be considered while creating a Plan Script:
  1. Do not include the following guestfish commands in the Plan Script since Image Streamer automatically invokes these commands while mounting the OS volume:
    • guestfish

    • add <disk.img>

    • run

  2. According to guestfish convention,
    • Any file path that begins with / refers to a file path in the mounted file system of the Golden Image.

    • Any file path that begins with ./ refers to a temporary space provided by Image Streamer appliance. This temporary space can be used to store temporary files during personalization or generalization.

      The temporary space is cleared after the personalization or generalization process.

  3. You can invoke bash commands by using !. You can also embed the bash commands using heredoc syntax.

  4. When a Plan Script is executed, the execution result is logged in the deployment log, To create additional log messages, use the following syntax:

    echo "ImageStreamerLog: [log message]"

  5. The @ character is used to mention custom attributes in Plan Scripts. So if you want to use the @ character for a different purpose, you must use @@ instead of @.