Bug 1077251 - RFE: Make distro and friends available in kickstart as well
Summary: RFE: Make distro and friends available in kickstart as well
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Beaker
Classification: Retired
Component: general
Version: 0.16
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: 20.0
Assignee: Dan Callaghan
QA Contact: tools-bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-03-17 15:07 UTC by Alexander Todorov
Modified: 2018-02-06 00:41 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Enhancement
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-04-20 02:23:11 UTC
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 966348 0 unspecified CLOSED Document models exposed to admin kickstart templates 2021-02-22 00:41:40 UTC

Internal Links: 966348

Description Alexander Todorov 2014-03-17 15:07:33 UTC
Description of problem:

From:
https://beaker-project.org/docs/admin-guide/kickstarts.html#writing-kickstart-templates


I was trying to use the 
{% if distro is osmajor('RedHatEnterpriseLinux5') %}

in a kickstart template but that failed - J:613479. Bill Peck figured it out:

(16,54,34) bpeck: atodorov, I see whats wrong
(16,54,56) bpeck: those methods/variables are only available from snippets
(16,55,44) bpeck: I would open a bz/RFE requesting that you be able to use those from a kickstart as well.  not just from snippets.


Please make all of the variables/template tags available to the kickstart section as well.

Comment 2 Dan Callaghan 2015-01-12 06:16:10 UTC
Those model objects are intentionally not exposed to user-supplied templates, because Jinja lets the template call arbitrary methods on the objects. The code does attempt to prevent changes being committed to the db but it may not be perfect. Also there are other operations which are exposed as model methods, so a user template might be able to accidentally or maliciously do things like send e-mails.

They are different than the ordinary ksmeta variables which are just strings or bools.

We could probably make a fake version of the distro, distro_tree, and system model objects appear in the context for user templates and that would be enough for all sensible use cases.

Comment 3 Alexander Todorov 2015-01-12 10:00:46 UTC
Hi Dan,
at the moment we have templates which rely on the following:

* CPU arch
* OS major
* OS family
* OS variant

without corresponding info in ks_meta they can't be rewritten to be rendered on the server. I'm fine with a few extra variables in ks_meta if this is the only way to resolve it. 

I'll see if I can send a patch for that.

Comment 4 Dan Callaghan 2015-01-22 06:00:29 UTC
I would rather expose a dummy version of the real model objects, for user templates, with just the useful attributes populated on them. That way the same template constructs work in both user and server templates. I think we can do it without too much mess.

Comment 5 Dan Callaghan 2015-01-22 06:29:51 UTC
Okay, first step is to write down what exactly is available to the templates. I have a patch for that on bug 966348.

This patch sets up "fake" distro and distro_tree variables which have the same documented attributes, which means the custom Jinja filters like is_arch, is_osmajor will work the same way with them.

http://gerrit.beaker-project.org/3946

Comment 10 Dan Callaghan 2015-04-20 02:23:11 UTC
Beaker 20.0 has been released.


Note You need to log in before you can comment on or make changes to this bug.