Creating a Task

Create a runbook task for patch management in Fleet Application Management.

Note

The tasks that you create using this process are shared tasks and can be used by any runbook.
    1. Open the navigation menu and click Observability & Management. Under Fleet Application Management, click Actions and Controls.
    2. On the Runbooks page, click the Tasks tab.
    3. Click Create task.
    4. In the Create task panel, enter a unique name and description for the task. Avoid entering confidential information.
    5. For Action type, select Run a script to attach a script from Object Storage, or you can add your script inline under Command. See step 15.
    6. (Optional) Select a product or product stack to which the task belongs and the type of OS on which the task runs.
    7. If the task is meant for discovering targets:
      1. 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.
      2. Click 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.
    8. If the task is for applying patches, switch on the This task needs patches to execute toggle.
      If 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.
    9. To add your script for task execution, click Browse next to Select script.
    10. In the Select file panel, 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 step 11.
      • Upload a file: Select a script by uploading it to Object Storage, and skip to step 12.
    11. If you selected Select from an Object Storage bucket:
      1. Select the compartment  that contains the Object Storage bucket with the script, and then select the bucket.
      2. Select the checkbox next to the script files and then click Select. Skip to step 13.
    12. If you selected Upload a file:
      1. Drag a file from the file system to the Drop a file box, or browse for the file.
      2. Select the compartment  that contains the Object Storage bucket that you want to upload the file to, and then select the bucket.
      3. Select the checkbox next to the script files and then click Select. Skip to step 13.
      4. (Optional) For Object name prefix, specify a prefix for the file that you upload to easily identify it when selecting from Object Storage.
      5. Click Upload and select to store the script in the bucket and select the script for the task.
    13. On the Create task panel, if the task requires input variables, switch on the Add input variables toggle and then enter the following details:
      1. Enter a unique name and description for the variable. Avoid entering confidential information.
      2. 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.
    14. If the task generates output variables, switch on the Add output variables toggle and then enter a unique name for the variable. Add more output variables as needed.
    15. (Optional) If task execution is based on several files, in the Command box, provide the command to start the execution of the script. 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:
        • 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
      • Enter the following JAR command for dynamic arguments (backuptype and timeout):
        java -jar ApplicationBackup.jar $backuptype $timeout
    16. (Optional) Select 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.
    17. 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.
    18. Click Create.

    About Discovery Output Template

    The following are the details of the discovery output template attributes in Fleet Application Management.

    • targets: It contains targets for a specific product. A discovery runbook can return several targets for a product or product stack.
    • product: It's an optional attribute for a product's discovery runbook and mandatory for a product stack's discovery runbook because a stack can return several targets for different products. Therefore, Fleet Application Management needs to know the target belongs to which product of the stack. If you don't specify the product attribute for its discovery runbook, Fleet Application Management uses the product associated with the runbook to map the target to the product.
    • target_name: The target's home directory.
    • version: The version of the product.
    • properties: The properties of the product. Use these in the condition builder of the patching runbook to conditionally execute the task.
    • components: The components associated with the product. Use these in the condition builder of the patching runbook to conditionally execute a task.
    • component (properties): The properties of the component. Use these in the condition builder of the patching runbook to conditionally execute a task.
    • resource_name: The name of the Compute instance (optional).
    • installed_patches: It contains patches already installed on the target.
    • available_patches: It contains patches available for installation on the target (optional).
  • 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 [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.