Browse Source

cobbler pxe loop fix and utils

Signed-off-by: Lee Reynolds <Lee.Reynolds@asu.edu>
Lee Reynolds 3 years ago
parent
commit
215230d0db

+ 8 - 1
appliance/roles/provision/files/temp_centos7.ks

@@ -60,4 +60,11 @@ reboot
 %packages
 @core
 net-tools
-%end
+%end
+
+%post
+$SNIPPET('post_install_kernel_options')
+$SNIPPET('cobbler_register')
+$SNIPPET('kickstart_done')
+%end
+

+ 44 - 0
cobbler_utils/create_system_profiles.sh

@@ -0,0 +1,44 @@
+#!/bin/bash
+
+if [ $# -lt 1 ] ; then
+    echo -e "\nNeed mapping file\n"
+    echo -e "e.g. $(basename $0) mapping.csv\n"
+    exit 1
+fi
+
+MAPPING=$1
+
+if [ ! -e $MAPPING ] ; then
+    echo -e "\nMapping file $MAPPING does not exist\n"
+    exit 1
+fi
+
+if [ ! -d profiles ] ; then
+	mkdir profiles
+fi
+
+echo -e "#!/bin/bash\n" > profiles/addall.sh
+
+for profile in $(cat $MAPPING | grep -v ^MAC) ; do
+
+    MAC=$(echo $profile | cut -d "," -f 1 )
+    HOSTNAME=$(echo $profile | cut -d "," -f 2 )
+    IPADDR=$(echo $profile | cut -d "," -f 3 )
+    OUTFILE=${HOSTNAME}.sh
+
+    cat template.sh \
+    | sed -e "s/^HOSTNAME=/HOSTNAME=\"$HOSTNAME\"/" \
+    -e "s/^IPADDR=/IPADDR=\"$IPADDR\"/" \
+    -e "s/^MAC=/MAC=\"$MAC\"/" > profiles/$OUTFILE
+
+    echo "./$OUTFILE" >> profiles/addall.sh
+
+    chmod 755 profiles/$OUTFILE
+
+done
+
+echo -e "\ncobbler sync\n" >> profiles/addall.sh
+
+chmod 755 profiles/addall.sh
+
+

+ 20 - 0
cobbler_utils/template.sh

@@ -0,0 +1,20 @@
+#!/bin/bash
+
+HOSTNAME=
+IPADDR=
+MAC=
+INTERFACE="em1"
+PROFILE="CentOS7-x86_64"
+
+cobbler system remove --name=$HOSTNAME 2>&1 > /dev/null
+
+cobbler system add --name=$HOSTNAME --hostname=$HOSTNAME --profile=$PROFILE
+
+cobbler system edit --name=$HOSTNAME --interface=$INTERFACE --mac=$MAC
+
+cobbler system edit --name=$HOSTNAME --kopts="ksdevice=$MAC nomodeset consoleblank=0"
+
+cobbler system edit --name=$HOSTNAME --kopts-post="nomodeset consoleblank=0"
+
+#cobbler sync
+