xiaodongwang 4ca3b760e4 tune cobbler snippets to deploy large scale cluster
Change-Id: I886b333ca2ede1088acb5bab69e14a8fe8884376
2014-02-27 22:32:40 -08:00

92 lines
1.7 KiB
Plaintext

## Generate client.rb
mkdir -p /etc/chef
## Generate validation.pem
cat << EOL > /etc/chef/validation.pem
$SNIPPET('chef-validator.pem')
EOL
cat << EOL > /etc/chef/client.rb
$SNIPPET('client.rb')
EOL
## Generate first-boot.json
cat << EOL > /etc/chef/first-boot.json
$SNIPPET('first-boot.json')
EOL
## Register Server in Rsyslog
cat << EOL > /etc/rsyslog.d/chef.conf
$SNIPPET('rsyslogchef')
EOL
cat << EOL > /etc/rsyslog.conf
$SNIPPET('rsyslogconf')
EOL
service rsyslog restart
cat << EOF > /etc/chef/firstrun.sh
#raw
#!/bin/bash
while true; do
pgrep chef-client
if [ "\$?" == "0" ]; then
exit 1
fi
chef-client -j /etc/chef/first-boot.json -L /var/log/chef-client.log &> /tmp/chef.log
if [ "\$?" != "0" ]; then
sleep 1m
else
break
fi
done
#end raw
EOF
cat << EOF > /etc/chef/rerun.sh
#raw
#!/bin/bash
pgrep chef-client
if [ "\$?" == "0" ]; then
exit 1
fi
chef-client &> /tmp/chef.log
#end raw
EOF
## 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 &
crontab -l > mycron
echo "*/30 * * * * /etc/chef/rerun.sh" >> mycron
crontab mycron
rm mycron
chkconfig chef off
mv /etc/init.d/chef /tmp/chef
EOF
chmod +x /etc/init.d/chef
chkconfig --level 2345 chef on