Bug 1077251

Summary: RFE: Make distro and friends available in kickstart as well
Product: [Retired] Beaker Reporter: Alexander Todorov <atodorov>
Component: generalAssignee: Dan Callaghan <dcallagh>
Status: CLOSED CURRENTRELEASE QA Contact: tools-bugs <tools-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 0.16CC: aigao, asaha, dcallagh, dowang, tools-bugs
Target Milestone: 20.0Keywords: FutureFeature, NeedsTestCase, Patch
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-04-20 02:23:11 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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.