[CentOS] Squid +Yum = apt-cacher?

Fri May 25 15:23:38 UTC 2007
Matt Shields <mattboston at gmail.com>

On 5/25/07, Les Mikesell <lesmikesell at gmail.com> wrote:
> But that's a per-box per-repo specific change, with per-distro, per-repo
> variations for the end users to figure out for themselves. And then it
> won't fail over at all if the url you pick goes away.  Aren't computers
> supposed to work for you instead of the other way around?

Sigh!!!!! Why do people insist on doing things the hard way and insist
on doing it over and over.  As explained in the previous post of mine,
I have a local repo, I use pxeboot with a kickstart file.  There is
one kickstart per distro, per version.  The kickstart files are
identicle except for the URL to the distro/arch specific repo and
minor diffs for arch specific stuff.  In the %post section of
kickstart I have a ton of stuff automated and one of the things is
modifiying the location of my repo in
/etc/yum.repos.d/CentOS-Base.repo file.  If people have a ton of RPM
based servers(RHEL, CentOS, WBEL, Fedora, etc) that they manage and
regularly image/reimage it makes sense to check out how great
kickstart and pxebooting can benefit you.  We have over 200+ servers,
50+ VMs and growing and it makes life so much simpler.  I can image up
a server in about 10 minutes and it will be totally customized the way
I want it with all the latest updates. We've also added into our repo
the ability to pxeboot install VMWare ESX and Windows 2k3.  I haven't
checked it out yet, but I've heard Cobbler takes this one step further
and makes it very very simple.  Not sure if Cobbler will handle the
VMWare and Windows though.  Little bit of time upfront will save you a
ton of time later.  Here's an example totally custom kickstart file
below, search the net for pxeboot or pxeinstall and kickstart, it will
save you so much time.

-matt

[root at install kickstart]# cat centos-4.4-i386.ks.cfg
install
text
reboot
url --url http://install.mydomain.com/install/centos/4.4/os/i386/
lang en_US.UTF-8
langsupport --default=en_US.UTF-8 en_US.UTF-8
keyboard us
#xconfig --card "ATI Radeon 7000" --videoram 8192 --hsync 31.5-37.9
--vsync 50-70 --resolution 800x600 --depth 16  --defaultdesktop gnome
network --device eth0 --bootproto dhcp
rootpw --iscrypted mypw
firewall --disabled
selinux --disabled
authconfig --enableshadow --enablemd5
timezone America/New_York
bootloader --location=mbr
autopart
zerombr yes #windows mbr removal
clearpart --all --drives=sda #s/linux/all (windows)
part /boot --fstype ext3 --size=200 --asprimary
part swap --size=1000 --grow --maxsize=2000 --ondisk=sda
part pv.01 --size=1024 --grow --ondisk=sda
volgroup vg.01 pv.01
logvol / --fstype ext3 --size=1024 --vgname=vg.01 --name=rootvol --grow
logvol /opt --fstype ext3 --size=2048 --vgname=vg.01 --name=junkvol
#part / --fstype ext3 --size=1024 --grow --ondisk=sda
%packages
@ compat-arch-development
@ editors
@ emacs
@ mysql
@ admin-tools
@ development-tools
@ text-internet
@ compat-arch-support
lvm2
kernel-smp-devel
kernel-smp
e2fsprogs
screen
sysstat
net-snmp

%post
CMDLINE="`cat /proc/cmdline`"
HOSTNAME=`expr "$CMDLINE" : '.*hostname=\([^ ]*\).*'` #grab hostname
from pxeboot
export CMDLINE HOSTNAME
set > /root/ks.env
if [ "$HOSTNAME" ]
then
        hostname $HOSTNAME
fi

# use these next few lines if you have a RHN account
#rpm --import /usr/share/rhn/RPM-GPG-KEY
#rhnreg_ks --force --profilename
${HOSTNAME:-"tmp-host-name.mydomain.com"} --username myrhnuser
--password myrhnpasswd
#up2date --nox --force --update -v

# use these lines if you're using CentOS
wget -O /etc/yum.repos.d/CentOS-Base.repo
http://install.mydomain.com/install/kickstart/CentOS-Base.repo #get my
custom CentOS-Base.repo file
rpm --import http://install.mydomain.com/install/CentOS/RPM-GPG-KEY-CentOS-4
yum -y update #why not update to the latest packages right after install

# look I'm setting custom resolv.conf info
cat > /etc/resolv.conf <<EOF
domain mydomain.com
nameserver x.x.x.x
nameserver x.x.x.x
EOF

chkconfig ntpd on
chkconfig cups off
chkconfig cups-config-daemon off
chkconfig sendmail off

# set machine to boot at init3
perl -i -pe 's/id\:5\:initdefault\:/id\:3\:initdefault\:/g' /etc/inittab

ed /etc/sysconfig/i18n <<EOF
%s/en_US\.UTF-8/en_US/g
w
EOF

ed /etc/mail/sendmail.mc <<DONE
%s/.*MASQUERADE_AS.*/MASQUERADE_AS(\`mydomain.com\')dnl/
w
q
DONE

make -C /etc/mail

umount /opt
lvremove -f /dev/vg.01/junkvol
ed /etc/fstab <<EOF
%s/\/dev\/vg.01\/junkvol/\#\/dev\/vg.01\/junkvol/g
w
EOF

makewhatis

cat >> /etc/bashrc <<EOF
alias dir='ls -lasF'
EOF
cat >> /etc/profile <<EOF

EDITOR=vi
SVN_EDITOR=vi
export EDITOR SVN_EDITOR
EOF

# install a custom snmpd.conf
wget -O /etc/snmp/snmpd.conf http://install.mydomain.com/install/snmp/snmpd.conf
chkconfig snmpd on

# create a directory for software installs
mkdir /opt/install