Class RunCLI

java.lang.Object
com.scivicslab.actoriac.cli.RunCLI
All Implemented Interfaces:
Callable<Integer>

public class RunCLI extends Object implements Callable<Integer>
CLI subcommand to execute actor-IaC workflows.

This is the main workflow execution command. It supports executing workflows defined in YAML, JSON, or XML format with optional overlay configuration.

Usage

actor-iac run -d /path/to/workflows -w main-workflow.yaml
actor-iac run --dir ./workflows --workflow deploy --threads 8
actor-iac run -d ./workflows -w deploy -i inventory.ini -g webservers
Since:
2.10.0
Author:
devteam@scivicslab.com
  • Field Details

  • Constructor Details

  • Method Details

    • call

      public Integer call()
      Executes the workflow.
      Specified by:
      call in interface Callable<Integer>
      Returns:
      exit code (0 for success, non-zero for failure)
    • suppressConsoleOutput

      private void suppressConsoleOutput()
      Suppresses all console output (stdout/stderr) for quiet mode.
    • setupLogDatabase

      private void setupLogDatabase() throws SQLException
      Sets up H2 database for distributed logging.

      Uses H2's AUTO_SERVER mode which automatically handles multiple processes accessing the same database. The first process starts a TCP server, and subsequent processes connect to it automatically.

      Throws:
      SQLException
    • setupTextLogging

      private void setupTextLogging() throws IOException
      Sets up text file logging via H2LogStore.

      This method configures the H2LogStore to also write log entries to a text file, in addition to the H2 database. Only called when -l/--log option is explicitly specified.

      Throws:
      IOException
    • configureLogLevel

      private void configureLogLevel(boolean verbose)
      Configures log level based on verbose flag.
    • executeMain

      private Integer executeMain()
      Main execution logic.
    • renderOverlayWorkflows

      Renders overlay-applied workflows to the specified directory.
    • executeWorkflow

      private Integer executeWorkflow(File mainWorkflowFile)
      Executes workflow with node-based execution.
    • logToDb

      private void logToDb(String nodeId, LogLevel level, String message)
      Logs a message to the distributed log store if available.
    • endSession

      private void endSession(SessionStatus status)
      Ends the current session with the given status.
    • promptForPassword

      private String promptForPassword(String prompt)
      Prompts for a password from the console.
    • scanWorkflowDirectory

      private void scanWorkflowDirectory(Path dir)
      Scans the immediate directory for workflow files (non-recursive).
      Since:
      2.12.1
    • isWorkflowFile

      private boolean isWorkflowFile(Path path)
      Checks if a file is a workflow file (YAML, JSON, or XML).
    • registerWorkflowFile

      private void registerWorkflowFile(Path path)
      Registers a workflow file in the cache.
    • findWorkflowFile

      public File findWorkflowFile(String path)
      Finds a workflow file by path relative to workflowDir.

      Supports paths like "sysinfo/main-collect-sysinfo.yaml" or "sysinfo/main-collect-sysinfo" (extension auto-detected).

      Parameters:
      path - workflow file path relative to workflowDir
      Returns:
      the workflow file, or null if not found
      Since:
      2.12.1
    • loadMainWorkflow

      private com.scivicslab.pojoactor.core.ActionResult loadMainWorkflow(NodeGroupIIAR nodeGroupActor, File workflowFile, File overlayDir)
      Loads the main workflow file with optional overlay support.
    • printWorkflowList

      private void printWorkflowList()
    • printAvailableCowfiles

      private void printAvailableCowfiles()
      Prints available cowfiles for cowsay output customization.
    • getBaseName

      private static String getBaseName(String fileName)
    • relativize

      private static String relativize(Path base, Path target)
    • scanWorkflowsForDisplay

      Scans the immediate directory for workflow files (non-recursive).
      Since:
      2.12.1
    • extractWorkflowName

      private static String extractWorkflowName(File file)
      Extracts the workflow name from a YAML/JSON/XML file.
    • extractNameFromYaml

      private static String extractNameFromYaml(File file)
      Extracts name field from YAML file using simple line parsing.
    • extractNameFromJson

      private static String extractNameFromJson(File file)
      Extracts name field from JSON file.
    • getGitCommit

      private String getGitCommit(File dir)
      Gets the git commit hash of the specified directory.
      Parameters:
      dir - directory to check (uses current directory if null)
      Returns:
      short git commit hash, or null if not a git repository
    • getGitBranch

      private String getGitBranch(File dir)
      Gets the git branch name of the specified directory.
      Parameters:
      dir - directory to check (uses current directory if null)
      Returns:
      git branch name, or null if not a git repository
    • buildCommandLine

      Builds a command line string from the current options.
      Returns:
      command line string
    • getActorIacCommit

      Gets the git commit hash of the actor-IaC installation. This looks for a .git directory relative to where actor-IaC is running.
      Returns:
      short git commit hash, or null if not available