Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate built-in template engines #1475

Open
ferki opened this issue Feb 20, 2021 · 2 comments · May be fixed by #1512
Open

Deprecate built-in template engines #1475

ferki opened this issue Feb 20, 2021 · 2 comments · May be fixed by #1512
Labels
feature request A suggested idea for the project

Comments

@ferki
Copy link
Member

ferki commented Feb 20, 2021

User story

As maintainer,
I would like to deprecate the built-in template engines,
so I can spend more of my efforts on the core capabilities of Rex.

Describe the solution you'd like

Rex::Template was the original templating engine, but its approach had problems, like almost useless diagnostics. So Rex::Template::NG was born to address some of the shortcomings, but its results are still not fully compatible yet, so we never truly made the switch (default engine has changed, but the old one is still around "just in case").

This situation provides some false promises to users, and adds considerable overhead for both users and maintainers. Therefore I'd like to help avoiding the whole rabbit hole in the first place.

I believe templating is complex topic on its own, and it's best to offload the responsibility to external modules, of which there are dozens on CPAN already. That way we could focus more on the core capabilities of Rex, while everyone may pick their preferred templating engine for their needs.

I think we could put up a one-time warning on the first use of any of the built-in engines in a given run, so later when the time comes, get rid of the modules themselves. It would also help raising awareness about the potential problems when using the built-in ones.

Describe alternatives you've considered

Creating our own "best" templating engine, at least in the limited scope of configuration management. It doesn't sound realistic to me.

EDIT: we can try and see if there's a good candidate on CPAN (with lightweight dependencies, compatible syntax, etc.) which we could use as a templating backend by default instead of inventing our own.

Additional context

@ferki ferki added the feature request A suggested idea for the project label Feb 20, 2021
@ferki
Copy link
Member Author

ferki commented Feb 21, 2021

One idea is to use Text::Template::Simple to do the heavy lifting by default instead of our own custom solution(s).

It seems lightweight enough with a compatible syntax. Ideally if there are any diffs in the rendered output compared to the current core modules, all those would classify as bugfix and/or new features. In that case we might be able to plan a gradual shift towards using it.

@ferki
Copy link
Member Author

ferki commented Nov 2, 2021

This is the current state of my ideas about phasing out Rex::Template and Rex::Template::NG:

  • migrate the internal uses of Rex::Template to an external templating engine
    • Text::Template::Simple might already have a compatible syntax, but others could work too
    • make sure passing extra variables to the templating engine still works (e.g. CMDB, inventory, hardware gathering results, etc.)
  • put up a deprecation warning whenever Rex::Template or Rex::Template::NG is imported (make sure to print it only once per rex run)
    • there's already Rex::deprecated() which we might be able to use (or modernize to our deprecation needs)
  • add deprecation warning to the documentation of the affected modules

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request A suggested idea for the project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant