Leonid Flaks wrote:
Hi!
I am trying to use download_config_files snippet on cobbler-1.6.6.
I've read
https://fedorahosted.org/cobbler/wiki/ModPythonDetails
and
https://fedorahosted.org/cobbler/wiki/BuiltinConfigManagement
Here is the question:
If I want to use the template x.template (taken from example in the link
above), where should I put the template file for cobbler to serve it?
Thanks,
There is an inherited variable in distros on down called template_files
which takes a dictionary. The keys are the location of the templates on
the cobbler server and the values are the location on the client.
We use a 'fakeroot' file structure on our file system under which we put
all of the template files we want served and where we want them. Then
we have a simple python script which uses the cobbler API to update the
profiles we want the files associated with. For example:
/opt/pub/config/root/.ssh/authorized_keys on the server is downloaded to
/root/.ssh/authorized_keys by the kickstart via mod python.
Do note, however, that the snippet uses http via wget to actually
download the files, so permissions are not maintained. I made a
workaround by modifying the snippet to grab the file permissions and
chmod the file immediately after it's downloaded. I've attached the patch.
--
Benjamin Riggs
System Staff
School of Mathematics
University of Minnesota
diff -u cobbler/var/lib/cobbler/snippets/download_config_files download_config_files
--- cobbler/var/lib/cobbler/snippets/download_config_files 2009-06-10
11:38:21.000000000 -0500
+++ download_config_files 2009-11-10 18:17:11.000000000 -0600
@@ -1,4 +1,6 @@
# Start download cobbler managed config files (if applicable)
+#import os
+#import stat
#for $tkey, $tpath in $template_files.items()
#set $orig = $tpath
#set $tpath =
$tpath.replace("_","__").replace("/","_")
@@ -11,8 +13,10 @@
#end if
#set $turl =
"http://"+$http_server+"/cblr/svc/op/template/"+$ttype+"/"+$tname+"/path/"+$tpath
#if $orig.startswith("/")
+#set $perms = oct(stat.S_IMODE(os.stat($tkey).st_mode))[-3:]
mkdir -p `dirname $orig`
-wget "$turl" --output-document="$orig"
+wget -nv "$turl" --output-document="$orig"
+chmod $perms $orig
#end if
#end for
# End download cobbler managed config files (if applicable)