diff --git a/cobbler/conf/dhcp.template b/cobbler/conf/dhcp.template index f76bcb9..79b2037 100644 --- a/cobbler/conf/dhcp.template +++ b/cobbler/conf/dhcp.template @@ -20,6 +20,11 @@ ignore client-updates; set vendorclass = option vendor-class-identifier; option pxe-system-type code 93 = unsigned integer 16; +option space pxelinux; +option pxelinux.magic code 208 = string; +option pxelinux.configfile code 209 = text; +option pxelinux.pathprefix code 210 = text; +option pxelinux.reboottime code 211 = unsigned integer 32; subnet $subnet netmask $netmask { option routers $gateway; @@ -55,6 +60,13 @@ group { #set iface = $dhcp_tags[$dhcp_tag][$mac] host $iface.name { hardware ethernet $mac; + site-option-space "pxelinux"; + option pxelinux.magic f1:00:74:7e; + if exists dhcp-parameter-request-list { + # Always send the PXELINUX options (specified in hexadecimal) + option dhcp-parameter-request-list = concat(option dhcp-parameter-request-list,d0,d1,d2,d3); + } + option pxelinux.reboottime 30; #if $iface.hostname: option host-name "$iface.hostname"; #end if diff --git a/cobbler/kickstarts/default.ks b/cobbler/kickstarts/default.ks index 8210a78..e336d22 100644 --- a/cobbler/kickstarts/default.ks +++ b/cobbler/kickstarts/default.ks @@ -55,7 +55,11 @@ selinux --disabled skipx # System Timezone +#if $getVar('timezone', '') != "" +timezone --utc $timezone +#else timezone --utc US/Pacific +#end if # Install install @@ -80,11 +84,10 @@ $SNIPPET('pre_anamon') $SNIPPET('partition_disks') # Packages -# %packages --ignoremissing --nobase %packages --nobase @core iproute -chef-11.8.0-1.el6.x86_64 +chef ntp openssh-clients wget @@ -92,28 +95,21 @@ json-c libestr libgt liblogging -rsyslog-7.6.3-1.el6.x86_64 +rsyslog %post --log=/var/log/post_install.log -#if $getVar('passwd', '') != "" - #set $passwd = $passwd.strip() -/usr/sbin/useradd -p '$passwd' $user -#end if - $SNIPPET('post_install_network_config') cat << EOF > /etc/yum.conf $SNIPPET('yum.conf') EOF -chkconfig ntpd on +$SNIPPET('ssh') +$SNIPPET('ntp') + chkconfig iptables off chkconfig ip6tables off -cat << EOF > /etc/ntp.conf -$SNIPPET('ntp.conf') -EOF - cat << EOF > /etc/security/limits.conf $SNIPPET('limits.conf') EOF @@ -124,13 +120,7 @@ EOF sysctl -p -## $yum_repo_stanza -## $yum_config_stanza - $SNIPPET($tool) -# rm -rf /etc/yum.repos.d/CentOS-Base.repo - - $SNIPPET('post_anamon') $SNIPPET('kickstart_done') diff --git a/cobbler/snippets/chef b/cobbler/snippets/chef index 8715992..892b66d 100644 --- a/cobbler/snippets/chef +++ b/cobbler/snippets/chef @@ -28,16 +28,22 @@ service rsyslog restart cat << EOF > /etc/chef/firstrun.sh #raw #!/bin/bash +touch /tmp/chef.log while true; do - pgrep chef-client + echo "firstrun chef-client on `date`" &>> /tmp/chef.log + clients=\$(pgrep chef-client) if [ "\$?" == "0" ]; then - exit 1 - fi - chef-client -L /var/log/chef-client.log &> /tmp/chef.log - if [ "\$?" != "0" ]; then - sleep 1m + echo "there are chef-clients '\$clients' running" &>> /tmp/chef.log + sleep 1m else - break + chef-client -L /var/log/chef-client.log &>> /tmp/chef.log + if [ "\$?" != "0" ]; then + echo "chef-client run failed" &>> /tmp/chef.log + sleep 1m + else + echo "chef-client run success" &>> /tmp/chef.log + break + fi fi done #end raw @@ -46,32 +52,31 @@ EOF cat << EOF > /etc/chef/rerun.sh #raw #!/bin/bash -pgrep chef-client +echo "rerun chef-client on `date`" &>> /tmp/chef.log +clients=\$(pgrep chef-client) if [ "\$?" == "0" ]; then - exit 1 + echo "there are chef-clients '\$clients' running" &>> /tmp/chef.log + exit 1 +fi +chef-client &>> /tmp/chef.log +if [ "\$?" != "0" ]; then + echo "chef-client run failed" &>> /tmp/chef.log +else + echo "chef-client run success" &>> /tmp/chef.log fi -chef-client &> /tmp/chef.log #end raw EOF +chmod +x /etc/chef/firstrun.sh +chmod +x /etc/chef/rerun.sh + ## A self-destruct service to boot chef client and register cron job cat << EOF > /etc/init.d/chef #!/bin/bash # chkconfig: 2345 95 20 # description: Description of the script # processname: chef-agent -#if $getVar('ntp_server', '') != "" -echo "old date is: \`date\`" 2>&1 > /tmp/ntp.log -echo "path: \$PATH" 2>&1 >> /tmp/ntp.log -/sbin/service ntpd stop 2>&1 >> /tmp/ntp.log -/usr/sbin/ntpdate $server 2>&1 >> /tmp/ntp.log -/sbin/service ntpd start 2>&1 >> /tmp/ntp.log -echo "new date is: \`date\`" 2>&1 >> /tmp/ntp.log -#end if - -chmod +x /etc/chef/firstrun.sh -chmod +x /etc/chef/rerun.sh -/etc/chef/firstrun.sh & +/etc/chef/firstrun.sh crontab -l > mycron echo "*/30 * * * * /etc/chef/rerun.sh" >> mycron @@ -81,6 +86,5 @@ chkconfig chef off mv /etc/init.d/chef /tmp/chef EOF - chmod +x /etc/init.d/chef chkconfig --level 2345 chef on diff --git a/cobbler/snippets/ntp b/cobbler/snippets/ntp new file mode 100644 index 0000000..a572d8f --- /dev/null +++ b/cobbler/snippets/ntp @@ -0,0 +1,14 @@ +chkconfig ntpd on + +cat << EOF > /etc/ntp.conf +$SNIPPET('ntp.conf') +EOF + +#if $getVar('ntp_server', '') != "" +echo "old date is: \`date\`" 2>&1 > /tmp/ntp.log +echo "path: \$PATH" 2>&1 >> /tmp/ntp.log +/sbin/service ntpd stop 2>&1 >> /tmp/ntp.log +/usr/sbin/ntpdate $ntp_server 2>&1 >> /tmp/ntp.log +/sbin/service ntpd start 2>&1 >> /tmp/ntp.log +echo "new date is: \`date\`" 2>&1 >> /tmp/ntp.log +#end if diff --git a/cobbler/snippets/ssh b/cobbler/snippets/ssh new file mode 100644 index 0000000..8af88e2 --- /dev/null +++ b/cobbler/snippets/ssh @@ -0,0 +1,6 @@ +mkdir -p /root/.ssh +chmod 700 -R /root/.ssh +cat << EOL >> /root/.ssh/authorized_keys +$SNIPPET('id_rsa.pub') +EOL +chmod 600 /root/.ssh/authorized_keys