diff --git a/cobbler/kickstarts/default.ks b/cobbler/kickstarts/default.ks
index 9603c7c..f7a1311 100644
--- a/cobbler/kickstarts/default.ks
+++ b/cobbler/kickstarts/default.ks
@@ -75,7 +75,6 @@ $SNIPPET('kickstart_pre_anamon')
%packages --nobase
@core
iproute
-chef
ntp
openssh-clients
wget
@@ -89,6 +88,10 @@ parted
#if $os_version == "rhel7"
net-tools
#end if
+#if $getVar('tool', '') != ''
+ #set $kickstart_software = "kickstart_software_%s" % $tool
+$SNIPPET($kickstart_software)
+#end if
%end
%post --log=/var/log/post_install.log
diff --git a/cobbler/kickstarts/default.seed b/cobbler/kickstarts/default.seed
index f572aa1..c764cf2 100644
--- a/cobbler/kickstarts/default.seed
+++ b/cobbler/kickstarts/default.seed
@@ -79,7 +79,13 @@ $SNIPPET('preseed_apt_repo_config')
# Individual additional packages to install
# wget is REQUIRED otherwise quite a few things won't work
# later in the build (like late-command scripts)
-d-i pkgsel/include string ntp ssh wget chef
+#if $getVar('tool', '') != ''
+ #set $preseed_software = "preseed_software_%s" % $tool
+$SNIPPET($preseed_software)
+#else
+d-i pkgsel/include string ntp ssh wget
+#end if
+
# Whether to upgrade packages after debootstrap.
# Allowed values: none, safe-upgrade, full-upgrade
d-i pkgsel/upgrade select none
diff --git a/cobbler/kickstarts/default.xml b/cobbler/kickstarts/default.xml
new file mode 100644
index 0000000..f9e0222
--- /dev/null
+++ b/cobbler/kickstarts/default.xml
@@ -0,0 +1,229 @@
+## Figure out if we're kickstarting a system or a profile
+#if $getVar('system_name','') != ''
+#set $what = "system"
+#else
+#set $what = "profile"
+#end if
+
+
+
+
+
+]>
+
+
+ false
+
+ ## without the next 6 lines autoyast will ask for confirmation bevore installation
+
+
+ true
+ true
+ true
+ true
+ true
+ true
+
+
+ false
+ true
+
+
+ $SNIPPET('hosts.xml')
+ $SNIPPET('kdump.xml')
+ ##
+ ## english
+ ##
+
+ en_US
+
+
+
+ localtime
+#if $getVar('timezone', '') != ""
+ $timezone
+#else
+ US/Pacific
+#end if
+
+
+
+
+ $SNIPPET('repo_config.xml')
+
+
+
+ base
+
+
+ iputils
+ openssh
+ gcc
+ net-tools
+ ethtool
+ ntp
+ wget
+ rsyslog
+ iproute2
+ parted
+#if $getVar('tool', '') != ''
+ #set $suse_software = "software_%s.xml" % $tool
+$SNIPPET($suse_software)
+#end if
+
+ true
+
+ $SNIPPET('yast_repo_config.xml')
+
+ $SNIPPET('limits_conf.xml')
+ $SNIPPET('ssh.xml')
+ $SNIPPET('sshd.xml')
+ $SNIPPET('sysctl.xml')
+ $SNIPPET('rsyslog.xml')
+
+
+
+
+
+ &network;
+
+ $SNIPPET('ntp.xml')
+
+ &partition;
+
+
+ &bootloader;
+
+
+ 3
+
+
+ sshd
+ enable
+
+
+ ntp
+ enable
+
+
+ syslog
+ enable
+
+
+ autoyast
+ enable
+
+
+
+
+
+ SYSLOG_DAEMON
+ /etc/sysconfig/syslog
+ rsyslogd
+
+
+ RSYSLOGD_COMPAT_VERSION
+ /etc/sysconfig/syslog
+ 4
+
+
+
+
+ /home
+ -1
+ /bin/bash
+ /etc/skel
+
+
+
+#if $getVar('password', '') != ""
+ true
+#else
+ false
+#end if
+ root
+ 0
+ /root
+
+
+
+
+
+
+
+
+ /bin/bash
+ 0
+#if $getVar('password', '') != ""
+ $password
+#else
+ root
+#end if
+ root
+
+
+
+ ## we have to include the pre-scripts tag to get kickstart_start included
+
+
+ ## SuSE has an annoying habit on ppc64 of changing the system
+ ## boot order after installation. This makes it non-trivial to
+ ## automatically re-install future OS.
+#set global $wrappedscript = 'save_boot_device'
+$SNIPPET('suse_scriptwrapper.xml')
+
+
+
+ ## This plugin wrapper provides the flexibility to call pure shell
+ ## snippets which can be used directly on kickstart and with with
+ ## wrapper on SuSE.
+#set global $wrappedscript = 'restore_boot_device'
+$SNIPPET('suse_scriptwrapper.xml')
+
+
+
+
+
+
+
+
+
diff --git a/cobbler/scripts/suse_early_default b/cobbler/scripts/suse_early_default
new file mode 100644
index 0000000..7af2435
--- /dev/null
+++ b/cobbler/scripts/suse_early_default
@@ -0,0 +1,25 @@
+# Start suse_early_default
+# This script is not run in the chroot /target by default
+#if $getVar('system_name','') != ''
+#set $what = "system"
+#else
+#set $what = "profile"
+#end if
+$SNIPPET('suse_pre_log')
+$SNIPPET('suse_pre_install_network')
+$SNIPPET('suse_pre_partition_disks')
+$SNIPPET('suse_pre_anamon')
+wget -O- http://$http_server/cblr/svc/op/ks/$what/$name | sed -e 's/&/\&/g' -e 's/&/\&/g' > /tmp/profile/modified.xml
+#raw
+# generic functions to be used to expand xml entity
+entity_expand() {
+ sed -i "/&$1;/ {
+ r /tmp/profile/$1.xml
+ d
+ }" $2
+}
+#end raw
+entity_expand network /tmp/profile/modified.xml
+entity_expand partition /tmp/profile/modified.xml
+entity_expand bootloader /tmp/profile/modified.xml
+# End suse_early_default
diff --git a/cobbler/scripts/suse_early_default.bak b/cobbler/scripts/suse_early_default.bak
new file mode 100644
index 0000000..e953074
--- /dev/null
+++ b/cobbler/scripts/suse_early_default.bak
@@ -0,0 +1,30 @@
+# Start suse_early_default
+# This script is not run in the chroot /target by default
+#if $getVar('system_name','') != ''
+#set $what = "system"
+#else
+#set $what = "profile"
+#end if
+$SNIPPET('suse_pre_log')
+$SNIPPET('suse_pre_install_network')
+$SNIPPET('suse_pre_partition_disks')
+$SNIPPET('suse_pre_anamon')
+wget -O- http://$http_server/cblr/svc/op/ks/$what/$name | sed -e 's/&/\&/g' | sed -e 's/&/\&/g' > /tmp/modified.xml
+cp -f /tmp/modified.xml /tmp/profile/modified.xml
+cat << EOF > /tmp/expand_entity.sh
+#raw
+#!/bin/bash
+sed -i "/&\$1;/ {
+ r /tmp/profile/\$1.xml
+ d
+}" \$2
+#end raw
+EOF
+chmod ugo+x /tmp/expand_entity.sh
+/tmp/expand_entity.sh network /tmp/profile/modified.xml
+/tmp/expand_entity.sh partition /tmp/profile/modified.xml
+/tmp/expand_entity.sh bootloader /tmp/profile/modified.xml
+while [ ! -f /tmp/break ]; do
+ sleep 10
+done
+# End suse_early_default
diff --git a/cobbler/scripts/suse_init_default b/cobbler/scripts/suse_init_default
new file mode 100644
index 0000000..bbff27e
--- /dev/null
+++ b/cobbler/scripts/suse_init_default
@@ -0,0 +1,7 @@
+#if $getVar('system_name','') != ''
+#set $what = "system"
+#else
+#set $what = "profile"
+#end if
+
+
diff --git a/cobbler/scripts/suse_late_default b/cobbler/scripts/suse_late_default
new file mode 100644
index 0000000..f8ae6fc
--- /dev/null
+++ b/cobbler/scripts/suse_late_default
@@ -0,0 +1,17 @@
+# Start suse_late_default
+# This script is not run in the chroot /target by default
+#if $getVar('system_name','') != ''
+#set $what = "system"
+#else
+#set $what = "profile"
+#end if
+$SNIPPET('suse_post_log')
+$SNIPPET('suse_post_install_network')
+$SNIPPET('suse_post_partition_disks')
+#if $getVar('tool', '') != ''
+ #set $suse_tool = "suse_%s" % $tool
+$SNIPPET($suse_tool)
+#end if
+$SNIPPET('suse_post_anamon')
+# End suse_late_default
+
diff --git a/cobbler/scripts/suse_post_default b/cobbler/scripts/suse_post_default
new file mode 100644
index 0000000..fe68768
--- /dev/null
+++ b/cobbler/scripts/suse_post_default
@@ -0,0 +1,5 @@
+#if $getVar('system_name','') != ''
+#set $what = "system"
+#else
+#set $what = "profile"
+#end if
diff --git a/cobbler/snippets/kickstart_chef_init b/cobbler/snippets/kickstart_chef_init
index 47b9dee..3968535 100644
--- a/cobbler/snippets/kickstart_chef_init
+++ b/cobbler/snippets/kickstart_chef_init
@@ -10,9 +10,9 @@ cat << EOF > /etc/init.d/chef
# processname: chef-agent
#end raw
echo "old date is: `date`" 2>&1 > /tmp/ntp.log
-service ntpd stop 2>&1 >> /tmp/ntp.log
+service ntp stop 2>&1 >> /tmp/ntp.log
ntpdate $ntp_server 2>&1 >> /tmp/ntp.log
-service ntpd start 2>&1 >> /tmp/ntp.log
+service ntp start 2>&1 >> /tmp/ntp.log
echo "new date is: `date`" 2>&1 >> /tmp/ntp.log
crontab -l > /tmp/mycron
diff --git a/cobbler/snippets/kickstart_chef_run.sh b/cobbler/snippets/kickstart_chef_run.sh
index 7328a30..215eb42 100644
--- a/cobbler/snippets/kickstart_chef_run.sh
+++ b/cobbler/snippets/kickstart_chef_run.sh
@@ -22,29 +22,29 @@
cat << EOF > /etc/chef/chef_client_run.sh
#!/bin/bash
-touch /tmp/chef.log
+touch /var/log/chef.log
PIDFILE=/tmp/chef_client_run.pid
if [ -f \\$PIDFILE ]; then
pid=\\$(cat \\$PIDFILE)
if [ -f /proc/\\$pid/exe ]; then
- echo "there are chef_client_run.sh running with pid \\$pid" &>> /tmp/chef.log
+ echo "there are chef_client_run.sh running with pid \\$pid" &>> /var/log/chef.log
exit 1
fi
fi
echo \\$$ > \\$PIDFILE
while true; do
- echo "run chef-client on \`date\`" &>> /tmp/chef.log
+ echo "run chef-client on \`date\`" &>> /var/log/chef.log
clients=\\$(pgrep chef-client)
if [[ "\\$?" == "0" ]]; then
- echo "there are chef-clients '\\$clients' running" &>> /tmp/chef.log
+ echo "there are chef-clients '\\$clients' running" &>> /var/log/chef.log
break
else
- echo "knife search nodes" &>> /tmp/chef.log
+ echo "knife search nodes" &>> /var/log/chef.log
# use knife node list here to check if node has been registered because knife search node
# doesn't work as expected.
- USER=root HOME=/root knife node list |grep \\$HOSTNAME. &>> /tmp/chef.log
+ USER=root HOME=/root knife node list |grep \\$HOSTNAME. &>> /var/log/chef.log
nodes=\\$(USER=root HOME=/root knife node list |grep \\$HOSTNAME.)
- echo "found nodes \\$nodes" &>> /tmp/chef.log
+ echo "found nodes \\$nodes" &>> /var/log/chef.log
let all_nodes_success=1
for node in \\$nodes; do
mkdir -p /var/log/chef/\\$node
@@ -78,15 +78,15 @@ EOL
service rsyslog restart
fi
if [ -f "/etc/chef/\\$node.done" ]; then
- USER=root HOME=/root chef-client --node-name \\$node -j /etc/chef/\\$node.json --client_key /etc/chef/\\$node.pem &>> /tmp/chef.log
+ USER=root HOME=/root chef-client --node-name \\$node -j /etc/chef/\\$node.json --client_key /etc/chef/\\$node.pem &>> /var/log/chef.log
else
- USER=root HOME=/root chef-client --node-name \\$node -j /etc/chef/\\$node.json --client_key /etc/chef/\\$node.pem -L /var/log/chef/\\$node/chef-client.log &>> /tmp/chef.log
+ USER=root HOME=/root chef-client --node-name \\$node -j /etc/chef/\\$node.json --client_key /etc/chef/\\$node.pem -L /var/log/chef/\\$node/chef-client.log &>> /var/log/chef.log
fi
if [ "\\$?" != "0" ]; then
- echo "chef-client --node-name \\$node run failed" &>> /tmp/chef.log
+ echo "chef-client --node-name \\$node run failed" &>> /var/log/chef.log
let all_nodes_success=0
else
- echo "chef-client --node-name \\$node run success" &>> /tmp/chef.log
+ echo "chef-client --node-name \\$node run success" &>> /var/log/chef.log
touch /etc/chef/\\$node.done
fi
done
diff --git a/cobbler/snippets/kickstart_client.rb b/cobbler/snippets/kickstart_client.rb
index 99b5618..e6495d0 100644
--- a/cobbler/snippets/kickstart_client.rb
+++ b/cobbler/snippets/kickstart_client.rb
@@ -4,6 +4,10 @@ log_level :info
log_location '/dev/null'
#if $getVar('chef_url', '') != ""
chef_server_url '$chef_url'
+#elif $getVar("compass_server","") != ""
+chef_server_url 'https://$compass_server'
+#else
+chef_server_url 'https://$server'
#end if
validation_client_name 'chef-validator'
json_attribs nil
diff --git a/cobbler/snippets/kickstart_post_anamon b/cobbler/snippets/kickstart_post_anamon
index b7055df..17b68aa 100644
--- a/cobbler/snippets/kickstart_post_anamon
+++ b/cobbler/snippets/kickstart_post_anamon
@@ -31,9 +31,9 @@ cat << EOF > /etc/init.d/anamon.init
#
#end raw
#if $getVar("compass_server","") != ""
-/usr/local/sbin/anamon --watchfile "/var/log/boot.log /var/log/messages /var/log/dmesg /var/log/anaconda.log" --name $name --server $compass_server --port $http_port --exit
+/usr/local/sbin/anamon --watchfile "/var/log/anaconda.log" --name $name --server $compass_server --port $http_port --exit
#else
-/usr/local/sbin/anamon --watchfile "/var/log/boot.log /var/log/messages /var/log/dmesg /var/log/anaconda.log" --name $name --server $server --port $http_port --exit
+/usr/local/sbin/anamon --watchfile "/var/log/anaconda.log" --name $name --server $server --port $http_port --exit
#end if
chkconfig anamon.init off
mv /etc/init.d/anamon.init /tmp/anamon.init
diff --git a/cobbler/snippets/kickstart_pre_partition_disks b/cobbler/snippets/kickstart_pre_partition_disks
index 6a87383..8426f53 100644
--- a/cobbler/snippets/kickstart_pre_partition_disks
+++ b/cobbler/snippets/kickstart_pre_partition_disks
@@ -131,7 +131,7 @@ for disk in \${sorted_disks}; do
break
fi
done
-echo "first disk \${first_disk}" >> /tmp/preseed.log
+echo "first disk \${first_disk}" >> /tmp/log
let disk_nums=\${#sorted_disks[@]}
sorted_disks_str=""
@@ -187,13 +187,13 @@ for disk_partition in \${disk_partitions}; do
remove_vg="\$vg"
remove_partition="\${disk_partition}"
else
- echo "partition \${disk_partition} does not match \${remove_disk_path}.*" >> /tmp/preseed.log
+ echo "partition \${disk_partition} does not match \${remove_disk_path}.*" >> /tmp/log
fi
if expr match "\${disk_partition}" "\${remove_disk}.*"; then
remove_vg="\$vg"
remove_partition="\${disk_partition}"
else
- echo "partition \${disk_partition} does not match \${remove_disk}.*" >> /tmp/preseed.log
+ echo "partition \${disk_partition} does not match \${remove_disk}.*" >> /tmp/log
fi
if [[ "\$vg" == "$vgname" ]]; then
remove_vg="\$vg"
@@ -232,12 +232,12 @@ for disk_partition in \${disk_partitions}; do
fi
done
-echo "remove vgs \${remove_vgs}" >> /tmp/preseed.log
+echo "remove vgs \${remove_vgs}" >> /tmp/log
for remove_vg in \${remove_vgs}; do
vgremove -f \${remove_vg}
done
-echo "remove partitions \${remove_partitions} from \${remove_vgs}" >> /tmp/preseed.log
+echo "remove partitions \${remove_partitions} from \${remove_vgs}" >> /tmp/log
for remove_partition in \${remove_partitions}; do
pvremove -ff -y \${remove_partition}
done
@@ -259,7 +259,7 @@ declare -A reserve_disks_size
#else
#set disk_size = $int($size)
#end if
-reserve_disks_size[\${disk_name}]=${disk_size}
+reserve_disks_size[${disk_name}]=${disk_size}
#end for
#end if
@@ -293,7 +293,7 @@ declare -A max_disks_size
#else
#set disk_size = $int($size)
#end if
-max_disks_size[\${disk_name}]=${disk_size}
+max_disks_size[${disk_name}]=${disk_size}
#end for
#end if
@@ -454,7 +454,7 @@ while [ \${disk_offset} -lt \${disk_nums} ]; do
fi
echo "partition \${disk} max size \${max_disk_size}" >> /tmp/log
if [ \${max_disk_size} -gt 0 ]; then
- maxsize_param="--maxsize=\${max_disks_size[\${disk}]}"
+ maxsize_param="--maxsize=\${max_disk_size}"
else
maxsize_param=""
fi
diff --git a/cobbler/snippets/kickstart_software_chef b/cobbler/snippets/kickstart_software_chef
new file mode 100644
index 0000000..398ae94
--- /dev/null
+++ b/cobbler/snippets/kickstart_software_chef
@@ -0,0 +1 @@
+chef
diff --git a/cobbler/snippets/limits_conf.xml b/cobbler/snippets/limits_conf.xml
new file mode 100644
index 0000000..2f33be5
--- /dev/null
+++ b/cobbler/snippets/limits_conf.xml
@@ -0,0 +1,61 @@
+
+ /etc/security/limits.conf
+
+ -
+#
+#Where:
+# can be:
+# - an user name
+# - a group name, with @group syntax
+# - the wildcard *, for default entry
+# - the wildcard %, can be also used with %group syntax,
+# for maxlogin limit
+#
+# can have the two values:
+# - "soft" for enforcing the soft limits
+# - "hard" for enforcing hard limits
+#
+#
- can be one of the following:
+# - core - limits the core file size (KB)
+# - data - max data size (KB)
+# - fsize - maximum filesize (KB)
+# - memlock - max locked-in-memory address space (KB)
+# - nofile - max number of open files
+# - rss - max resident set size (KB)
+# - stack - max stack size (KB)
+# - cpu - max CPU time (MIN)
+# - nproc - max number of processes
+# - as - address space limit (KB)
+# - maxlogins - max number of logins for this user
+# - maxsyslogins - max number of logins on the system
+# - priority - the priority to run user process with
+# - locks - max number of file locks the user can hold
+# - sigpending - max number of pending signals
+# - msgqueue - max memory used by POSIX message queues (bytes)
+# - nice - max nice priority allowed to raise to values: [-20, 19]
+# - rtprio - max realtime priority
+#
+#
-
+#
+
+#* soft core 0
+#* hard rss 10000
+#@student hard nproc 20
+#@faculty soft nproc 20
+#@faculty hard nproc 50
+#ftp hard nproc 0
+#@student - maxlogins 4
+* - nofile 100000
+# End of file
+#end raw
+]]>
+
+ root.root
+ 644
+
diff --git a/cobbler/snippets/ntp.xml b/cobbler/snippets/ntp.xml
new file mode 100644
index 0000000..0f1a10f
--- /dev/null
+++ b/cobbler/snippets/ntp.xml
@@ -0,0 +1,16 @@
+#if $getVar('ntp_server', '') == ""
+ #set $ntp_server = '0.pool.ntp.org'
+#end if
+
+ false
+
+
+ $ntp_server
+ true
+
+ server
+
+
+ true
+ true
+
diff --git a/cobbler/snippets/preseed_chef_run.sh b/cobbler/snippets/preseed_chef_run.sh
index 2e3c715..5becbe4 100644
--- a/cobbler/snippets/preseed_chef_run.sh
+++ b/cobbler/snippets/preseed_chef_run.sh
@@ -21,27 +21,27 @@
cat << EOF > /etc/chef/chef_client_run.sh
#!/bin/bash
-touch /tmp/chef.log
+touch /var/log/chef.log
PIDFILE=/tmp/chef_client_run.pid
if [ -f \\$PIDFILE ]; then
pid=\\$(cat \\$PIDFILE)
if [ -f /proc/\\$pid/exe ]; then
- echo "there are chef_client_run.sh running with pid \\$pid" &>> /tmp/chef.log
+ echo "there are chef_client_run.sh running with pid \\$pid" &>> /var/log/chef.log
exit 1
fi
fi
echo \\$$ > \\$PIDFILE
while true; do
- echo "run chef-client on \`date\`" &>> /tmp/chef.log
+ echo "run chef-client on \`date\`" &>> /var/log/chef.log
clients=\\$(pgrep chef-client)
if [[ "\\$?" == "0" ]]; then
- echo "there are chef-clients '\\$clients' running" &>> /tmp/chef.log
+ echo "there are chef-clients '\\$clients' running" &>> /var/log/chef.log
break
else
- echo "knife search nodes" &>> /tmp/chef.log
- USER=root HOME=/root knife node list |grep \\$HOSTNAME. &>> /tmp/chef.log
+ echo "knife search nodes" &>> /var/log/chef.log
+ USER=root HOME=/root knife node list |grep \\$HOSTNAME. &>> /var/log/chef.log
nodes=\\$(USER=root HOME=/root knife node list |grep \\$HOSTNAME.)
- echo "found nodes \\$nodes" &>> /tmp/chef.log
+ echo "found nodes \\$nodes" &>> /var/log/chef.log
all_nodes_success=1
for node in \\$nodes; do
mkdir -p /var/log/chef/\\$node
@@ -71,15 +71,15 @@ EOL
service rsyslog restart
fi
if [ -f "/etc/chef/\\$node.done" ]; then
- USER=root HOME=/root chef-client --node-name \\$node -j /etc/chef/\\$node.json --client_key /etc/chef/\\$node.pem &>> /tmp/chef.log
+ USER=root HOME=/root chef-client --node-name \\$node -j /etc/chef/\\$node.json --client_key /etc/chef/\\$node.pem &>> /var/log/chef.log
else
- USER=root HOME=/root chef-client --node-name \\$node -j /etc/chef/\\$node.json --client_key /etc/chef/\\$node.pem -L /var/log/chef/\\$node/chef-client.log &>> /tmp/chef.log
+ USER=root HOME=/root chef-client --node-name \\$node -j /etc/chef/\\$node.json --client_key /etc/chef/\\$node.pem -L /var/log/chef/\\$node/chef-client.log &>> /var/log/chef.log
fi
if [ "\\$?" != "0" ]; then
- echo "chef-client --node-name \\$node run failed" &>> /tmp/chef.log
+ echo "chef-client --node-name \\$node run failed" &>> /var/log/chef.log
all_nodes_success=0
else
- echo "chef-client --node-name \\$node run success" &>> /tmp/chef.log
+ echo "chef-client --node-name \\$node run success" &>> /var/log/chef.log
touch /etc/chef/\\$node.done
fi
done
diff --git a/cobbler/snippets/preseed_client.rb b/cobbler/snippets/preseed_client.rb
index 58befb3..d4dc2bf 100644
--- a/cobbler/snippets/preseed_client.rb
+++ b/cobbler/snippets/preseed_client.rb
@@ -3,6 +3,10 @@ log_level :info
log_location '/dev/null'
#if $getVar('chef_url', '') != ""
chef_server_url '$chef_url'
+#elif $getVar("compass_server","") != ""
+chef_server_url 'https://$compass_server'
+#else
+chef_server_url 'https://$server'
#end if
validation_client_name 'chef-validator'
json_attribs nil
diff --git a/cobbler/snippets/preseed_post_anamon b/cobbler/snippets/preseed_post_anamon
index e576482..8182c95 100644
--- a/cobbler/snippets/preseed_post_anamon
+++ b/cobbler/snippets/preseed_post_anamon
@@ -1,7 +1,11 @@
#if $str($getVar('anamon_enabled','')) == "1"
## install anamon script
+ #if $getVar("compass_server", "") != ""
+wget -O /usr/local/sbin/anamon "http://$compass_server:$http_port/cobbler/aux/anamon"
+ #else
wget -O /usr/local/sbin/anamon "http://$server:$http_port/cobbler/aux/anamon"
+ #end if
## install anamon system service
cat << EOF > /etc/init.d/anamon.init
#raw
@@ -29,7 +33,11 @@ cat << EOF > /etc/init.d/anamon.init
cd /var/log/installer
gunzip initial-status.gz
cd -
-/usr/local/sbin/anamon --watchfile "/var/log/installer/syslog /var/log/installer/hardware-summary /var/log/installer/initial-status /var/log/installer/status /var/log/messages /var/log/dmesg" --name $name --server $server --port $http_port --exit
+#if $getVar("compass_server","") != ""
+/usr/local/sbin/anamon --watchfile "/var/log/installer/syslog /var/log/installer/hardware-summary /var/log/installer/initial-status /var/log/installer/status" --name $name --server $compass_server --port $http_port --exit
+#else
+/usr/local/sbin/anamon --watchfile "/var/log/installer/syslog /var/log/installer/hardware-summary /var/log/installer/initial-status /var/log/installer/status" --name $name --server $server --port $http_port --exit
+#end if
update-rc.d -f anamon remove
mv /etc/init.d/anamon.init /tmp/anamon.init
EOF
diff --git a/cobbler/snippets/preseed_post_install_network_config b/cobbler/snippets/preseed_post_install_network_config
index 1048bbe..90f6e2b 100644
--- a/cobbler/snippets/preseed_post_install_network_config
+++ b/cobbler/snippets/preseed_post_install_network_config
@@ -253,8 +253,8 @@ done
echo "unset physical interfaces \${sorted_unset_physical_interfaces}" >> /tmp/network_log
echo "unset logical interfaces \${sorted_unset_logical_interfaces}" >> /tmp/network_log
-# map any unmapped logical interfaces
-echo "map unmapped logical interfaces" >> /tmp/network_log
+# map remaining unmapped logical interfaces
+echo "map remaining unmapped logical interfaces" >> /tmp/network_log
if [ ! -z "\${sorted_unset_logical_interfaces}" ]; then
# get all available logical interfaces which the same name physical interface is not used
available_logical_interfaces=""
@@ -297,19 +297,6 @@ if [ ! -z "\${sorted_unset_logical_interfaces}" ]; then
done
sorted_unset_logical_interfaces=\${unset_logical_interfaces}
- echo "finish mapping ramaining unmapped logical interfaces to the same name physical interface" >> /tmp/network_log
- for key in \${logical_interfaces}; do
- eval "physical_interface=\\${logical_interface_mapping_\${key}}"
- echo "map logical interface \${key} to physical interface \${physical_interface}" >> /tmp/network_log
- done
- for key in \${physical_interfaces}; do
- eval "logical_interface=\\${physical_interface_mapping_\${key}}"
- echo "map physical interface \${key} to logical interface \${logical_interface}" >> /tmp/network_log
- done
-
- echo "unset physical interfaces \${sorted_unset_physical_interfaces}" >> /tmp/network_log
- echo "unset logical interfaces \${sorted_unset_logical_interfaces}" >> /tmp/network_log
-
# map remain unset logical interfaces to available logical interface names
for logical_interface in \${sorted_unset_logical_interfaces}; do
for available_logical_interface in \${available_logical_interfaces}; do
@@ -335,8 +322,8 @@ for key in \${physical_interfaces}; do
echo "map physical interface \${key} to logical interface \${logical_interface}" >> /tmp/network_log
done
-# map any unmapped physical interfaces
-echo "map unmapped physical interfaces" >> /tmp/network_log
+# map remaining unmapped physical interfaces
+echo "map remaining unmapped physical interfaces" >> /tmp/network_log
if [ ! -z "\${sorted_unset_physical_interfaces}" ]; then
# get all available physical interfaces which the same name logical interface is not used
available_physical_interfaces=""
@@ -379,19 +366,6 @@ if [ ! -z "\${sorted_unset_physical_interfaces}" ]; then
done
sorted_unset_physical_interfaces=\${unset_physical_interfaces}
- echo "finish mapping ramaining unmapped physical interfaces to the same name logical interface" >> /tmp/network_log
- for key in \${logical_interfaces}; do
- eval "physical_interface=\\${logical_interface_mapping_\${key}}"
- echo "map logical interface \${key} to physical interface \${physical_interface}" >> /tmp/network_log
- done
- for key in \${physical_interfaces}; do
- eval "logical_interface=\\${physical_interface_mapping_\${key}}"
- echo "map physical interface \${key} to logical interface \${logical_interface}" >> /tmp/network_log
- done
-
- echo "unset physical interfaces \${sorted_unset_physical_interfaces}" >> /tmp/network_log
- echo "unset logical interfaces \${sorted_unset_logical_interfaces}" >> /tmp/network_log
-
# map remain unset physical interfaces to logical interface name as available physical interface names
for physical_interface in \${sorted_unset_physical_interfaces}; do
for available_physical_interface in \${available_physical_interfaces}; do
diff --git a/cobbler/snippets/preseed_pre_install_network_config b/cobbler/snippets/preseed_pre_install_network_config
index bc6230d..ea09990 100644
--- a/cobbler/snippets/preseed_pre_install_network_config
+++ b/cobbler/snippets/preseed_pre_install_network_config
@@ -33,6 +33,8 @@ get_ifname() {
#end raw
#set ikeys = $interfaces.keys()
#for $iname in $ikeys
+ #set $idata = $interfaces[$iname]
+ #set $management = $idata["management"]
#if $management
#set $management_nic = $iname
#end if
diff --git a/cobbler/snippets/preseed_pre_partition_disks b/cobbler/snippets/preseed_pre_partition_disks
index cbb1411..285ae22 100644
--- a/cobbler/snippets/preseed_pre_partition_disks
+++ b/cobbler/snippets/preseed_pre_partition_disks
@@ -108,6 +108,7 @@ for disk in \$(list-devices disk); do
fi
done
echo "partition disks: \${partition_disks}" >> /tmp/preseed.log
+echo "disks \${disks}" >> /tmp/preseed.log
#if $getVar('sort_disks', '0') != "0"
sorted_disks=\$(printf '%s\n' \${partition_disks} | sort)
@@ -441,6 +442,19 @@ partition_maxsize_$volname=${vol_max_size}
#end for
#end if
+echo "finish partition mapping" >> /tmp/preseed.log
+for key in \${partition_names}; do
+ eval "mountpoint=\\${partition_point_\$key}"
+ echo "partition names \$key => \${mountpoint}" >> /tmp/preseed.log
+ eval "partition_percentage=\\${partition_percentage_\$key}"
+ echo "partition percentage \$key => \${partition_percentage}" >> /tmp/preseed.log
+ eval "partition_size=\\${partition_size_\$key}"
+ echo "partition size \$key => \${partition_size}" >> /tmp/preseed.log
+ eval "partition_max_size=\\${partition_max_size_\$key}"
+ echo "partition max size \$key => \${partition_max_size}" >> /tmp/preseed.log
+done
+
+
if [ -z "\${default_partition_name}" ]; then
default_partition_name=root
fi
@@ -505,11 +519,11 @@ if [ -z "\${partition_size_swap}" ]; then
fi
if [ -z "\${partition_percentage_swap}" ]; then
- partition_percentage_swap=200
+ partition_percentage_swap=10
fi
if [ -z "\${partition_maxsize_swap}" ]; then
- partition_maxsize_swap=10%
+ partition_maxsize_swap=200%
fi
partition_param_swap="linux-swap \
diff --git a/cobbler/snippets/preseed_software_chef b/cobbler/snippets/preseed_software_chef
new file mode 100644
index 0000000..febb68b
--- /dev/null
+++ b/cobbler/snippets/preseed_software_chef
@@ -0,0 +1 @@
+d-i pkgsel/include string ntp ssh wget chef
diff --git a/cobbler/snippets/repo_config.xml b/cobbler/snippets/repo_config.xml
new file mode 100644
index 0000000..5483644
--- /dev/null
+++ b/cobbler/snippets/repo_config.xml
@@ -0,0 +1,17 @@
+# Repository Config
+#set $repo_data = $getVar("repo_data",[])
+#for $repo in $repo_data
+
+ #if $repo.mirror_locally
+ http://$http_server/cobbler/repo_mirror/${repo.name}
+ #else
+ ${repo.mirror}
+ #end if
+ ${repo.name}
+ /
+ false
+ ${repo.name}
+
+#end for
+
+
diff --git a/cobbler/snippets/rsyslog.xml b/cobbler/snippets/rsyslog.xml
new file mode 100644
index 0000000..37fd69e
--- /dev/null
+++ b/cobbler/snippets/rsyslog.xml
@@ -0,0 +1,71 @@
+
+ /etc/rsyslog.conf
+
+
+
+ root.root
+ 600
+
diff --git a/cobbler/snippets/software_chef.xml b/cobbler/snippets/software_chef.xml
new file mode 100644
index 0000000..0767709
--- /dev/null
+++ b/cobbler/snippets/software_chef.xml
@@ -0,0 +1,2 @@
+ chef
+
diff --git a/cobbler/snippets/ssh.xml b/cobbler/snippets/ssh.xml
new file mode 100644
index 0000000..1cb8a88
--- /dev/null
+++ b/cobbler/snippets/ssh.xml
@@ -0,0 +1,36 @@
+#set ssh_keys = $getVar("push_ssh_keys", "/root/.ssh/id_rsa.pub")
+#if $ssh_keys != ""
+
+ /root/.ssh/authorized_keys
+ root.root
+ 600
+
+ shell
+
+ /root/.ssh/authorized_keys
+ #echo $f.read()
+EOL
+ #else
+cat << EOL >> /root/.ssh/authorized_keys
+ #echo $f.read()
+EOL
+ #end if
+ #silent $f.close()
+ #set $firstline = False
+ #end for
+]]>
+
+
+
+#end if
diff --git a/cobbler/snippets/sshd.xml b/cobbler/snippets/sshd.xml
new file mode 100644
index 0000000..d42f6f8
--- /dev/null
+++ b/cobbler/snippets/sshd.xml
@@ -0,0 +1,142 @@
+
+ /etc/ssh/sshd_config
+
+
+
+ root.root
+ 640
+
diff --git a/cobbler/snippets/suse_chef b/cobbler/snippets/suse_chef
new file mode 100644
index 0000000..f42cea2
--- /dev/null
+++ b/cobbler/snippets/suse_chef
@@ -0,0 +1,13 @@
+mkdir -p /etc/chef
+mkdir -p /var/log/chef
+
+## Generate validation.pem
+$SNIPPET('suse_chef-validator.pem')
+## Generate admin.pem
+$SNIPPET('suse_chef-admin.pem')
+## Generate client.rb
+$SNIPPET('suse_client.rb')
+$SNIPPET('suse_knife.rb')
+$SNIPPET('suse_gem_local_repo')
+$SNIPPET('suse_chef_run.sh')
+$SNIPPET('suse_chef_init')
diff --git a/cobbler/snippets/suse_chef-admin.pem b/cobbler/snippets/suse_chef-admin.pem
new file mode 100644
index 0000000..36aad5d
--- /dev/null
+++ b/cobbler/snippets/suse_chef-admin.pem
@@ -0,0 +1,8 @@
+#if $getVar('chef_admin_file', '') == ""
+ #set chef_admin_file = '/etc/chef-server/admin.pem'
+#end if
+#set f = $open($chef_admin_file)
+cat << EOL > /etc/chef/admin.pem
+#echo $f.read()
+EOL
+#silent $f.close()
diff --git a/cobbler/snippets/suse_chef-validator.pem b/cobbler/snippets/suse_chef-validator.pem
new file mode 100644
index 0000000..515a219
--- /dev/null
+++ b/cobbler/snippets/suse_chef-validator.pem
@@ -0,0 +1,8 @@
+#if $getVar('chef_validation_file', '') == ""
+ #set chef_validation_file = '/etc/chef-server/chef-validator.pem'
+#end if
+#set f = $open($chef_validation_file)
+cat << EOL > /etc/chef/validation.pem
+#echo $f.read()
+EOL
+#silent $f.close()
diff --git a/cobbler/snippets/suse_chef_init b/cobbler/snippets/suse_chef_init
new file mode 100644
index 0000000..93f3f24
--- /dev/null
+++ b/cobbler/snippets/suse_chef_init
@@ -0,0 +1,32 @@
+## A self-destruct service to boot chef client and register cron job
+#if $getVar('ntp_server', '') == ""
+ #set $ntp_server = '0.pool.ntp.org'
+#end if
+cat << EOF > /etc/init.d/chef
+#raw
+#!/bin/bash
+# Required-Start: \$syslog \$ntp
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 6
+# Short-Description: chef client daemon (chef)
+# Description: chef client daemon (chef).
+#end raw
+echo "old date is: `date`" 2>&1 > /tmp/ntp.log
+service ntpd stop 2>&1 >> /tmp/ntp.log
+ntpdate $ntp_server 2>&1 >> /tmp/ntp.log
+service ntpd start 2>&1 >> /tmp/ntp.log
+echo "new date is: `date`" 2>&1 >> /tmp/ntp.log
+
+crontab -l > /tmp/mycron
+echo "*/30 * * * * /etc/chef/chef_client_run.sh" >> /tmp/mycron
+crontab /tmp/mycron
+rm /tmp/mycron
+
+/etc/chef/chef_client_run.sh &
+
+chkconfig -d chef
+mv /etc/init.d/chef /tmp/chef
+EOF
+
+chmod 755 /etc/init.d/chef
+chkconfig chef on
diff --git a/cobbler/snippets/suse_chef_run.sh b/cobbler/snippets/suse_chef_run.sh
new file mode 100644
index 0000000..5becbe4
--- /dev/null
+++ b/cobbler/snippets/suse_chef_run.sh
@@ -0,0 +1,94 @@
+#set ip_address = ""
+#set ikeys = $interfaces.keys()
+#for $iname in $ikeys
+ #set $idata = $interfaces[$iname]
+ #set $static = $idata["static"]
+ #set $management = $idata["management"]
+ #set $ip = $idata["ip_address"]
+ #if $management and $ip
+ #set $ip_address = $ip
+ #end if
+#end for
+
+#set $proxy_url = ""
+#set $local_repo_url = ""
+#if $getVar("local_repo","") != ""
+ #set $local_repo_url = $local_repo
+#end if
+#if $getVar("proxy","") != ""
+ #set $proxy_url = $proxy
+#end if
+
+cat << EOF > /etc/chef/chef_client_run.sh
+#!/bin/bash
+touch /var/log/chef.log
+PIDFILE=/tmp/chef_client_run.pid
+if [ -f \\$PIDFILE ]; then
+ pid=\\$(cat \\$PIDFILE)
+ if [ -f /proc/\\$pid/exe ]; then
+ echo "there are chef_client_run.sh running with pid \\$pid" &>> /var/log/chef.log
+ exit 1
+ fi
+fi
+echo \\$$ > \\$PIDFILE
+while true; do
+ echo "run chef-client on \`date\`" &>> /var/log/chef.log
+ clients=\\$(pgrep chef-client)
+ if [[ "\\$?" == "0" ]]; then
+ echo "there are chef-clients '\\$clients' running" &>> /var/log/chef.log
+ break
+ else
+ echo "knife search nodes" &>> /var/log/chef.log
+ USER=root HOME=/root knife node list |grep \\$HOSTNAME. &>> /var/log/chef.log
+ nodes=\\$(USER=root HOME=/root knife node list |grep \\$HOSTNAME.)
+ echo "found nodes \\$nodes" &>> /var/log/chef.log
+ all_nodes_success=1
+ for node in \\$nodes; do
+ mkdir -p /var/log/chef/\\$node
+ if [ ! -f /etc/chef/\\$node.json ]; then
+ cat << EOL > /etc/chef/\\$node.json
+{
+ "local_repo": "$local_repo_url",
+ "proxy_url": "$proxy_url",
+ "ip_address": "$ip_address"
+}
+EOL
+ fi
+ if [ ! -f "/etc/chef/\\$node.pem" ]; then
+ cat << EOL > /etc/rsyslog.d/\\$node.conf
+\\\\$ModLoad imfile
+\\\\$InputFileName /var/log/chef/\\$node/chef-client.log
+\\\\$InputFileReadMode 0
+\\\\$InputFileTag \\$node
+\\\\$InputFileStateFile chef_\\${node}_log
+\\\\$InputFileSeverity notice
+\\\\$InputFileFacility local3
+\\\\$InputRunFileMonitor
+\\\\$InputFilePollInterval 1
+local3.info @$server:514
+EOL
+ rm -rf /var/lib/rsyslog/chef_\\$node_log
+ service rsyslog restart
+ fi
+ if [ -f "/etc/chef/\\$node.done" ]; then
+ USER=root HOME=/root chef-client --node-name \\$node -j /etc/chef/\\$node.json --client_key /etc/chef/\\$node.pem &>> /var/log/chef.log
+ else
+ USER=root HOME=/root chef-client --node-name \\$node -j /etc/chef/\\$node.json --client_key /etc/chef/\\$node.pem -L /var/log/chef/\\$node/chef-client.log &>> /var/log/chef.log
+ fi
+ if [ "\\$?" != "0" ]; then
+ echo "chef-client --node-name \\$node run failed" &>> /var/log/chef.log
+ all_nodes_success=0
+ else
+ echo "chef-client --node-name \\$node run success" &>> /var/log/chef.log
+ touch /etc/chef/\\$node.done
+ fi
+ done
+ if [ \\$all_nodes_success -eq 0 ]; then
+ sleep 1m
+ else
+ break
+ fi
+ fi
+done
+EOF
+chmod +x /etc/chef/chef_client_run.sh
diff --git a/cobbler/snippets/suse_client.rb b/cobbler/snippets/suse_client.rb
new file mode 100644
index 0000000..d4dc2bf
--- /dev/null
+++ b/cobbler/snippets/suse_client.rb
@@ -0,0 +1,35 @@
+cat << EOL > /etc/chef/client.rb
+log_level :info
+log_location '/dev/null'
+#if $getVar('chef_url', '') != ""
+chef_server_url '$chef_url'
+#elif $getVar("compass_server","") != ""
+chef_server_url 'https://$compass_server'
+#else
+chef_server_url 'https://$server'
+#end if
+validation_client_name 'chef-validator'
+json_attribs nil
+pid_file '/var/run/chef-client.pid'
+# Using default node name (fqdn)
+no_lazy_load true
+ssl_verify_mode :verify_none
+EOL
+
+mkdir -p /etc/chef/trusted_certs
+#set certs_path = $getVar("trusted_certs_path", "/var/opt/chef-server/nginx/ca")
+#if $certs_path != ""
+ #import os
+ #import os.path
+ #set filenames = $os.listdir($certs_path)
+ #for filename in $filenames
+ #if $filename.endswith('.crt')
+ #set filepath = $os.path.join($certs_path, $filename)
+ #set f = $open($filepath)
+cat << EOF > /etc/chef/trusted_certs/$filename
+ #echo $f.read()
+EOF
+ #silent $f.close()
+ #end if
+ #end for
+#end if
diff --git a/cobbler/snippets/suse_gem_local_repo b/cobbler/snippets/suse_gem_local_repo
new file mode 100644
index 0000000..ac77938
--- /dev/null
+++ b/cobbler/snippets/suse_gem_local_repo
@@ -0,0 +1,23 @@
+cat << EOF > /root/.gemrc
+#if $getVar('proxy', '') != ""
+gem: --no-ri --no-rdoc --http-proxy=$proxy
+#else
+gem: --no-ri --no-rdoc
+#end if
+:backtrace: false
+:benchmark: false
+:bulk_threshold: 1000
+:sources:
+#if $getVar("local_repo","") != ""
+- $local_repo/gem_repo/
+ #if $getVar("local_repo_only","1") == "0"
+- https://rubygems.org/
+ #end if
+#else
+- https://rubygems.org/
+#end if
+:update_sources: true
+:verbose: true
+EOF
+
+cp -f /root/.gemrc /etc/gemrc
diff --git a/cobbler/snippets/suse_knife.rb b/cobbler/snippets/suse_knife.rb
new file mode 100644
index 0000000..0cb6bbc
--- /dev/null
+++ b/cobbler/snippets/suse_knife.rb
@@ -0,0 +1,32 @@
+mkdir -p /root/.chef
+cat << EOL > /root/.chef/knife.rb
+log_level :info
+log_location '/dev/null'
+#if $getVar('chef_url', '') != ""
+chef_server_url '$chef_url'
+#end if
+node_name 'admin'
+client_key '/etc/chef/admin.pem'
+validation_client_name 'chef-validator'
+validation_key '/etc/chef/validation.pem'
+syntax_check_cache_path '/root/.chef/syntax_check_cache'
+ssl_verify_mode :verify_none
+EOL
+
+mkdir -p /root/.chef/trusted_certs
+#set certs_path = $getVar("trusted_certs_path", "/var/opt/chef-server/nginx/ca")
+#if $certs_path != ""
+ #import os
+ #import os.path
+ #set filenames = $os.listdir($certs_path)
+ #for filename in $filenames
+ #if $filename.endswith('.crt')
+ #set filepath = $os.path.join($certs_path, $filename)
+ #set f = $open($filepath)
+cat << EOF > /root/.chef/trusted_certs/$filename
+ #echo $f.read()
+EOF
+ #silent $f.close()
+ #end if
+ #end for
+#end if
diff --git a/cobbler/snippets/suse_post_anamon b/cobbler/snippets/suse_post_anamon
new file mode 100644
index 0000000..6810dab
--- /dev/null
+++ b/cobbler/snippets/suse_post_anamon
@@ -0,0 +1,30 @@
+#if $str($getVar('anamon_enabled','')) == "1"
+ #if $getVar("compass_server", "") != ""
+wget -O /usr/local/sbin/anamon "http://$compass_server:$http_port/cobbler/aux/anamon"
+ #else
+wget -O /usr/local/sbin/anamon "http://$server:$http_port/cobbler/aux/anamon"
+ #end if
+cat << EOF > /etc/init.d/anamon.init
+#raw
+#!/bin/bash
+## BEGIN INIT INFO
+# Required-Start: $network
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 6
+# Short-Description: Starts the cobbler anamon boot notification program
+# Description: anamon runs the first time a machine is booted after installation.
+## END INIT INFO
+#end raw
+#if $getVar("compass_server","") != ""
+/usr/local/sbin/anamon --watchfile "/var/log/YaST2/y2start.log /var/log/YaST2/y2log" --name $name --server $compass_server --port $http_port --exit
+#else
+/usr/local/sbin/anamon --watchfile "/var/log/YaST2/y2start.log /var/log/YaST2/y2log" --name $name --server $server --port $http_port --exit
+#end if
+chkconfig -d anamon.init
+mv /etc/init.d/anamon.init /tmp/anamon.init
+EOF
+
+chmod 755 /etc/init.d/anamon.init /usr/local/sbin/anamon
+chmod +x /etc/init.d/anamon.init
+chkconfig anamon.init on
+#end if
diff --git a/cobbler/snippets/suse_post_install_network b/cobbler/snippets/suse_post_install_network
new file mode 100644
index 0000000..14bb80c
--- /dev/null
+++ b/cobbler/snippets/suse_post_install_network
@@ -0,0 +1,10 @@
+# Start post_install_network_config generated code
+#if $getVar('promisc_nics', '') != ""
+ #set promisc_interfaces = [promisc.strip() for promisc in $promisc_nics.split(',') if promisc.strip()]
+#else
+ #set promisc_interfaces = []
+#end if
+
+#for promisc_interface in $promisc_interfaces
+echo 'LINK_OPTIONS="promisc on"' >> /etc/sysconfig/network/ifcfg-$promisc_interface
+#end for
diff --git a/cobbler/snippets/suse_post_log b/cobbler/snippets/suse_post_log
new file mode 100644
index 0000000..41c4a7b
--- /dev/null
+++ b/cobbler/snippets/suse_post_log
@@ -0,0 +1,2 @@
+set -x -v
+exec 1>/root/yast-post.log 2>&1
diff --git a/cobbler/snippets/suse_post_partition_disks b/cobbler/snippets/suse_post_partition_disks
new file mode 100644
index 0000000..5151b6b
--- /dev/null
+++ b/cobbler/snippets/suse_post_partition_disks
@@ -0,0 +1,30 @@
+set \$(lsblk -n -p -P -o NAME,TYPE,LABEL | grep 'TYPE="part"' | grep 'LABEL="reserved_.*"' | cut -d' ' -f1)
+echo "list partitions: \$@" >> /tmp/post_partition.log
+declare -a remove_partitions
+for arg in \$@; do
+ eval \$arg
+ partition=\$NAME
+ partition_name=\$(basename \$partition)
+ echo "add \${partition_name} => \$partition into remove list" >> /tmp/post_partition.log
+ remove_partitions[\${partition_name}]=\$partition
+done
+echo "remove partitions: \${remove_partitions[@]}" >> /tmp/post_partition.log
+
+for partition in \${remove_partitions[@]}; do
+ if [ -z "\$partition" ]; then
+ continue
+ fi
+ echo "umount \$partition" >> /tmp/post_partition.log
+ umount \$partition
+ set \$(echo \${partition} | sed -e 's/^\(.*\)\([0-9]\+\)\$/\1 \2/g')
+ partition_disk=\$1
+ partition_number=\$2
+ echo "remove disk \${partition_disk} partition \${partition_number}" >> /tmp/post_partition.log
+ if [ -z "\${partition_disk}" -o -z "\${partition_number}" ]; then
+ continue
+ fi
+ parted \${partition_disk} rm \${partition_number}
+done
+
+grep -v "LABEL=reserved_.*" /etc/fstab > /tmp/fstab.new
+mv -f /tmp/fstab.new /etc/fstab
diff --git a/cobbler/snippets/suse_pre_anamon b/cobbler/snippets/suse_pre_anamon
new file mode 100644
index 0000000..7ffe677
--- /dev/null
+++ b/cobbler/snippets/suse_pre_anamon
@@ -0,0 +1,9 @@
+#if $str($getVar('anamon_enabled','')) == "1"
+ #if $getVar("compass_server", "") != ""
+wget -O /tmp/anamon "http://$compass_server:$http_port/cobbler/aux/anamon"
+python /tmp/anamon --watchfile "/var/log/YaST2/y2start.log /var/log/YaST2/y2log /tmp/log" --name "$name" --server "$compass_server" --port "$http_port"
+ #else
+wget -O /tmp/anamon "http://$server:$http_port/cobbler/aux/anamon"
+python /tmp/anamon --watchfile "/var/log/YaST2/y2start.log /var/log/YaST2/y2log /tmp/log" --name "$name" --server "$server" --port "$http_port"
+ #end if
+#end if
diff --git a/cobbler/snippets/suse_pre_install_network b/cobbler/snippets/suse_pre_install_network
new file mode 100644
index 0000000..55e8d64
--- /dev/null
+++ b/cobbler/snippets/suse_pre_install_network
@@ -0,0 +1,541 @@
+# Start pre_install_network_config generated code
+
+#if $getVar('promisc_nics', '') != ""
+ #set promisc_interfaces = [promisc.strip() for promisc in $promisc_nics.split(',') if promisc.strip()]
+#else
+ #set promisc_interfaces = []
+#end if
+
+# get physical interfaces
+declare -a physical_interfaces
+physical_interfaces=()
+set \$(ip -o link | grep -v lo | awk '{print \$2}' | sed 's/://')
+let physical_interface_num=\$#;
+let physical_interface_offset=0
+echo "network interface numbers: \$physical_interface_num" > /tmp/network_log
+echo "got network interfaces: \$@" >> /tmp/network_log
+while [ \$physical_interface_offset -lt \$physical_interface_num ];
+do
+ physical_interface=\$1
+ echo "record \$physical_interface_offset physical interface \${physical_interface}" >> /tmp/network_log
+ physical_interfaces+=(\${physical_interface})
+ eval "physical_interface_\${physical_interface}=\${physical_interface}"
+ let physical_interface_offset=\$physical_interface_offset+1
+ shift 1
+done
+
+echo "interfaces: \${physical_interfaces[@]}" >> /tmp/network_log
+
+# map physical interface to mac address
+declare -a mac_names
+mac_names=()
+for physical_interface in \${physical_interfaces[@]}; do
+ mac=\$(cat /sys/class/net/\${physical_interface}/address)
+ mac_name=\$(echo \${mac} |tr 'a-z' 'A-Z' | tr ':' '_')
+ mac_names+=(\$mac_name)
+ echo "mapping physical interface \${physical_interface} to mac \${mac}" >> /tmp/network_log
+ eval "physical_interface_mac_\${physical_interface}=\$mac"
+ eval "physical_mac_interface_\${mac_name}=\${physical_interface}"
+ eval "mac_name_\${mac_name}=\$mac"
+done
+
+echo "list physical interfaces to mac" >> /tmp/network_log
+for physical_interface in \${physical_interfaces[@]}; do
+ eval "mac=\\${physical_interface_mac_\${physical_interface}}"
+ echo "physical interface to mac: \${physical_interface} => \${mac}" >> /tmp/network_log
+done
+
+echo "list mac to physical interface mapping" >> /tmp/network_log
+for mac_name in \${mac_names[@]}; do
+ eval "mac=\\${mac_name_\${mac_name}}"
+ eval "physical_interface=\\${physical_mac_interface_\${mac_name}}"
+ echo "mac to physical interface: \${mac} => \${physical_interface}" >> /tmp/network_log
+done
+
+declare -a logical_interfaces
+logical_interfaces=()
+#set ikeys = $interfaces.keys()
+#set osversion = $getVar("os_version","")
+#import re
+#set $vlanpattern = $re.compile("([a-zA-Z0-9]+)[\.][0-9]+")
+#set $subinterfacepattern = $re.compile("([a-zA-Z0-9]+)[:][0-9]+")
+#set $numbondingdevs = 0
+#for $iname in $ikeys
+ #set $idata = $interfaces[$iname]
+ #set $mac = $idata.get("mac_address", "").upper()
+ #set $interface_type = $idata.get("interface_type", "").lower()
+ #if $interface_type in ("master","bond","bonded_bridge_slave")
+ #set $numbondingdevs += 1
+ #end if
+ #if $interface_type in ("master","bond","bridge","bonded_bridge_slave")
+ #continue
+ #end if
+ #if $vlanpattern.match($iname)
+ #set $interface_matched = $vlanpattern.match($iname)
+ #set $interface_name = $interface_matched.group(1)
+logical_interface=${interface_name}
+ #elif $subinterfacepattern.match($iname)
+ #set $interface_matched = $subinterfacepattern.match($iname)
+ #set $interface_name = $interface_matched.group(1)
+logical_interface=${interface_name}
+ #else
+logical_interface=$iname
+ #end if
+logical_interfaces+=(\${logical_interface})
+eval "logical_interface_\${logical_interface}=\${logical_interface}"
+ #if $mac != ""
+ #set mac_name = $mac.replace(':', '_')
+physical_interface=\${physical_mac_interface_${mac_name}}
+eval "logical_interface_mapping_\${logical_interface}=\${physical_interface}"
+if [ ! -z "\$physical_interface" ]; then
+ eval "physical_interface_mapping_\${physical_interface}=\${logical_interface}"
+fi
+ #else
+eval "physical_interface=\\${logical_interface_mapping_\${logical_interface}}"
+if [ -z "\${physical_interface}" ]; then
+ eval "logical_interface_mapping_\${logical_interface}="
+fi
+ #end if
+#end for
+
+echo "logical interfaces: \${logical_interfaces[@]}" >> /tmp/network_log
+
+echo "finish mapping logical interfaces in network config to physical interfaces" >> /tmp/network_log
+for key in \${logical_interfaces[@]}; do
+ eval "physical_interface=\\${logical_interface_mapping_\${key}}"
+ echo "map logical interface \${key} to physical interface \${physical_interface}" >> /tmp/network_log
+done
+for key in \${physical_interfaces[@]}; do
+ eval "logical_interface=\\${physical_interface_mapping_\${key}}"
+ echo "map physical interface \${key} to logical interface \${logical_interface}" >> /tmp/network_log
+done
+
+# map unmapped logical interface to the same name physical interface
+echo "mapping unmapped logical interfaces to the same name physical interfaces" >> /tmp/network_log
+for logical_interface in \${logical_interfaces[@]}; do
+ eval "physical_interface=\\${logical_interface_mapping_\${logical_interface}}"
+ if [ ! -z "\${physical_interface}" ]; then
+ echo "ignore logical interface \${logical_interface} where its physical interface is \${physical_interface}" >> /tmp/network_log
+ continue
+ fi
+ # check if the same name physical interface is mapped
+ eval "mapped_logical_interface=\\${physical_interface_mapping_\${logical_interface}}"
+ if [ ! -z "\${mapped_logical_interface}" ]; then
+ echo "ignore logical interface \${logical_interface} since the same name physical interface is mapped by logical interface \${mapped_logical_interface}" >> /tmp/network_log
+ continue
+ fi
+ # check if the same name physical interface exists
+ eval "mapped_logical_interface=\\${physical_interface_\${logical_interface}}"
+ if [ -z "\${mapped_logical_interface}" ]; then
+ echo "ignore logical interface \${logical_interface} since the same name physical interface does not exist" >> /tmp/network_log
+ continue
+ fi
+ eval "logical_interface_mapping_\${logical_interface}=\${logical_interface}"
+ eval "physical_interface_mapping_\${logical_interface}=\${logical_interface}"
+ echo "set logical interface \${logical_interface} to the same physical interface" >> /tmp/network_log
+done
+
+echo "finish mapping unmapped logical interfaces in network config to the same name physical interfaces" >> /tmp/network_log
+for key in \${logical_interfaces[@]}; do
+ eval "physical_interface=\\${logical_interface_mapping_\${key}}"
+ echo "map logical interface \${key} to physical interface \${physical_interface}" >> /tmp/network_log
+done
+for key in \${physical_interfaces[@]}; do
+ eval "logical_interface=\\${physical_interface_mapping_\${key}}"
+ echo "map physical interface \${key} to logical interface \${logical_interface}" >> /tmp/network_log
+done
+
+declare -a unset_logical_interfaces
+unset_logical_interfaces=()
+declare -a unset_physical_interfaces
+unset_physical_interfaces=()
+
+echo "get unset logical interfaces from \${logical_interfaces[@]}" >> /tmp/network_log
+for logical_interface in \${logical_interfaces[@]}; do
+ eval "physical_interface=\\${logical_interface_mapping_\${logical_interface}}"
+ if [ ! -z "\${physical_interface}" ]; then
+ echo "logical interface \${logical_interface} is already set to \${physical_interface}" >> /tmp/network_log
+ continue
+ fi
+ unset_logical_interfaces+=(\${logical_interface})
+done
+echo "got unset logical interfaces: \${unset_logical_interfaces[@]}" >> /tmp/network_log
+
+echo "get unset physical interfaces from \${physical_interfaces[@]}" >> /tmp/network_log
+for physical_interface in \${physical_interfaces[@]}; do
+ eval "logical_interface=\\${physical_interface_mapping_\${physical_interface}}"
+ if [ ! -z "\${logical_interface}" ]; then
+ echo "physical interface \${physical_interface} is already set to \${logical_interface}" >> /tmp/network_log
+ continue
+ fi
+ unset_physical_interfaces+=(\${physical_interface})
+ eval "unset_physical_interface_\${physical_interface}=\${physical_interface}"
+done
+echo "got unset physical interfaces: \${unset_physical_interfaces[@]}" >> /tmp/network_log
+
+sorted_unset_physical_interfaces=(\$(printf '%s\n' \${unset_physical_interfaces[@]} | sort))
+echo "sorted unset physical interfaces: \${sorted_unset_physical_interfaces[@]}" >> /tmp/network_log
+sorted_unset_logical_interfaces=(\$(printf '%s\n' \${unset_logical_interfaces[@]} | sort))
+echo "sorted unset logical interfaces: \${sorted_unset_logical_interfaces[@]}" >> /tmp/network_log
+
+# map unset logical interface to unset physical interface
+echo "map unset logical interfaces \${sorted_unset_logical_interfaces[@]} to unset physical interfaces \${sorted_unset_physical_interfaces[@]}" >> /tmp/network_log
+while [ \${#sorted_unset_physical_interfaces[@]} -gt 0 -a \${#sorted_unset_logical_interfaces[@]} -gt 0 ]; do
+ physical_interface=\${sorted_unset_physical_interfaces[0]}
+ logical_interface=\${sorted_unset_logical_interfaces[0]}
+ echo "map unset logical interface \${logical_interface} to unset physical interface \${physical_interface}" >> /tmp/network_log
+ unset sorted_unset_physical_interfaces[0]
+ unset sorted_unset_logical_interfaces[0]
+ echo "map unset logical interface \${logical_interface} to unset physical interface \${physical_interface}" >> /tmp/network_log
+ eval "physical_interface_mapping_\${physical_interface}=\${logical_interface}"
+ eval "logical_interface_mapping_\${logical_interface}=\${physical_interface}"
+done
+unset_logical_interfaces=()
+unset_physical_interfaces=()
+
+echo "finish mapping unmapped logical interfaces in network config to unmapped physical interfaces" >> /tmp/network_log
+for key in \${logical_interfaces[@]}; do
+ eval "physical_interface=\\${logical_interface_mapping_\${key}}"
+ echo "map logical interface \${key} to physical interface \${physical_interface}" >> /tmp/network_log
+done
+for key in \${physical_interfaces[@]}; do
+ eval "logical_interface=\\${physical_interface_mapping_\${key}}"
+ echo "map physical interface \${key} to logical interface \${logical_interface}" >> /tmp/network_log
+done
+
+echo "unset logical interfaces: \${sorted_unset_logical_interfaces[@]}" >> /tmp/network_log
+echo "unset physical interfaces: \${sorted_unset_physical_interfaces[@]}" >> /tmp/network_log
+
+# map remaining unmapped logical interfaces
+echo "map remaining unmapped logical interfaces" >> /tmp/network_log
+if [ \${#sorted_unset_logical_interfaces[@]} -gt 0 ]; then
+ declare -a available_logical_interfaces
+ available_logical_interfaces=()
+ # get all available logical interfaces which the same name physical interface is not used
+ for logical_interface in \${logical_interfaces[@]}; do
+ eval "mapped_logical_interface=\\${physical_interface_mapping_\${logical_interface}}"
+ if [ -z "\${mapped_logical_interface}" ]; then
+ eval "available_logical_interface_\${logical_interface}=\${logical_interface}"
+ available_logical_interfaces+=(\${logical_interface})
+ else
+ echo "ignore logical interface \${logical_interface} since the same name physical interface mapped to logical interface \${mapped_logical_interface}" >> /tmp/network_log
+ fi
+ done
+
+ # add extra logical interfaces name to physical interfaces
+ physical_interfaces+=(\${available_logical_interfaces[@]})
+ echo "updated physical interfaces: \${physical_interfaces[@]}" >> /tmp/network_log
+
+ #first map logical interface to the same name physical interface if that physical interface name is not used
+ unset_logical_interfaces=()
+ for logical_interface in \${sorted_unset_logical_interfaces[@]}; do
+ eval "available_logical_interface=\\${available_logical_interface_\${logical_interface}}"
+ if [ ! -z "\${available_logical_interface}" ]; then
+ eval "physical_interface_mapping_\${available_logical_interface}=\${logical_interface}"
+ eval "logical_interface_mapping_\${logical_interface}=\${available_logical_interface}"
+ else
+ unset_logical_interfaces+=(\${logical_interface})
+ fi
+ done
+ sorted_unset_logical_interfaces=(\${unset_logical_interfaces[@]})
+
+ echo "finish mapping ramaining unmapped logical interfaces to the same name physical interface" >> /tmp/network_log
+ for key in \${logical_interfaces}; do
+ eval "physical_interface=\\${logical_interface_mapping_\${key}}"
+ echo "map logical interface \${key} to physical interface \${physical_interface}" >> /tmp/network_log
+ done
+ for key in \${physical_interfaces}; do
+ eval "logical_interface=\\${physical_interface_mapping_\${key}}"
+ echo "map physical interface \${key} to logical interface \${logical_interface}" >> /tmp/network_log
+ done
+ echo "unset physical interfaces \${sorted_unset_physical_interfaces[@]}" >> /tmp/network_log
+ echo "unset logical interfaces \${sorted_unset_logical_interfaces[@]}" >> /tmp/network_log
+
+ # map remain unset logical interfaces to available logical interface names
+ for logical_interface in \${sorted_unset_logical_interfaces[@]}; do
+ for available_logical_interface in \${available_logical_interfaces[@}}; do
+ eval "mapped_logical_interface=\\${physical_interface_mapping_\${available_logical_interface}}"
+ if [ -z "\${mapped_logical_interface}" ]; then
+ eval "physical_interface_mapping_\${available_logical_interface}=\${logical_interface}"
+ eval "logical_interface_mapping_\${logical_interface}=\${available_logical_interface}"
+ break
+ fi
+ done
+ done
+fi
+unset_logical_interfaces=()
+sorted_unset_logical_interfaces=()
+
+echo "finish mapping ramaining unmapped logical interfaces" >> /tmp/network_log
+for key in \${logical_interfaces[@]}; do
+ eval "physical_interface=\\${logical_interface_mapping_\${key}}"
+ echo "map logical interface \${key} to physical interface \${physical_interface}" >> /tmp/network_log
+done
+for key in \${physical_interfaces[@]}; do
+ eval "logical_interface=\\${physical_interface_mapping_\${key}}"
+ echo "map physical interface \${key} to logical interface \${logical_interface}" >> /tmp/network_log
+done
+
+# map remaining unmapped physical interfaces
+echo "map remaining unmapped physical interfaces" >> /tmp/network_log
+if [ \${#sorted_unset_physical_interfaces[@]} -gt 0 ]; then
+ declare -a available_physical_interfaces
+ available_physical_interfaces=()
+ # get all available physical interfaces which the same name logical interface is not used
+ for physical_interface in \${physical_interfaces[@]}; do
+ eval "mapped_physical_interface=\\${logical_interface_mapping_\${physical_interface}}"
+ if [ -z "\${mapped_physical_interface}" ]; then
+ eval "available_physical_interface_\${physical_interface}=\${physical_interface}"
+ available_physical_interfaces+=(\${physical_interface})
+ else
+ echo "ignore physical interface \${physical_interface} since the same name logical interface mapped to physical interface \${mapped_physical_interface}" >> /tmp/network_log
+ fi
+ done
+
+ logical_interfaces+=(\${available_physical_interfaces[@]})
+ echo "updated logical interfaces: \${logical_interfaces[@]}" >> /tmp/network_log
+
+ #first map physical interface to the same name logical interface if that logical interface name is not used
+ unset_physical_interfaces=()
+ for physical_interface in \${sorted_unset_physical_interfaces[@]}; do
+ eval "available_physical_interface=\\${available_physical_interface_\${physical_interface}}"
+ if [ ! -z "\${available_physical_interface}" ]; then
+ eval "logical_interface_mapping_\${available_physical_interface}=\${physical_interface}"
+ eval "physical_interface_mapping_\${physical_interface}=\${available_physical_interface}"
+ else
+ unset_physical_interfaces+=(\${physical_interface})
+ fi
+ done
+ sorted_unset_physical_interfaces=(\${unset_physical_interfaces[@]})
+
+ # map remain unset physical interfaces to logical interface name as available physical interface names
+ for physical_interface in \${sorted_unset_physical_interfaces}; do
+ for available_physical_interface in \${available_physical_interfaces}; do
+ eval "mapped_physical_interface=\\${logical_interface_mapping_\${available_physical_interface}}"
+ if [ -z "\${mapped_physical_interface}" ]; then
+ eval "logical_interface_mapping_\${available_physical_interface}=\${physical_interface}"
+ eval "physical_interface_mapping_\${physical_interface}=\${available_physical_interface}"
+ break
+ fi
+ done
+ done
+fi
+unset_physical_interfaces=()
+sorted_unset_physical_interfaces=()
+
+echo "finish mapping ramaining unmapped physical interfaces" >> /tmp/network_log
+for key in \${logical_interfaces[@]}; do
+ eval "physical_interface=\\${logical_interface_mapping_\${key}}"
+ echo "map logical interface \${key} to physical interface \${physical_interface}" >> /tmp/network_log
+done
+for key in \${physical_interfaces[@]}; do
+ eval "logical_interface=\\${physical_interface_mapping_\${key}}"
+ echo "map physical interface \${key} to logical interface \${logical_interface}" >> /tmp/network_log
+done
+
+echo 'false' > /tmp/profile/network.xml
+echo '' >> /tmp/profile/network.xml
+echo ' false' >> /tmp/profile/network.xml
+echo ' false' >> /tmp/profile/network.xml
+echo ' false' >> /tmp/profile/network.xml
+echo ' ' >> /tmp/profile/network.xml
+#if $hostname != ""
+echo ' $hostname' >> /tmp/profile/network.xml
+#end if
+#if $getVar("name_servers_search","") != ""
+echo ' ' >> /tmp/profile/network.xml
+ #for $sd in $name_servers_search
+echo ' $sd' >> /tmp/profile/network.xml
+ #end for
+echo ' ' >> /tmp/profile/network.xml
+#end if
+#if $getVar("name_servers","") != ""
+echo ' ' >> /tmp/profile/network.xml
+ #for $ns in $name_servers
+echo ' $ns' >> /tmp/profile/network.xml
+ #end for
+echo ' ' >> /tmp/profile/network.xml
+#end if
+#if $getVar("domain", "") != ""
+echo '$domain' >> /tmp/profile/network.xml
+#else
+echo 'site' >> /tmp/profile/network.xml
+#end if
+echo '' >> /tmp/profile/network.xml
+
+echo '' >> /tmp/profile/network.xml
+
+#for $iname in $ikeys
+# Start configuration for $iname
+ ## create lots of variables to use later
+ #set $idata = $interfaces[$iname]
+ #set $mac = $idata.get("mac_address", "").upper()
+ #set $mtu = $idata.get("mtu", "")
+ #set $static = $idata.get("static", "")
+ #set $ip = $idata.get("ip_address", "")
+ #set $netmask = $idata.get("netmask", "")
+ #set $if_gateway = $idata.get("if_gateway", "")
+ #set $static_routes = $idata.get("static_routes", "")
+ #set $iface_type = $idata.get("interface_type", "").lower()
+ #set $iface_master = $idata.get("interface_master", "")
+ #set $bonding_opts = $idata.get("bonding_opts", "")
+ #set $bridge_opts = $idata.get("bridge_opts", "").split(" ")
+ #set $devfile = "/etc/sysconfig/network-scripts/cobbler/ifcfg-" + $iname
+ #set $routesfile = "/etc/sysconfig/network-scripts/cobbler/route-" + $iname
+
+used_logical_interface_$iname=$iname
+
+echo ' ' >> /tmp/profile/network.xml
+
+ #if $iface_type in ("slave","bond_slave","bridge_slave","bonded_bridge_slave")
+ #set $static = 1
+ #end if
+
+echo ' $iname' >> /tmp/profile/network.xml
+echo ' auto' >> /tmp/profile/network.xml
+echo ' no' >> /tmp/profile/network.xml
+ #if $iface_type not in ("master","bond","bridge","bonded_bridge_slave")
+ #if $vlanpattern.match($iname)
+ #pass
+ #else
+ #set $interface_matched = $subinterfacepattern.match($iname)
+ #if $interface_matched
+ #set $interface_name = $interface_matched.group(1)
+logical_interface=$interface_name
+ #else
+logical_interface=$iname
+ #end if
+eval "physical_interface=\\${logical_interface_mapping_\${logical_interface}}"
+if [ ! -z "\${physical_interface}" ]; then
+ eval "physical_mac=\\${physical_interface_mac_\${physical_interface}}"
+fi
+if [ ! -z "\${physical_mac}" ]; then
+ physical_mac=\$(echo \${physical_mac} | tr 'A-Z' 'a-z')
+ echo " \${physical_mac}" >> /tmp/profile/network.xml
+fi
+ #end if
+ #end if
+
+ #if $iface_type in ("master","bond","bonded_bridge_slave")
+echo ' yes' >> /tmp/profile/network.xml
+ #if $bonding_opts != ""
+echo ' $bonding_opts.lower()' >> /tmp/profile/network.xml
+ #end if
+ #set $loop_ikeys = $interfaces.keys()
+ #set $loop_counter = 0
+ #for $loop_iface in $loop_ikeys
+ #set $loop_idata = $interfaces[$loop_iface]
+ #set $loop_interface_type = $loop_idata["interface_type"]
+ #if $loop_interface_type.lower == "bond_slave"
+ #if $loop_idata["interface_master"] != ""
+ #if $loop_idata["interface_master"].lower() == $iface.lower()
+echo ' $loop_iface' >> /tmp/profile/network.xml
+ #set $loop_counter += 1
+ #end if
+ #end if
+ #end if
+ #end for
+ #end if
+ #if $static
+echo ' static' >> /tmp/profile/network.xml
+ #if $iname in $promisc_interfaces
+ #pass
+ #elif $ip != ""
+echo ' $ip' >> /tmp/profile/network.xml
+
+ #if $netmask == ""
+ ## Default to 255.255.255.0?
+ #set $netmask = "255.255.255.0"
+ #end if
+echo " $netmask" >> /tmp/profile/network.xml
+ #end if
+ #else
+echo ' dhcp' >> /tmp/profile/network.xml
+ #end if
+
+ #if $mtu != ""
+echo " $mtu" >> /tmp/profile/network.xml
+ #end if
+echo ' ' >> /tmp/profile/network.xml
+#end for
+
+for logical_interface in \${logical_interfaces[@]}; do
+ eval "used_logical_interface=\\${used_logical_interface_\${logical_interface}}"
+ if [ ! -z "\${used_logical_interface}" ]; then
+ # ignore logical interface that is already generated in above
+ echo "ignore used logical interface \${logical_interface}" >> /tmp/network_log
+ continue
+ fi
+ echo "add logical interface \${logical_interface} into network config since it is not set above" >> /tmp/network_log
+ eval "physical_interface=\\${logical_interface_mapping_\${logical_interface}}"
+ if [ ! -z "\${physical_interface}" ]; then
+ eval "mac=\\${physical_interface_mac_\${physical_interface}}"
+ echo " " >> /tmp/profile/network.xml
+ echo " \${logical_interface}" >> /tmp/profile/network.xml
+ echo " auto" >> /tmp/profile/network.xml
+ echo " no" >> /tmp/profile/network.xml
+ echo " static" >> /tmp/profile/network.xml
+ if [ ! -z "\$mac" ]; then
+ mac=\$(echo \${mac} | tr 'A-Z' 'a-z')
+ echo " \${mac}" >> /tmp/profile/network.xml
+ fi
+ echo " " >> /tmp/profile/network.xml
+ fi
+done
+echo '' >> /tmp/profile/network.xml
+echo 'false' >> /tmp/profile/network.xml
+echo '' >> /tmp/profile/network.xml
+for logical_interface in \${logical_interfaces[@]}; do
+ eval "physical_interface=\\${logical_interface_mapping_\${logical_interface}}"
+ if [ ! -z "\${physical_interface}" ]; then
+ eval "mac=\\${physical_interface_mac_\${physical_interface}}"
+ if [ ! -z "\$mac" ]; then
+ mac=\$(echo \${mac} | tr 'A-Z' 'a-z')
+ echo " " >> /tmp/profile/network.xml
+ echo " \$logical_interface" >> /tmp/profile/network.xml
+ echo " ATTR{address}" >> /tmp/profile/network.xml
+ echo " \${mac}" >> /tmp/profile/network.xml
+ echo " " >> /tmp/profile/network.xml
+ fi
+ fi
+done
+echo '' >> /tmp/profile/network.xml
+echo '' >> /tmp/profile/network.xml
+echo ' false' >> /tmp/profile/network.xml
+echo ' ' >> /tmp/profile/network.xml
+#if $gateway != ""
+echo ' ' >> /tmp/profile/network.xml
+echo ' default' >> /tmp/profile/network.xml
+echo ' -' >> /tmp/profile/network.xml
+echo ' -' >> /tmp/profile/network.xml
+echo ' $gateway' >> /tmp/profile/network.xml
+echo ' ' >> /tmp/profile/network.xml
+#end if
+#for $iname in $ikeys
+ ## create lots of variables to use later
+ #set $idata = $interfaces[$iname]
+ #set $static_routes = $idata.get("static_routes", "")
+ #for $route in $static_routes
+ #set routepattern = $re.compile("[0-9/.]+:[0-9.]+")
+ #if $routepattern.match($route)
+ #set $routebits = $route.split(":")
+ #set [$network, $router] = $route.split(":")
+ #import netaddr
+ #set interface_network = $netaddr.IPNetwork($network)
+ #set interface_network_ip = $str($interface_network.ip)
+ #set interface_network_netmask = $str($interface_network.netmask)
+echo ' ' >> /tmp/profile/network.xml
+echo ' $interface_network_ip' >> /tmp/profile/network.xml
+echo ' $interface_network_netmask' >> /tmp/profile/network.xml
+echo ' $iname' >> /tmp/profile/network.xml
+echo ' $router' >> /tmp/profile/network.xml
+echo ' ' >> /tmp/profile/network.xml
+echo "$network via $router" >> $routesfile
+ #else
+# Warning: invalid route "$route"
+ #end if
+ #end for
+#end for
+echo ' ' >> /tmp/profile/network.xml
+echo '' >> /tmp/profile/network.xml
+
diff --git a/cobbler/snippets/suse_pre_log b/cobbler/snippets/suse_pre_log
new file mode 100644
index 0000000..d7fe28d
--- /dev/null
+++ b/cobbler/snippets/suse_pre_log
@@ -0,0 +1,2 @@
+set -x -v
+exec 1>/tmp/yast-pre.log 2>&1
diff --git a/cobbler/snippets/suse_pre_partition_disks b/cobbler/snippets/suse_pre_partition_disks
new file mode 100644
index 0000000..c83e082
--- /dev/null
+++ b/cobbler/snippets/suse_pre_partition_disks
@@ -0,0 +1,543 @@
+#set hostname=$getVar('hostname',None)
+#set partition = $getVar('partition', None)
+#set partition_size = $getVar('partition_size', None)
+#set partition_maxsize = $getVar('partition_maxsize', None)
+#set disk_reserve_size = $getVar('disk_reserve_size', None)
+#set disk_max_size = $getVar('disk_max_size', None)
+#set default_disk_reserve_size = $getVar('default_disk_reserve_size', '0')
+#set default_disk_max_size = $getVar('default_disk_max_size', '0')
+
+#if $hostname == None
+#set $vgname = "VolGroup00"
+#else
+#set $vgname = $hostname.split('.')[0]
+#end if
+
+set \$(ls -s -l /dev/disk/by-path | awk '{print \$10, \$12}')
+let disk_mapping_nums=\$#/2
+let disk_mapping_offset=0
+echo "disk_mapping_nums: \$disk_mapping_nums" > /tmp/log
+echo "disk_mapping: \$*" >> /tmp/log
+declare -a disk_mapping
+disk_mapping=()
+declare -a disk_path_mapping
+disk_path_mapping=()
+
+while [ \$disk_mapping_offset -lt \$disk_mapping_nums ]; do
+ let found_disk_type=0
+#if $getVar('disk_type_only','') != ""
+ if expr match "\$1" ".*-${disk_type_only}-.*"; then
+ let found_disk_type=1
+ fi
+#else
+ let found_disk_type=1
+#end if
+ path_name=\$(basename \$1)
+ disk_path_name=\$(echo \${path_name} | tr '-' '_' | tr ':' '_' | tr '.' '_')
+ disk_name=\$(basename \$2)
+ let disk_mapping_offset=\$disk_mapping_offset+1
+ shift 2
+
+ if [ \$found_disk_type -gt 0 ]; then
+ disk_mapping+=(\${disk_name})
+ disk_path_mapping+=(\${disk_path_name})
+ eval "disk_\${disk_name}=/dev/disk/by-path/\${path_name}"
+ eval "disk_\${disk_path_name}=/dev/disk/by-path/\${path_name}"
+ eval "disk_path_\${disk_path_name}=/dev/\${disk_name}"
+ eval "disk_path_\${disk_name}=/dev/\${disk_name}"
+ fi
+done
+
+echo "finish disk mapping" >> /tmp/log
+for key in \${disk_mapping[@]}; do
+ eval "disk_path=\\${disk_\$key}"
+ echo "disk_mapping \$key => \${disk_path}" >> /tmp/log
+done
+
+for key in \${disk_path_mapping[@]}; do
+ eval "disk=\\${disk_path_\$key}"
+ echo "disk path mapping \$key => \${disk}" >> /tmp/log
+done
+
+
+declare -a partition_disks
+partition_disks=()
+declare -a disks
+disks=()
+set \$(lsblk -n -d -o NAME,RM,RO,SIZE | awk '\$2 == "0" && \$3 == "0" { print \$1, \$4 }')
+let disk_nums=\$#/2
+let disk_offset=0
+while [ \$disk_offset -lt \$disk_nums ]; do
+ disk_name=\$1
+ shift 2
+ let disk_offset=\$disk_offset+1
+ eval "disk_path=\\${disk_\${disk_name}}"
+ if [ -z "\${disk_path}" ]; then
+ echo "ignore disk \${disk_name} since it is not in disk_mapping" >> /tmp/log
+ continue
+ fi
+ let found_disk=0
+
+#if $getVar('partitions_only', '') != ""
+ #for $partition_only in $partitions_only.split(',')
+ #if not $partition_only
+ #continue
+ #end if
+ if expr match "\${disk_name}" "$partition_only"; then
+ let found_disk=1
+ else
+ echo "disk \${disk_name} does not match $partition_only" >> /tmp/log
+ fi
+ #end for
+#else
+ let found_disk=1
+#end if
+
+#if $getVar('partition_by_path', '0') != "0"
+ eval "disk=\\${disk_\${disk_name}}"
+#else
+ eval "disk=\\${disk_path_\${disk_name}}"
+#end if
+
+ if [ \${found_disk} -gt 0 ]; then
+ echo "add disk \${disk_name} in partitioning list" >> /tmp/log
+ partition_disks+=(\$disk)
+ fi
+
+ disks+=(\$disk)
+done
+echo "partition disks: \${partition_disks[@]}" >> /tmp/log
+echo "disks: \${disks[@]}" >> /tmp/log
+
+#if $getVar('sort_disks', '0') != "0"
+sorted_disks=(\$(printf '%s\n' \${partition_disks[@]} | sort))
+#else
+sorted_disks=(\${partition_disks[@]})
+#end if
+echo "sorted disks: \${sorted_disks[@]}" >> /tmp/log
+
+#if $getVar('start_from_disk', '') != ""
+ #set $start_from_disk = $int($start_from_disk)
+ #if $start_from_disk > 0
+ #set $disk_start_offset = $start_from_disk - 1
+ #else
+ #set $disk_start_offset = 0
+ #end if
+set \${sorted_disks[@]}
+shift $disk_start_offset
+sorted_disks=(\$@)
+echo "sorted disks begin from the $start_from_disk: \${sorted_disks[@]}" >> /tmp/log
+#end if
+
+#if $getVar('disk_num', '') != ""
+set \${sorted_disks[@]}
+sorted_disks=(\$(printf '%s\n' \$@ | head -n${disk_num}))
+echo "sorted disks for $disk_num disks: \${sorted_disks[@]}" >> /tmp/log
+#end if
+
+first_disk=""
+for disk in \${sorted_disks}; do
+ if [ -z "\${first_disk}" ]; then
+ first_disk=\${disk}
+ break
+ fi
+done
+echo "first disk \${first_disk}" >> /tmp/log
+
+declare -a remove_disks
+remove_disks=()
+#if $getVar('keep_old_partitions', '0') != "0"
+for disk in \${sorted_disks[@]}; do
+ dd if=/dev/zero of=\${disk} bs=512 count=1
+ remove_disks+=(\$disk)
+done
+#else
+for disk in \${disks[@]}; do
+ dd if=/dev/zero of=\${disk} bs=512 count=1
+ remove_disks+=(\$disk)
+done
+#end if
+echo "remove disks: \${remove_disks[@]}" >> /tmp/log
+
+disk_partitions=\$(pvs --noheadings --separator :| cut -d: -f1)
+remove_partitions=""
+remove_vgs=""
+for disk_partition in \${disk_partitions}; do
+ vg=\$(pvs --noheadings --separator : \${disk_partition} | cut -d: -f2)
+ remove_vg=""
+ remove_partition=""
+ for remove_disk in \${remove_disks[@]}; do
+#if $getVar('partition_by_path', '0') != "0"
+ path_name=\$(basename \${remove_disk})
+ disk_path_name=\$(echo \${path_name} | tr '-' '_' | tr ':' '_' | tr '.' '_')
+ remove_disk_path=\${remove_disk}
+ eval "remove_disk=\\${disk_path_\${disk_path_name}}"
+#else
+ disk_name=\$(basename \${remove_disk})
+ eval "remove_disk_path=\\${disk_\${disk_name}}"
+#end if
+ if [ -z "\${remove_disk}" ]; then
+ continue
+ fi
+ if [ -z "\${remove_disk_path}" ]; then
+ continue
+ fi
+ if expr match "\${disk_partition}" "\${remove_disk_path}.*"; then
+ remove_vg="\$vg"
+ remove_partition="\${disk_partition}"
+ else
+ echo "partition \${disk_partition} does not match \${remove_disk_path}.*" >> /tmp/log
+ fi
+ if expr match "\${disk_partition}" "\${remove_disk}.*"; then
+ remove_vg="\$vg"
+ remove_partition="\${disk_partition}"
+ else
+ echo "partition \${disk_partition} does not match \${remove_disk}.*" >> /tmp/log
+ fi
+ if [[ "\$vg" == "$vgname" ]]; then
+ remove_vg="\$vg"
+ remove_partition="\${disk_partition}"
+ fi
+ done
+ if [ ! -z "\${remove_vg}" ]; then
+ if [ -z "\${remove_vgs}" ]; then
+ remove_vgs="\${remove_vg}"
+ else
+ vg_removed=0
+ for vg in \${remove_vgs}; do
+ if [[ "\$vg" == "\${remove_vg}" ]]; then
+ vg_removed=1
+ fi
+ done
+ if [ \${vg_removed} -eq 0 ]; then
+ remove_vgs="\${remove_vgs} \${remove_vg}"
+ fi
+ fi
+ fi
+ if [ ! -z "\${remove_partition}" ]; then
+ if [ -z "\${remove_partitions}" ]; then
+ remove_partitions="\${remove_partition}"
+ else
+ pv_removed=0
+ for pv in ${remove_partitions}; do
+ if [[ "\$pv" == "\${remove_partition}" ]]; then
+ pv_removed=1
+ fi
+ done
+ if [ \${pv_removed} -eq 0 ]; then
+ remove_partitions="\${remove_partitions} \${remove_partition}"
+ fi
+ fi
+ fi
+done
+
+echo "remove vgs: \${remove_vgs}" >> /tmp/log
+for remove_vg in \${remove_vgs}; do
+ vgremove -f \${remove_vg}
+done
+
+echo "remove partitions: \${remove_partitions} from vgs \${remove_vgs}" >> /tmp/log
+for remove_partition in \${remove_partitions}; do
+ pvremove -ff -y \${remove_partition}
+done
+
+default_partition=$getVar('default_partition', '/')
+partition_fstype=$getVar('partition_fstype', 'ext3')
+echo "default partition \${default_partition}" >> /tmp/log
+echo "partition fstype \${partition_fstype}" >> /tmp/log
+
+#if $disk_reserve_size != None
+ #set disk_sizes = [disk_size.strip() for disk_size in $disk_reserve_size.split(';') if disk_size.strip()]
+ #for disk_and_size in $disk_sizes
+ #set disk_name, size = $disk_and_size.split(' ', 1)
+ #set disk_name = $disk_name.strip()
+reserve_disk_size_${disk_name}=${size}
+ #end for
+#end if
+
+default_reserve_disk_size=${default_disk_reserve_size}
+
+#if $disk_max_size != None
+ #set disk_sizes = [disk_size.strip() for disk_size in $disk_max_size.split(';') if disk_size.strip()]
+ #for disk_and_size in $disk_sizes
+ #set disk_name, size = $disk_and_size.split(' ', 1)
+ #set disk_name = $disk_name.strip()
+max_disk_size_${disk_name}=${size}
+ #end for
+#end if
+
+default_max_disk_size=${default_disk_max_size}
+
+declare -a partition_names
+partition_names=()
+default_partition_name=""
+#if $partition != None
+ #set vol_sizes = [part.strip() for part in $partition.split(';') if part.strip()]
+ #for vol_and_size in $vol_sizes
+ #set vol, vol_size = $vol_and_size.split(' ', 1)
+ #set vol = $vol.strip()
+ #if $vol == '/'
+ #set volname = 'root'
+ #elif $vol == 'swap'
+ #set volname = 'swap'
+ #elif $vol.startswith('/')
+ #set volname = $vol[1:].replace('/', '_')
+ #else
+# $vol is not starts with /
+ #continue
+ #end if
+partition_names+=($volname)
+if [[ "$vol" == "\$default_partition" ]]; then
+ default_partition_name=$volname
+fi
+partition_point_$volname=$vol
+ #set vol_size = $vol_size.strip()
+ #if $vol_size.endswith('%'):
+partition_percentage_$volname=$vol_size
+ #else
+partition_size_$volname=$vol_size
+ #end if
+ #end for
+#end if
+
+#if $partition_size != None
+ #set vol_sizes = [part.strip() for part in $partition_size.split(';') if part.strip()]
+ #for vol_and_size in $vol_sizes
+ #set vol, vol_size = $vol_and_size.split(' ', 1)
+ #set vol = $vol.strip()
+ #if $vol == '/'
+ #set volname = 'root'
+ #elif $vol == 'swap'
+ #set volname = 'swap'
+ #elif $vol.startswith('/')
+ #set volname = $vol[1:].replace('/', '_')
+ #else
+# $vol is not starts with /
+ #continue
+ #end if
+partitions_size_$volname=${vol_size}
+ #end for
+#end if
+
+#if $partition_maxsize != None
+ #set vol_sizes = [part.strip() for part in $partition_maxsize.split(';') if part.strip()]
+ #for vol_and_size in $vol_sizes
+ #set vol, vol_size = $vol_and_size.split(' ', 1)
+ #set vol = $vol.strip()
+ #if $vol == '/'
+ #set volname = 'root'
+ #elif $vol == 'swap'
+ #set volname = 'swap'
+ #elif $vol.startswith('/')
+ #set volname = $vol[1:].replace('/', '_')
+ #else
+# $vol is not starts with /
+ #continue
+ #end if
+partition_maxsize_$volname=${vol_size}
+ #end for
+#end if
+
+if [ -z "\${default_partition_name}" ]; then
+ default_partition_name=root
+fi
+
+if [ -z "\${partition_point_root}" ]; then
+ partition_names+=(root)
+ partition_point_root=/root
+fi
+
+eval "default_partition_point=\\${partition_point_\${default_partition_name}}"
+if [ -z "\${default_partition_point}" ]; then
+ partition_names+=(\${default_partition_name})
+ default_partition_point="/\${default_partition_name}"
+ eval "partition_point_\${default_partition_name}=\${default_partition_point}"
+fi
+
+echo "finish partition mapping" >> /tmp/log
+for key in \${partition_names[@]}; do
+ eval "mountpoint=\\${partition_point_\$key}"
+ echo "partition mountpoint \$key => \${mountpoint}" >> /tmp/log
+ eval "partition_percentage=\\${partition_percentage_\$key}"
+ echo "partition percentage \$key => \${partition_percentage}" >> /tmp/log
+ eval "partition_size=\\${partition_size_\$key}"
+ echo "partition size \$key => \${partition_size}" >> /tmp/log
+ eval "partition_max_size=\\${partition_max_size_\$key}"
+ echo "partition max size \$key => \${partition_max_size}" >> /tmp/log
+done
+
+if [ -z "\${first_disk}" ]; then
+ first_disk=/dev/sda
+fi
+
+declare -a vggroup
+vggroup=()
+for disk in \${sorted_disks[@]}; do
+ disk_name=\$(basename \$disk)
+ eval "used_disk_\${disk_name}=\$disk"
+ echo "add disk \$disk into disks" >> /tmp/log
+ echo '' >> /tmp/profile/partition.xml
+ echo " \$disk" >> /tmp/profile/partition.xml
+ echo ' true' >> /tmp/profile/partition.xml
+ echo ' ' >> /tmp/profile/partition.xml
+ echo ' gpt' >> /tmp/profile/partition.xml
+ echo ' ' >> /tmp/profile/partition.xml
+
+ if [[ "\$disk" == "\${first_disk}" ]]; then
+ percentage=\${partition_percentage_boot}
+ echo "got percentage \${percentage} for partition boot" >> /tmp/log
+ if [[ ! -z "\$percentage" ]] && [[ "\$percentage" != "0" ]]; then
+ size=\$percentage
+ else
+ size=\${partition_size_boot}
+ fi
+ echo "got size \$size for partition boot" >> /tmp/log
+ used_partition_boot="/boot"
+ echo "add partition /boot into disk \$disk" >> /tmp/log
+ echo ' ' >> /tmp/profile/partition.xml
+ echo " \${partition_fstype}" >> /tmp/profile/partition.xml
+ echo ' true' >> /tmp/profile/partition.xml
+#if $getVar('partition_by_path', '0') != "0"
+ echo ' uuid' >> /tmp/profile/partition.xml
+#else
+ echo ' device' >> /tmp/profile/partition.xml
+#end if
+ echo ' primary' >> /tmp/profile/partition.xml
+ echo ' /boot' >> /tmp/profile/partition.xml
+ if [[ ! -z "\$size" ]] && [[ "$size" != "0" ]]; then
+ echo " \${size}" >> /tmp/profile/partition.xml
+ else
+ echo " auto" >> /tmp/profile/partition.xml
+ fi
+ echo ' ' >> /tmp/profile/partition.xml
+ percentage=\${partition_percentage_swap}
+ echo "got percentage \$percentage for partition swap" >> /tmp/log
+ if [[ ! -z "\$percentage" ]] && [[ "\$percentage" != "0" ]]; then
+ size=\$percentage
+ else
+ size=\${partition_size_swap}
+ fi
+ echo "got size \$size for partition swap" >> /tmp/log
+ used_partition_swap=swap
+ echo "add partition swap into disk \$disk" >> /tmp/log
+ echo ' ' >> /tmp/profile/partition.xml
+ echo " swap" >> /tmp/profile/partition.xml
+ echo ' primary' >> /tmp/profile/partition.xml
+ echo ' swap' >> /tmp/profile/partition.xml
+ if [[ ! -z "\$size" ]] && [[ "$size" != "0" ]]; then
+ echo " \${size}" >> /tmp/profile/partition.xml
+ else
+ echo " auto" >> /tmp/profile/partition.xml
+ fi
+ echo ' ' >> /tmp/profile/partition.xml
+ fi
+ echo "add lvm partition $vgname into disk \$disk" >> /tmp/log
+ echo ' ' >> /tmp/profile/partition.xml
+ echo ' $vgname' >> /tmp/profile/partition.xml
+ eval "max_disk_size=\\${max_disk_size_\${disk_name}}"
+ if [ -z "\${max_disk_size}" ]; then
+ max_disk_size=\${default_max_disk_size}
+ fi
+ echo "got max disk size \${max_disk_size} for disk \$disk" >> /tmp/log
+ if [[ ! -z "\${max_disk_size}" ]] && [[ "\${max_disk_size}" != "0" ]]; then
+ echo ' ${max_disk_size}' >> /tmp/profile/partition.xml
+ else
+ echo " max" >> /tmp/profile/partition.xml
+ fi
+ echo ' ' >> /tmp/profile/partition.xml
+ vggroup+=(\$disk)
+ eval "reserve_disk_size=\\${reserve_disk_size_\${disk_name}}"
+ if [ -z "\${reserve_disk_size}" ]; then
+ reserve_disk_size=\${default_reserve_disk_size}
+ fi
+ echo "reserve size \${reserve_disk_size} on \${disk}" >> /tmp/log
+ if [[ ! -z "\${reserve_disk_size}" ]] && [[ "\${reserve_disk_size}" != "0" ]]; then
+ echo "add partition /reserved_\${disk_name} into partitions" >> /tmp/log
+ echo ' ' >> /tmp/profile/partition.xml
+ echo " \${partition_fstype}" >> /tmp/profile/partition.xml
+ echo ' true' >> /tmp/profile/partition.xml
+ echo " /reserved_\${disk_name}" >> /tmp/profile/partition.xml
+ echo ' label' >> /tmp/profile/partition.xml
+ echo " " >> /tmp/profile/partition.xml
+ echo " \${reserve_disk_size}" >> /tmp/profile/partition.xml
+ echo ' ' >> /tmp/profile/partition.xml
+ else
+ echo "no reserve space on disk \$disk" >> /tmp/log
+ fi
+ echo ' ' >> /tmp/profile/partition.xml
+ echo '' >> /tmp/profile/partition.xml
+done
+
+for disk in \${remove_disks[@]}; do
+ disk_name=\$(basename \$disk)
+ eval "used_disk=\\${used_disk_\${disk_name}}"
+ if [ ! -z "\${used_disk}" ]; then
+ # ignore disk that is already generated
+ echo "ignore disk \$disk that is already generated" >> /tmp/log
+ continue
+ fi
+ eval "used_disk_\${disk_name}=\$disk"
+ echo "add disk \$disk into disks" >> /tmp/log
+ echo '' >> /tmp/profile/partition.xml
+ echo " \$disk" >> /tmp/profile/partition.xml
+ echo ' true' >> /tmp/profile/partition.xml
+ echo ' ' >> /tmp/profile/partition.xml
+ echo ' gpt' >> /tmp/profile/partition.xml
+ echo '' >> /tmp/profile/partition.xml
+done
+
+echo "partition disks" >> /tmp/log
+
+if [ \${#vggroup[@]} -gt 0 ]; then
+ echo '' >> /tmp/profile/partition.xml
+ echo " /dev/$vgname" >> /tmp/profile/partition.xml
+ echo ' CT_LVM' >> /tmp/profile/partition.xml
+ echo ' true' >> /tmp/profile/partition.xml
+ echo ' 4M' >> /tmp/profile/partition.xml
+ echo ' ' >> /tmp/profile/partition.xml
+ echo ' ' >> /tmp/profile/partition.xml
+ for partition_name in \${partition_names[@]}; do
+ eval "used_partition=\\${used_partition_\${partition_name}}"
+ if [ ! -z "\${used_partition}" ]; then
+ echo "ignore partition \${used_partition} since it is already used" >> /tmp/log
+ continue
+ fi
+ eval "partition=\\${partition_point_\${partition_name}}"
+ echo "setup lvm partition name \$partition_name" >> /tmp/log
+ echo ' ' >> /tmp/profile/partition.xml
+ echo ' true' >> /tmp/profile/partition.xml
+ echo " \${partition_fstype}" >> /tmp/profile/partition.xml
+ echo " \${partition_name}vol" >> /tmp/profile/partition.xml
+ echo " \$partition" >> /tmp/profile/partition.xml
+ eval "percentage=\\${partition_percentage_\${partition_name}}"
+ echo "got percentage \${percentage} for partition \${partition_name}" >> /tmp/log
+ if [[ ! -z "\${percentage}" ]] && [[ "\${percentage}" != "0" ]]; then
+ size=\${percentage}
+ echo "set size \$size from percentage \$percentage for partition \${partition_name}" >> /tmp/log
+ else
+ eval "size=\\${partition_size_\${partition_name}}"
+ fi
+ echo "got size \$size for partition \${partition_name}" >> /tmp/log
+ if [[ ! -z "\${size}" ]] && [[ "\$size" != "0" ]]; then
+ echo " \$size" >> /tmp/profile/partition.xml
+ else
+ echo ' max' >> /tmp/profile/partition.xml
+ fi
+ echo ' ' >> /tmp/profile/partition.xml
+ done
+ echo ' ' >> /tmp/profile/partition.xml
+ echo '' >> /tmp/profile/partition.xml
+fi
+
+echo '' >> /tmp/profile/bootloader.xml
+echo ' ' >> /tmp/profile/bootloader.xml
+echo " \${first_disk}" >> /tmp/profile/bootloader.xml
+echo ' ' >> /tmp/profile/bootloader.xml
+echo '' >> /tmp/profile/bootloader.xml
+echo '' >> /tmp/profile/bootloader.xml
+echo ' true' >> /tmp/profile/bootloader.xml
+echo ' SUSE' >> /tmp/profile/bootloader.xml
+echo ' 0' >> /tmp/profile/bootloader.xml
+echo ' true' >> /tmp/profile/bootloader.xml
+echo ' true' >> /tmp/profile/bootloader.xml
+echo '' >> /tmp/profile/bootloader.xml
diff --git a/cobbler/snippets/suse_zypp b/cobbler/snippets/suse_zypp
new file mode 100644
index 0000000..ee802b2
--- /dev/null
+++ b/cobbler/snippets/suse_zypp
@@ -0,0 +1,27 @@
+#set profile_name = $getVar('profile_name','')
+#set os_info = $profile_name.split('-')
+#set osname = $os_info[0].lower()
+#set osversion = $os_info[1]
+
+#if $getVar("local_repo", "") == "" or $getVar("local_repo_only","1") == "0"
+ #set repos_snippet = 'zypp.repos.d/%s/%s/autoyast_repos' % ($osname, $osversion)
+$SNIPPET($repos_snippet)
+#end if
+
+#if $getVar("local_repo","") != ""
+ #set repo = 'zypp.repos.d/%s/%s/sles_repo' % ($osname, $osversion)
+cat << EOF > /etc/zypp/repos.d/Compass.repo
+[compass_repo]
+name=Compass zypp repo
+baseurl=$local_repo/$repo
+enabled=1
+autorefresh=1
+path=/
+type=rpm-md
+keeppackages=1
+EOF
+
+ #if $getVar("local_repo_only","1") != "0"
+zypper -n update
+ #end if
+#end if
diff --git a/cobbler/snippets/sysctl.xml b/cobbler/snippets/sysctl.xml
new file mode 100644
index 0000000..a842674
--- /dev/null
+++ b/cobbler/snippets/sysctl.xml
@@ -0,0 +1,78 @@
+
+ /etc/sysctl.conf
+
+
+
+ root.root
+ 644
+
diff --git a/cobbler/snippets/yast_repo_config.xml b/cobbler/snippets/yast_repo_config.xml
new file mode 100644
index 0000000..9f9cfa3
--- /dev/null
+++ b/cobbler/snippets/yast_repo_config.xml
@@ -0,0 +1,20 @@
+# Repository Config
+#set $repo_data = $getVar("repo_data",[])
+
+
+#for $repo in $repo_data
+
+ #if $repo.mirror_locally
+ http://$http_server/cobbler/repo_mirror/${repo.name}/
+ #else
+ ${repo.mirror}
+ #end if
+ ${repo.name}
+ /
+ false
+
+ ${repo.name}
+
+#end for
+
+
diff --git a/cobbler/snippets/zypp.repos.d/sles/11sp3/autoyast_repos b/cobbler/snippets/zypp.repos.d/sles/11sp3/autoyast_repos
new file mode 100644
index 0000000..e69de29