Caching centos yum updates with apt-cacher-ng

1,608 views
Skip to first unread message

Darren Wurf

unread,
Oct 28, 2014, 2:08:20 AM10/28/14
to mlu...@googlegroups.com
Just thought I'd share this fun fact: if you use apt-cacher-ng to
cache your debian/ubuntu updates you can also use it for centos (and
presumably fedora)

Here's a one-liner I pieced together for my dev VMs:

# Configure a new CentOS VM to pull yum updates from Internode, via
the apt-cacher-ng proxy
## NOT FOR PRODUCTION - this mangles important system files and has
the potential to really f2k things up
cd /etc/yum.repos.d/ && sudo sed -i.bak -e 's/^mirrorlist *=
*/#mirrorlist = /' -e
's/#*baseurl=http:\/\/mirror.centos.org/baseurl=http:\/\/mirror.internode.on.net\/pub/'
*.repo && sudo sed -i 's/enabled=1/enabled=0/'
/etc/yum/pluginconf.d/fastestmirror.conf && sudo sed -i 's/proxy
*=.*/proxy=http:\/\/10.0.3.184:3142/' /etc/yum.conf; grep proxy
/etc/yum.conf || echo 'proxy=http://10.0.3.184:3142' | sudo tee -a
/etc/yum.conf

No changes required on the server side, the default apt-cacher-ng
config works fine. I pieced this together from these two links:

http://www.sotechdesign.com.au/how-to-cache-yum-repositories-on-centos-using-apt-cacher-ng-on-debian-or-ubuntu/
http://serverascode.com/2014/03/29/squid-cache-yum.html

For those who are interested, the config I use on my ubuntu machines:

$ cat /etc/apt/apt.conf.d/10aptcache
Acquire::http { Proxy "http://10.0.3.184:3142"; };
Acquire::https { Proxy "DIRECT"; };

Cheers,

--
Darren

Cameron

unread,
Oct 28, 2014, 11:36:16 AM10/28/14
to mlu...@googlegroups.com
... and some more additional fun facts for apt-cacher-ng for those who run arch linux and other variants:-

apt-cacher-ng can be installed on an arch server with this package from AUR: https://aur.archlinux.org/packages/apt-cacher-ng/

This AUR package has been pre-configured to allow caching to the following client distros:-
  • Arch Linux
  • Cygwin
  • Debian
  • Debian Volatile
  • Fedora
  • Fedora EPEL
  • Gentoo
  • Scientific Linux
  • Sourceforge
  • Ubuntu
Just be sure to put your favourite distro mirror at the top of the relevant configuration lists.

While I haven't tried this latest version of apt-cacher-ng in arch, I can confirm that an older version of it with some hand-crafted config files work flawlessly on a pentium 2 or a raspberry pi running arch linux.

Cam.

Timothy Rice

unread,
Oct 28, 2014, 4:42:44 PM10/28/14
to mlu...@googlegroups.com
> apt-cacher-ng can be installed on an arch server with this package from
> AUR: https://aur.archlinux.org/packages/apt-cacher-ng/

Thanks, this is interesting.

~ Tim

David Schoen

unread,
Oct 29, 2014, 6:17:58 PM10/29/14
to mlu...@googlegroups.com
For what it's worth, every now and then yum seems to throw some new
file type in that doesn't match the appropriate patterns in ACNG, you
can usually just coax the RegEx in the config in to doing what you
want again though, e.g
https://bugs.launchpad.net/ubuntu/+source/apt-cacher-ng/+bug/1006844

TLDR - if something breaks, 99% of the time you can fiddle with
VFilePattern to get it working again, regardless of what ACNG
"supports".

If you're moving around on a Debian laptop and want to have an ACNG
server remain in place on LANs you commonly use you may want to
configure it to fiddle with the apt proxy settings depending on which
LAN you've ended up on, I documented a hack on
https://help.ubuntu.com/community/Apt-Cacher-Server#A.22Roaming.22_mode_event-driven_solution
a while ago.


Cheers,
Dave
Reply all
Reply to author
Forward
0 new messages