Excerpts from Nick Coghlan's message of 2014-02-27 14:29:23 +1000:
Sort of - the template conditions in some cases currently look like:
"distro is osmajor('RedHatEnterpriseLinux7')".
Yes that is a Jinja filter, shorthand for:
distro.osversion.osmajor.osmajor == 'RedHatEnterpriseLinux7'
The important thing is that we are talking about (at the database level)
a new relationship from OSMajor to OSMajor.
How we expose it in the templates is less important, although I would be
inclined to expose the actual OSMajor instance (rather than its name)
just for consistency. In fact we needn't expose it as a new variable at
all, it would be reachable from the distro variable just as the ordinary
OSMajor currently is.
So instead of distro.osversion.osmajor it becomes
distro.osversion.osmajor.base_osmajor. We could even encapsulate that in
the existing 'osmajor' Jinja filter so that the current template
conditions that use "distro is osmajor()" remain unchanged. This way
users don't have to update their custom snippets to obey base_osmajor.
Or if that is too magical it could be a separate Jinja filter,
based_on_osmajor:
distro is based_on_osmajor('RedHatEnterpriseLinux7')
The startswith case you quoted should probably be extracted to a Jinja
filter as well, analogous to the osmajor() filter. Maybe:
distro is osmajor('Fedora', match_prefix=True)
although I can't remember if Jinja filters can accept named args....
--
Dan Callaghan <dcallagh(a)redhat.com>
Software Engineer, Hosted & Shared Services
Red Hat, Inc.