# Installer Installation Strategy Configuration Fragment

[[elements]]
border_bottom = false
border_top = true
name = "installation_section_header"
title = "🔧 Installation Strategy"
type = "section_header"

# Installation Mode
[[elements]]
default = "interactive"
help = "Installation mode and UI"
name = "installation_mode"
nickel_path = ["installer", "installation", "mode"]
options = ["interactive", "unattended", "api"]
prompt = "Installation Mode"
type = "select"

# Parallel Service Installation
[[elements]]
default = 1
help = "Number of services to install in parallel (range: 1-10, 1 = sequential)"
max = 10
min = 1
name = "parallel_services"
nickel_path = ["installer", "installation", "parallel_services"]
prompt = "Parallel Services"
type = "number"

# Installation Timeout
[[elements]]
default = 1800
help = "Installation timeout in seconds (range: 0-14400, 0 = no timeout)"
max = 14400
min = 0
name = "installation_timeout_seconds"
nickel_path = ["installer", "installation", "timeout_seconds"]
prompt = "Installation Timeout (seconds)"
type = "number"

# Rollback Strategy
[[elements]]
default = true
help = "Automatically rollback on installation failure"
name = "rollback_on_failure"
nickel_path = ["installer", "installation", "rollback_on_failure"]
prompt = "Rollback on Failure"
type = "confirm"

[[elements]]
condition = "rollback_on_failure == true"
default = "automatic"
help = "Rollback strategy when failure occurs"
name = "rollback_strategy"
nickel_path = ["installer", "installation", "rollback_strategy"]
options = ["automatic", "manual", "snapshot"]
prompt = "Rollback Strategy"
type = "select"

[[elements]]
condition = "rollback_on_failure == true && rollback_strategy == 'snapshot'"
default = true
help = "Create system snapshot before installation for rollback"
name = "create_pre_install_snapshot"
nickel_path = ["installer", "installation", "create_snapshot"]
prompt = "Create Pre-Install Snapshot"
type = "confirm"

# Installation Logging
[[elements]]
default = "info"
help = "Installation logging verbosity"
name = "log_level"
nickel_path = ["installer", "installation", "log_level"]
options = ["debug", "info", "warn", "error"]
prompt = "Log Level"
type = "select"

[[elements]]
default = "/var/log/provisioning-installer"
help = "Directory for installation logs"
name = "log_directory"
nickel_path = ["installer", "installation", "log_directory"]
prompt = "Log Directory"
type = "text"

[[elements]]
default = true
help = "Write installation logs to file"
name = "write_logs_to_file"
nickel_path = ["installer", "installation", "write_to_file"]
prompt = "Write Logs to File"
type = "confirm"

[[elements]]
default = false
help = "Upload installation logs to remote server"
name = "upload_logs"
nickel_path = ["installer", "installation", "upload_logs", "enabled"]
prompt = "Upload Logs"
type = "confirm"

[[elements]]
condition = "upload_logs == true"
default = ""
help = "Remote log server URL"
name = "log_server_url"
nickel_path = ["installer", "installation", "upload_logs", "server_url"]
prompt = "Log Server URL"
required = true
type = "text"

# Artifact Handling
[[elements]]
default = false
help = "Keep temporary artifacts after installation completes"
name = "keep_artifacts"
nickel_path = ["installer", "installation", "keep_artifacts"]
prompt = "Keep Artifacts"
type = "confirm"

[[elements]]
condition = "keep_artifacts == true"
default = "/var/tmp/provisioning-install-artifacts"
help = "Directory for keeping installation artifacts"
name = "artifacts_directory"
nickel_path = ["installer", "installation", "artifacts_directory"]
prompt = "Artifacts Directory"
type = "text"

# Installation Hooks
[[elements]]
default = false
help = "Execute custom scripts during installation"
name = "enable_hooks"
nickel_path = ["installer", "installation", "hooks", "enabled"]
prompt = "Enable Installation Hooks"
type = "confirm"

[[elements]]
condition = "enable_hooks == true"
default = ""
help = "Script to run before installation starts"
name = "pre_install_hook"
nickel_path = ["installer", "installation", "hooks", "pre_install_script"]
prompt = "Pre-Install Hook Script"
type = "text"

[[elements]]
condition = "enable_hooks == true"
default = ""
help = "Script to run after installation completes successfully"
name = "post_install_hook"
nickel_path = ["installer", "installation", "hooks", "post_install_script"]
prompt = "Post-Install Hook Script"
type = "text"

[[elements]]
condition = "enable_hooks == true"
default = ""
help = "Script to run on installation failure"
name = "on_failure_hook"
nickel_path = ["installer", "installation", "hooks", "on_failure_script"]
prompt = "On-Failure Hook Script"
type = "text"

# Validation After Installation
[[elements]]
default = true
help = "Validate installation was successful"
name = "validate_installation"
nickel_path = ["installer", "installation", "validation", "enabled"]
prompt = "Validate Installation"
type = "confirm"

[[elements]]
condition = "validate_installation == true"
default = 30000
help = "Installation validation timeout in milliseconds (range: 5000-300000)"
max = 300000
min = 5000
name = "validation_timeout"
nickel_path = ["installer", "installation", "validation", "timeout_ms"]
prompt = "Validation Timeout (ms)"
type = "number"

[[elements]]
condition = "validate_installation == true"
default = true
help = "Check all services are running"
name = "validate_services_running"
nickel_path = ["installer", "installation", "validation", "services_running"]
prompt = "Validate Services Running"
type = "confirm"

[[elements]]
condition = "validate_installation == true"
default = true
help = "Validate network connectivity"
name = "validate_connectivity"
nickel_path = ["installer", "installation", "validation", "connectivity"]
prompt = "Validate Connectivity"
type = "confirm"

# Auto-Recovery
[[elements]]
default = false
help = "Enable automatic recovery if services fail after installation"
name = "auto_recovery_enabled"
nickel_path = ["installer", "installation", "auto_recovery", "enabled"]
prompt = "Enable Auto-Recovery"
type = "confirm"

[[elements]]
condition = "auto_recovery_enabled == true"
default = 3
help = "Maximum number of recovery attempts"
max = 10
min = 1
name = "auto_recovery_max_attempts"
nickel_path = ["installer", "installation", "auto_recovery", "max_attempts"]
prompt = "Max Recovery Attempts"
type = "number"

[[elements]]
condition = "auto_recovery_enabled == true"
default = 30
help = "Delay in seconds before attempting recovery"
min = 5
name = "auto_recovery_delay_seconds"
nickel_path = ["installer", "installation", "auto_recovery", "delay_seconds"]
prompt = "Recovery Delay (seconds)"
type = "number"
