Class RunCLI
java.lang.Object
com.scivicslab.actoriac.cli.RunCLI
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final recordRecord for displaying workflow information. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate Stringprivate ExecutorServiceDedicated executor service for DB writesprivate Stringprivate Fileprivate Stringprivate booleanprivate static final Loggerprivate Fileprivate Fileprivate DistributedLogStoreDistributed log store (H2 database)private com.scivicslab.pojoactor.core.ActorRef<DistributedLogStore> Actor reference for the log store (for async writes)private intprivate booleanprivate booleanprivate Fileprivate booleanprivate Fileprivate longCurrent session ID for distributed loggingprivate intprivate booleanCache of discovered workflow files: name -> Fileprivate Fileprivate String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate StringBuilds a command line string from the current options.call()Executes the workflow.private voidconfigureLogLevel(boolean verbose) Configures log level based on verbose flag.private voidendSession(SessionStatus status) Ends the current session with the given status.private IntegerMain execution logic.private IntegerexecuteWorkflow(File mainWorkflowFile) Executes workflow with node-based execution.private static StringextractNameFromJson(File file) Extracts name field from JSON file.private static StringextractNameFromYaml(File file) Extracts name field from YAML file using simple line parsing.private static StringextractWorkflowName(File file) Extracts the workflow name from a YAML/JSON/XML file.findWorkflowFile(String path) Finds a workflow file by path relative to workflowDir.private StringGets the git commit hash of the actor-IaC installation.private static StringgetBaseName(String fileName) private StringgetGitBranch(File dir) Gets the git branch name of the specified directory.private StringgetGitCommit(File dir) Gets the git commit hash of the specified directory.private booleanisWorkflowFile(Path path) Checks if a file is a workflow file (YAML, JSON, or XML).private com.scivicslab.pojoactor.core.ActionResultloadMainWorkflow(NodeGroupIIAR nodeGroupActor, File workflowFile, File overlayDir) Loads the main workflow file with optional overlay support.private voidLogs a message to the distributed log store if available.private voidPrints available cowfiles for cowsay output customization.private voidprivate StringpromptForPassword(String prompt) Prompts for a password from the console.private voidregisterWorkflowFile(Path path) Registers a workflow file in the cache.private static Stringrelativize(Path base, Path target) private IntegerRenders overlay-applied workflows to the specified directory.private voidScans the immediate directory for workflow files (non-recursive).private static List<RunCLI.WorkflowDisplay> scanWorkflowsForDisplay(File directory) Scans the immediate directory for workflow files (non-recursive).private voidSets up H2 database for distributed logging.private voidSets up text file logging via H2LogStore.private voidSuppresses all console output (stdout/stderr) for quiet mode.
-
Field Details
-
LOG
-
workflowDir
-
workflowName
-
inventoryFile
-
groupName
-
threads
-
verbose
-
overlayDir
-
logFile
-
noLog
-
logDbPath
-
noLogDb
-
askPass
-
limitHosts
-
listWorkflows
-
quiet
-
cowfile
-
renderToDir
-
maxSteps
-
workflowCache
Cache of discovered workflow files: name -> File -
logStore
Distributed log store (H2 database) -
logStoreActor
Actor reference for the log store (for async writes) -
dbExecutor
Dedicated executor service for DB writes -
sessionId
Current session ID for distributed logging
-
-
Constructor Details
-
RunCLI
public RunCLI()
-
-
Method Details
-
call
-
suppressConsoleOutput
Suppresses all console output (stdout/stderr) for quiet mode. -
setupLogDatabase
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
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
Configures log level based on verbose flag. -
executeMain
Main execution logic. -
renderOverlayWorkflows
Renders overlay-applied workflows to the specified directory. -
executeWorkflow
Executes workflow with node-based execution. -
logToDb
-
endSession
Ends the current session with the given status. -
promptForPassword
Prompts for a password from the console. -
scanWorkflowDirectory
Scans the immediate directory for workflow files (non-recursive).- Since:
- 2.12.1
-
isWorkflowFile
Checks if a file is a workflow file (YAML, JSON, or XML). -
registerWorkflowFile
Registers a workflow file in the cache. -
findWorkflowFile
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
-
printAvailableCowfiles
Prints available cowfiles for cowsay output customization. -
getBaseName
-
relativize
-
scanWorkflowsForDisplay
Scans the immediate directory for workflow files (non-recursive).- Since:
- 2.12.1
-
extractWorkflowName
Extracts the workflow name from a YAML/JSON/XML file. -
extractNameFromYaml
Extracts name field from YAML file using simple line parsing. -
extractNameFromJson
Extracts name field from JSON file. -
getGitCommit
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
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
-