Disclaimer: ---------------- -- I apologize if this has been previously dealt with -- I fully understand that the advanced snippet mechanism can handle this more simply. -- I'm just trying to determine if I've made a mistake or if cobbler's rendering of cheetah won't do what I think it will and/or should.
Setup: -------------------- I've been using the recipes and included snippets to get better at using cheetah inside cobbler. I attempted to use a recipe for including packages by name on the wiki at https://fedorahosted.org/cobbler/wiki/KickstartSnippets#PackageSelectionbyho...
This didn't appear to work for me for some reason, so I reformatted to the following as a test: #set $hostname = "X"
#if $hostname == None -- None #else #set $hostpart = $getVar('$hostpart', None) #if $hostpart == None #set $hostpart = $hostname.split('.')[0] #end if #set $sourcefile = "/var/lib/cobbler/packages/" + $hostpart ABOUT TO TRY #try #for $b in $hostname $b #end for INSIDE TRY -- $sourcefile #include $sourcefile #except INSIDE EXCEPT -- No $sourcefile #end try #end if
I included the snippet in a kickstart file and got the following result ABOUT TO TRY X INSIDE TRY -- /var/lib/cobbler/packages/X # Unable to read /var/lib/cobbler/packages/X
Since the file /var/lib/cobbler/packages/X doesn't exist, I would expect the result to be something like ABOUT TO TRY X INSIDE TRY -- /var/lib/cobbler/packages/X INSIDE EXCEPT -- No /var/lib/cobbler/packages/X
Pre-Questions: ------------------------
I thought this worked in the past. Did it previously work and now the recipe on the wiki simply invalid? -- This appears to be true. I cannot get the #except block to fire for a missing #include. It just reports that the file is missing and moves along. Does Cheetah's #include not produce an exception on failure? -- executing 'cheetah fill ...' from the command line DOES fire an exception on the failed include -- inside cobbler the except doesn't seem to fire (just reports failure), but any other exception (like calling an invalid method call on the rendered $b above) DOES fire the exception. The only conclusion I can reach is that cobbler behaves differently than "cheetah fill" with regard to #include, which is reasonable but unexpected.
The REAL Question: -------------------------- Is it at all possible to detect when cobbler tries to import a missing file with a cheetah #include ?
Any information about this (or even better, about how my reasoning is flawed) would be greatly appreciated.
Thanks, Mykel
cobbler@lists.fedorahosted.org