Network/SQL multi host Emerge for Gentoo

I have a lot of Gentoo hosts. Going to each one of them and running emerge xxxx what ever is really annoying.
Its also a waste of my time.  I set out to fix that.

Design goals are :-
1) Can query a SQL DB to find out what hosts need updating.
2) Can run against a single host or many hosts.
3) Can preform emerge sync, revdev- rebuld, emerge packages and tell me what needs uptating in etc.
4) Can run from a central host.
5) Can run from a crontab and generate a log file for me to inspect later.

Currently I can do this :-

./genhstutil.rb
Preform maintenance on mutiple Gentoo hosts over the network

Usage:
 [options] {host} or {package}
 where {package} is the name of a gentoo package atom
 where {host} is the dns name of a host
 where [options] are:
 --esync, -e: Run emerge sync on {host}
 --breif, -b: Get a one line package update summary on {host}
 --detail, -d: Get a detailed package update list on {host}
 --world, -w: Emerge world on {host}
 --system, -s: Emerge system on {host}
 --revdep, -r: Run revdep rebuild on {host}
 --ipkg, -i: Install {package} on a {host}
 --etcup, -t: Check a host for etc-updates
 --esync-all, -y: Run 'esync' on all Gentoo hosts
 --breif-all, -f: Run 'breif' on all Gentoo hosts
 --detail-all, -a: Run 'detail' on all Gentoo hosts
 --ipkg-all, -p: Install package on all Gentoo hosts
 --world-all, -o: Run emerge world on all Gentoo hosts
 --system-all, -m: Run emerge system on all Gentoo hosts
 --revdep-all, -v: Run revdep-rebuild on all Gentoo hosts
 --echall-all, -c: Check all Gentoo hosts for etc-updates
 --help, -h: Show this message

There a few things that need to be done before this code will work.
1) you need to have an user set up on each host, in my example I have called the use “maint” currently I use a password to access the hosts rather then ssh keys.
2) sudo to be installed anc configured like this :-

maint ALL = NOPASSWD: /usr/bin/emerge, /usr/bin/rsync, /usr/bin/revdep-rebuild, /usr/bin/find

3) A SQL database that can be accessed over the network, see the attached schema.

You will need to rename the files from .doc to to .rb and .sql as wordpress won’t allow me upload anything else.
Gentoo Host ruby script
Gentoo Host sql schema 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: