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.
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.
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.
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.
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
Beaker 20.0 has been released.