02 - Variables and System Facts¶
Learn how to define custom variables and use Mooncake's comprehensive system facts.
What You'll Learn¶
- Defining custom variables with
vars - Using all available system facts
- Combining custom variables with system facts
- Using variables in file operations
Quick Start¶
What It Does¶
- Defines custom application variables
- Displays all system facts (OS, hardware, network, software)
- Creates files using both custom variables and system facts
Key Concepts¶
Custom Variables¶
Define your own variables:
Use them in commands and paths:
System Facts¶
Mooncake automatically collects system information:
Basic:
os- Operating system (linux, darwin, windows)arch- Architecture (amd64, arm64)hostname- System hostnameuser_home- User's home directory
Hardware:
cpu_cores- Number of CPU coresmemory_total_mb- Total RAM in megabytes
Distribution:
distribution- Distribution name (ubuntu, debian, macos, etc.)distribution_version- Full version (e.g., "22.04")distribution_major- Major version number
Software:
package_manager- Detected package manager (apt, yum, brew, etc.)python_version- Installed Python version
Network:
ip_addresses- Array of IP addressesip_addresses_string- Comma-separated IP addresses
Variable Substitution¶
Variables work everywhere:
Seeing All Facts¶
Run mooncake facts to see all facts for your system:
Next Steps¶
→ Continue to 03-files-and-directories to learn about file operations.