Creating a Task
Create a runbook task for performing lifecycle operations on a fleet in Fleet Application Management.
Note
The tasks that you create using this procedure are shared tasks and can be used by any runbook.
The tasks that you create using this procedure are shared tasks and can be used by any runbook.
- On the Tasks list page, select Create task. If you need help finding the list page, see Listing Runbook Tasks.
-
In the Create task page, enter the following information:
- Name: Enter a unique name for the task. The name doesn't have to be unique, but it can't be changed in the Console. You can, however, change it with the API. Avoid entering confidential information.
- Description: Enter a suitable description for the task.
- Create in compartment: Select the compartment that you want to create the runbook task in.
- Lifecycle operation compartment: Select a compartment where the specific lifecycle operation exists. To know about various lifecycle operations, see Lifecycle Operation in Fleet Application Management.
- Lifecycle operation: Select a lifecycle operation—for example, patch, discovery, provision, or any custom.
- For patch or discovery lifecycle operations, enter the following information:
- Product/Product stack compartment: Select the compartment where the product or product stack is in.
- Product/Product stack: Select a product or product stack to which the task belongs from the compartment.
- Action type: Select one of the following options:
- Run a script: Attach a script from Object Storage, or add your script inline under Command. For adding inline script, see substep n.
- Run a terraform: Use a Terraform package to provision resources. Skip to step 4.
-
If you selected Run a script, enter the following information under Script details as needed.
- For OS type, select a supported platform on which the task runs.
-
If the task is meant for discovering targets:
- Switch on the Mark this as discovery output task toggle. This action allows Fleet Application Management to collect software inventory information from the task after it's done.
- Under Add script, select Download discovery output template to ensure that the task output matches the discovery template format. Use the downloaded discovery template as a guide for coding the discovery script. To know about the attributes of the template, see About Discovery Output Template.Note
The success of executing discovery or patching scripts depends on the commands used by the scriptwriter and whether these commands are supported on your instance. If some commands fail, ensure you set up the host with the necessary installations before using the commands. For example, using commands such asmlocate
orlocate
to find files.
- If the task is for applying patches, switch on the This task needs patches to execute toggle. When turned on, Fleet Application Management populates the details of the recommended patches for the task. The details are available in the patches.json file. The script can read the patches.json file to obtain all patches and use the environment variable, DATA_DIR, to know the patch's location downloaded by Fleet Application Management onto the Compute instance.
-
To add your script for task execution, select one of the following options:
- Upload or select from an Object storage: An option to upload the script from your file system or from Object Storage bucket. Skip to substep e.
- Select from catalog: An option to choose the script from the private catalog item. Skip to substep i.
-
If the script addition is through Object Storage, select Browse next to Select script from object storage.
In the Select file page, select one of the following options:
- Select from an object storage bucket: Select a script from Object Storage, if it's already been uploaded, and skip to substep f.
- Upload a file: Select a script by uploading it to Object Storage, and skip to substep g.
-
If you selected Select from an object storage bucket:
- Select the compartment that contains the Object Storage bucket with the script, and then select the bucket.
- Select a script file from the bucket and then select Select. Skip to substep h.
-
If you selected Upload a file:
- Drag a file from the file system to the Drag and drop box, or browse for the file.
- Select the compartment that contains the Object Storage bucket that you want to upload the file to, and then select the bucket.
- Select the script file as required.
- For Object name prefix, specify a prefix for the file you upload to easily identify it when selecting from Object Storage.
- Select Upload and select to store the script in the bucket and select the script for the task.
- Switch on the Save as a catalog item toggle if the script should be stored as a catalog item. Then, specify the name of the stored catalog item.
- If the script addition is through private catalog in substep d, select the compartment that contains the catalog item and then select the catalog item or use inline command. For usage of command, see substep n.
- Switch on the Make script executable toggle to enable automatic execution of the script file.
- Switch on the Lock script toggle to prevent the execution of the script when updated in Object Storage bucket.
-
Switch on the Add input variables toggle if the task requires input variables, and then enter the following details:
- Enter a unique name and description for the variable. Avoid entering confidential information.
- For Type, select string or output variable. For example, select the type as output variable if you want the variable value to be used as an input variable for another task.
Add more input variables as needed.
- Switch on the Add output variables toggle if the task generates output variables. Then, enter a unique name for the variable. Add more output variables as needed.
- (Optional)
If task execution is based on several files, in the Command box, provide the command to start the execution. Provide the command to let Fleet Application Management know on how to execute the script. The script can be a ZIP file, a JAR file, an EXE file, or any other program that can be run on the instance. The variables defined for the task can be passed to the script either as place arguments or key-value arguments. When passing a variable as an argument, prefix it with "$." For example, to use the ZIP and JAR files:
- Enter the
unzip zippedfile.zip
command to unzip the file that contains all files, and then enter the./main.sh
command to begin the execution. - To pass variables to the command, provide them as command line arguments. See the following types of command line arguments. See the following types of command line arguments:
- For static arguments, provide them directly as arguments (for example, if the task script expects a timeout value), the argument can be as follows:
./main.sh 10s
- For dynamic arguments based on the ones configured in the task (for example, if it expects timeout and backuptype), the argument can be as follows:
./main.sh $timeout $backuptype
- For a combination of static and dynamic arguments, the argument can be as follows:
./main.sh 10s $backuptype
- For static arguments, provide them directly as arguments (for example, if the task script expects a timeout value), the argument can be as follows:
- Enter the following JAR command for dynamic arguments (backuptype and timeout):
java -jar ApplicationBackup.jar $backuptype $timeout
- Enter the
- (Optional)
Select a credential compartment and credential names that you created in Vault
if not defined for the product or product stack.
Important
If the task requires a credential, you must create it under metadata management and provide its details for a fleet, resource, or target credential. Fleet Application Management then passes these details for the runbook task execution.
-
If you selected Run a terraform in step 2, enter the following information under Terraform details as needed.
- Select an existing Marketplace or private Terraform catalog item from the specific compartment.
-
If you selected an existing Marketplace( OCI Core Landing Zone) package from a specific compartment in substep a, create a private catalog item for the "Terraform package" type to create a custom Terraform package.
- Create a private catalog item of the CONFIG_FILE package type that contains a sample
config.json
. - Upload the
config.json
to an Object Storage bucket and create a PAR URL link for it. - For Select config file from catalog, select the corresponding Terraform package catalog item that contains the PAR URL link to the
config.json
file as mentioned in the previous step.The following is a sample
config.json
file:{ "service_label": "cisbasic", "network_admin_email_endpoints": ["email.address@example.com"], "security_admin_email_endpoints": ["email.address@example.com"], "enable_cloud_guard": true }
For information about all the configuration variables of OCI Core Landing Zone catalog item, see OCI Core Landing Zone Variables.
- Create a private catalog item of the CONFIG_FILE package type that contains a sample
- If you selected an existing configuration private catalog item from a specific compartment in substep a, create a private catalog item for "Terraform package" type to create a custom configuration package.
-
Select a target compartment where the Compute instances, database resources, block volumes, or network resources created after the execution of the Terraform package can reside.
Note
Allocating different compartments for different resources makes resources more secure, manageable, and scalable. - Turn on the Read output variable toggle to allow the output variables generated by Terraform's execution to be read and used as input for the next task.
-
Under Task properties, enter the following details:
- Max retries on failure: Specify a value for the number of times a task should retry when it fails.
- Timeout: Specify a timeout value for a task in seconds when it fails.
See Task Properties.
- To create a copy of the task in the task library, turn on the Make a copy of this task in library. This task is then a part of the task library and you can reuse and update this library task.
- Select Create.
Use the oci fleet-apps-management fleet-apps-management-runbooks task-record create command and required parameters to create a runbook task:
oci fleet-apps-management fleet-apps-management-runbooks task-record create --compartment-id <compartment_OCID> --details <json_file_or_string> -display-name <text> [OPTIONS]
For a complete list of flags and variable options for Fleet Application Management CLI commands, see the CLI for Fleet Application Management.
Run the CreateTaskRecord operation to create a runbook task.