Creating Custom Actions
This topic does not apply to Oracle Cloud at Customer.
For example, you can use custom actions to automatically install an OS package, create a database schema, or deploy an application.
For an introduction, see What are Custom Actions.
Creating a Software Component
Define custom actions in your Oracle Cloud Stack template within a special type of resource called a software component.
Adding a Software Component to a Resource
Configure a template resource so that Oracle Cloud Stack executes custom actions after provisioning the resource.
Adding a Condition to a Software Component
Assign a global condition to a software component in your Oracle Cloud Stack template.
If the condition evaluates to false during the creation of a stack, the custom actions in this software component will not be executed. See Defining Global Conditions.
- Access the Oracle Cloud Stack console, and then edit your template.
- To the left of Software components, click .
- To the right of the software component that you want to modify, click Edit .
- From the Conditions field, select an existing condition.
- Click Apply Changes.
- Click Save the current template .
Custom Action Best Practices
Consider these best practices when creating Software Components in an Oracle Cloud Stack template.
-
The use of template functions, such as
GetParam
, is not supported within the OS commands of a custom action. -
Program a custom action so that it can run multiple times without failing or behaving unexpectedly (idempotent). A custom action might be run more than once in the following scenarios:
-
Oracle Cloud Stack retries the execution of a custom action after a communication failure with the target resource.
-
If you create a cloud stack with the
RETAIN
option, and then resume the stack after a resource provisioning failure, Oracle Cloud Stack also (re)executes any custom actions that are associated with the failed resource.
-
-
In a custom action, return 0 to indicate success and return 1 to indicate a failure.
-
By default, all existing resources are terminated if there is a failure during the creation of a stack, which includes the deletion of any log files generated by a custom action. To facilitate troubleshooting, record log messages to an external location like cloud storage.
-
You can use
wget
,curl
, or similar OS commands to download scripts and other files to the administration node in the target cloud resource. For example, you could download and extract an archive file found in an Oracle Cloud Infrastructure Object Storage container, and then execute one or more scripts found in the archive.