Skip to content

Feat/add open tofu support - #5

Merged
bartrosa merged 5 commits into
mainfrom
feat/add-open-tofu-support
Jul 18, 2026
Merged

bartrosa merged 5 commits into
mainfrom
feat/add-open-tofu-support

Conversation

@bartrosa

Copy link
Copy Markdown
Owner

Summary

Add lab tofu under the infra command group: install the OpenTofu binary via OS-native methods, then orchestrate tofu against IaC stack directories.

Install (lab tofu install / version)

  • Detects platform via internal/platform and picks a method:
    • macOSbrew install|upgrade opentofu
    • Linux apt → official install-opentofu.sh --install-method deb
    • Linux dnf / rpm-ostree--install-method rpm
    • Linux fallbacksnap install --classic opentofu
    • Windowswinget install OpenTofu.OpenTofu
  • Does not manage apt/rpm repo keys itself — delegates to brew / official script / snap / winget
  • Supports --dry-run (prints planned method + commands) and --upgrade

Orchestration (init / validate / plan / apply / fmt)

  • Thin Cobra wrappers around tofu -chdir=<stack> … via internal/exec
  • apply requires --yes for -auto-approve (default is interactive)
  • Secrets (TF_VAR_*, passwords) are intended to come from op run / env injection — not from files on disk
  • Stack argument is a filesystem path today; resolving bare names under homelab.root/hq-infra is left as a TODO

Docs / wiring

  • Package: internal/tofu
  • CLI: internal/cli/commands/tofu.go, registered in root.go (infra)
  • docs/architecture.md updated (package table + command group)

Test plan

  • make fmt && make vet && make lint && make build
  • go test ./... (or make test / CI with -race)
  • lab tofu install --dry-run shows correct method for this host (deb on Ubuntu/apt)
  • lab tofu install then lab tofu version
  • lab tofu plan <stack-path> --dry-run prints planned tofu -chdir=… plan
  • lab tofu apply <stack-path> without --yes does not pass -auto-approve
  • lab tofu apply <stack-path> --yes passes -auto-approve

bartrosa added 5 commits July 18, 2026 15:09
Introduced the OpenTofu package, which includes methods for installing the OpenTofu binary across different platforms (macOS, Linux, Windows) and orchestrating commands against IaC stack directories. Added comprehensive tests for installation detection methods and command execution, ensuring robust functionality and user experience.
Introduced the Tofu command, enabling users to install the OpenTofu binary and orchestrate Infrastructure as Code (IaC) stacks. The command includes subcommands for installation, version checking, and applying stack changes, enhancing the CLI's functionality for managing OpenTofu operations.
Added the Tofu command to the CLI under the "infra" category, enhancing the command set for managing OpenTofu operations. This integration supports improved user interaction with the Tofu functionalities.
…ture category

Added the Tofu command to the architecture documentation, reflecting its role in managing OpenTofu installations and orchestration within the infrastructure category. This update enhances clarity on the command structure and available functionalities.
Updated the error message in the Tofu installation detection method to use lowercase for "homebrew," ensuring consistency and clarity in user feedback when Homebrew is not found on macOS.
@bartrosa
bartrosa merged commit db875f7 into main Jul 18, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant