Created
October 10, 2012 09:12
-
-
Save sgirones/3864276 to your computer and use it in GitHub Desktop.
Prepate an Ubuntu template for Abiquo Chef
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Prepare config | |
cat > /etc/init/abiquo-chef-agent.conf << EOF | |
# chef-client - Chef Configuration Management Client | |
# | |
# Chef Client provides the Chef configuration management daemon | |
description "Abiquo Chef Agent" | |
start on (local-filesystems and net-device-up IFACE=eth0) | |
stop on runlevel [!2345] | |
pre-start script | |
test -x /usr/local/bin/abiquo-chef-run || { stop; exit 0; } | |
export RUBYOPT="-d" | |
end script | |
console output | |
script | |
apt-get update | |
service ntp stop | |
/usr/sbin/ntpdate pool.ntp.org | |
service ntp start | |
/usr/local/bin/abiquo-chef-run | |
end script | |
EOF | |
cat > /etc/dhcp/dhclient.conf << EOF | |
option rfc3442-classless-static-routes code 121 = array of unsigned integer 8; | |
send host-name "<hostname>"; | |
request subnet-mask, broadcast-address, time-offset, routers, | |
domain-name, domain-name-servers, domain-search, host-name, | |
netbios-name-servers, netbios-scope, interface-mtu, | |
rfc3442-classless-static-routes, ntp-servers, vendor-encapsulated-options; | |
EOF | |
# Install needed packages | |
apt-get update -y | |
apt-get install -y openssh-server ubuntu-minimal rubygems ruby ntp wget ruby-dev build-essential libxml2-dev libxslt1-dev psmisc | |
gem install abiquo-chef-agent | |
# Clean packages | |
apt-get remove -fy --purge build-essential gcc make libxml2-dev libxslt-dev ruby-dev perl perl-modules apache2.2-common apache2-utils apache2.2-bin | |
apt-get autoremove --purge -y | |
apt-get clean | |
mkdir /var/lib/dhcp3 | |
# Clean env | |
rm -rf /etc/chef | |
rm -f /var/log/abiquo-chef-run.log | |
rm -f /var/lib/dhcp3/* | |
rm -f /var/lib/dhcp/* | |
rm -f /var/log/chef-client.log | |
rm -f /var/log/abiquo-chef-agent.log | |
> ~/.bash_history | |
> /var/log/dmesg | |
> /var/log/syslog | |
> /var/log/auth.log | |
pkill -9 -f chef-client | |
echo nameserver 8.8.8.8 > /etc/resolv.conf | |
echo ubuntu-abiquo-chef > /etc/hostname | |
rm -rf /var/cache/apt/archives/* | |
rm /var/log/*.gz | |
> /var/log/syslog | |
> /var/log/dmesg | |
> /var/log/kern.log | |
> /var/log/boot.log | |
> /var/log/dpkg.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment