Skip to content

feat: add infra filters for terraform, nix, ansible, and opentofu#769

Open
BSD-Yassin wants to merge 4 commits intortk-ai:masterfrom
BSD-Yassin:feat/infra-filters-tofu
Open

feat: add infra filters for terraform, nix, ansible, and opentofu#769
BSD-Yassin wants to merge 4 commits intortk-ai:masterfrom
BSD-Yassin:feat/infra-filters-tofu

Conversation

@BSD-Yassin
Copy link

Summary

  • Add first-class rtk terraform, rtk nix, and rtk ansible-playbook support for compact infra output with gain tracking.
  • Add first-class rtk tofu support as a Terraform-equivalent command by reusing the Terraform filter pipeline and preserving OpenTofu-specific tracking labels.
  • Extend discover rewrite coverage so terraform, nix, ansible-playbook, and tofu commands are recognized and rewritten to RTK equivalents.

Test plan

  • cargo fmt --all
  • cargo clippy --all-targets
  • cargo test --all
  • Runtime validation in nix-shell with real tools (terraform, opentofu, ansible, nix) using raw-vs-rtk comparisons:
    • Terraform plan: 20 -> 3 lines
    • OpenTofu plan: 20 -> 2 lines
    • Ansible playbook: 11 -> 4 lines
    • Nix search: 113383 -> 21 lines
  • Verify gain tracking entries for all commands:
    • rtk terraform plan -no-color
    • rtk tofu plan -no-color
    • rtk nix search nixpkgs hello
    • rtk ansible-playbook ...
  • Validate discover rewrite behavior:
    • rtk rewrite "tofu plan -lock=false"
    • rtk rewrite "terraform apply -auto-approve"
    • rtk rewrite "nix search nixpkgs hello"
    • rtk rewrite "ansible-playbook ..."

Notes

  • Smoke script run (bash scripts/test-all.sh) reports known environment-related failures unrelated to this change (learn/discover need Claude sessions, and script used an older globally installed rtk binary).

Introduce dedicated rtk nix and rtk terraform handlers to keep high-signal infra output while dropping progress and attribute-level noise. This preserves actionable plan/search summaries and records savings in tracking history for gain analytics.
Introduce a dedicated ansible-playbook handler that keeps task/recap/failure signals while dropping routine noise, and wire it into CLI routing and integrity-protected operational commands so gains are tracked directly.
Treat OpenTofu as a Terraform-equivalent RTK command so infra plans are compressed consistently, tracked in gain history, and rewritten from discover hooks.
@CLAassistant
Copy link

CLAassistant commented Mar 21, 2026

CLA assistant check
All committers have signed the CLA.

@pszymkowiak pszymkowiak added effort-large Plusieurs jours, nouveau module enhancement New feature or request labels Mar 21, 2026
@pszymkowiak
Copy link
Collaborator

[w] wshm · Automated triage by AI

📊 Automated PR Analysis

Type feature
🟡 Risk medium

Summary

Adds first-class RTK filter support for Terraform, OpenTofu, Nix, and Ansible-playbook commands, providing compact output with gain tracking. Also extends the discover/rewrite system to recognize and rewrite these commands to their RTK equivalents.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Analyzed automatically by wshm · This is an automated analysis, not a human review.

Add an infrastructure command section in the README and record the new first-class infra filters in the Unreleased changelog so the PR scope is explicit for reviewers.
@BSD-Yassin
Copy link
Author

Those tools are heavy in my daily workflow, and while debugging an issue, they can be launched in conjunction with aws-cli, docker, curl and eat a lot of tokens. Take this PR as my first reduction of token and the start of a lot of "infra/devops" related reduction.

Note : I have not added any automated tests. That could obviously be a blocking step that can be discussed here.

The nix command should be alright to test directly on the pipeline or locally but for terraform, ansible and opentofu, I didn't want to create a whole infra for testing each use case.

Nor did I want to create an output model file, as I assume that any of those tools will evolve in the future and it would require this output file would need to follow version changes. I have yet to think of a fair solution, I suppose all of them are able to create local resources, that would make a good compromise for an execution test all while not reaching a remote instance to provision / configure.

Feel free to ask any questions, remarks or require any improvements, as it is one of my rare contributions, and do note that I obviously helped myself with IA to produce it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort-large Plusieurs jours, nouveau module enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants