lecture
in color
/var (why do you think it's called that?)
/var.
make and rpm actually do.
documentation: do it by hand.
scripting: do same thing automatically.
file abstraction: determine what is done to files by scripts,
assure that automatically.
service abstraction: describe services in terms of the assurances
one must have in order to provide them, e.g., www.
rdist: the remote distribution utility.
+---------------+ distribution +----------------+
| | ------------> | |
| master server | requests | client machine |
| | | |
| /etc/motd | status | /etc/motd |
+---------------+ <----------- +----------------+
reports
Distfile (patterned after Makefile):
#[key][source] -> [ hosts ]
motd: /admin/rdist/master/etc/motd -> ( presto apex forte )
install /etc/motd; # directives must start with TAB
#[tab][command][destination]
/admin/rdist/master/etc/motd - local master copy of file.
/etc/motd - remote destination for master.
presto, apex, forte - hosts upon which to place the file.
MACRO=value: set a macro
install /etc/motd: put the file in question into /etc/motd
notify couch@eecs.tufts.edu: mail a report of actions to this person
except foo: omit copying files named foo if copying a directory.
special "/usr/lib/newaliases" : run a command (as root) on the remote
machine.
Distfile is
SUN= allegro presto apex forte
aliases: /etc/mail/aliases -> (${SUN})
install /etc/mail/aliases
special "/usr/sbin/newaliases"
notify couch@eecs.tufts.edu
rdist -m forte aliasesthen
rdist will do the following things. aliases is out of date.
/usr/sbin/newaliases.
rsh to the target host(Can fix this by customizing rdist using kerberos). root on the master host into
/root/.rhosts on every host. root on
the whole network!
rdist that don't talk
to one another very well!
rdist can't work in reverse.
root, rdist can walk on your changes unless
you keep master files 'in sync'.
rdist for many years.
rdist.
rdist with cfengine.
rdist didn't do what I wanted.
rdist.
Distfile
by what amounts to macro processing.
rdist on the generated Distfile.
_allegroshorthand for __allegro allegro: creates a one-machine category.
__sol2x allegro presto apex forte vitesseall solaris 2.x boxes (for some x=4,5,6,7)
__sol2x_no_allegro presto apex forte vitesseall of these except allegro, which must be treated specially.
# file keyword __sol2x_no_allegro/etc/mail/aliases aliases
# file keyword __sol2x/etc/motd motdOn every sol2x box, place this /etc/motd.
__sol2x_no_allegro/etc/netgroup netgroupLikewise on every sol2x box except allegro, put this /etc/netgroup.
Dist.make creates Distfile:
_allegro = ( allegro )
__sol2x = ( allegro presto apex forte vitesse )
__sol2x_no_allegro = ( presto apex forte vitesse )
motd: __sol2x/etc/motd -> ( ${__sol2x} )
install /etc/motd;
aliases: __sol2x_no_allegro/etc/mail/aliases -> ( ${__sol2x_no_allegro} )
install /etc/mail/aliases;
netgroup: __sol2x_no_allegro/etc/netgroup -> ( ${__sol2x_no_allegro} )
install /etc/netgroup;
rdist alone.
rdist configures whole network at once.
sol2x= allegro presto apex forte vitesseThese hosts run solaris 2.x for some x.
sol2x_tftp= prestoPresto supports the trivial file transfer protocol.
sol2x_no_tftp= $sol2x - $sol2x_tftpThe other machines don't.
#cat master file target host list (with additions and deletions) auto etc/auto_master /etc/auto_master $sol26_nocache $sol27 - largoIn category auto, distribute Master/etc/auto_master as /etc/auto_master on all solaris 2.6 machines without cache space and all solaris 2.7 machines except for largo.
inetd etc/inet/inetd.conf+2.5 /etc/inet/inetd.conf $sol25 - allegro presto agonyIn category inetd, distribute Master/etc/inet/inetd.conf+2.5 as /etc/inet/inetd.conf on all solaris 2.5 machines except for allegro, presto, and agony.
pings hosts to figure out whether they're up, then calls
limited copies of rdist. PROTOTYPES are files that we plan to rdist.
ARCHIVES are numbered 0000-9999 and hold revisions of prototypes.
(as close as I ever got to a network version of CVS)
MASTERS are seperate working files which are copied to prototypes
when it's time to make changes.
SLAVES are files on remote hosts that rdist updates.
(hand-edit) : (sent)==rdist=>(remote)
MASTERS===m2p===>PROTOS<---s2p---SLAVES
| : | ^ : |
| : -p2a | | -a2p : |
| : V | : |
+------m2a-->ARCHIVES<--s2a-----+
: (0000-9999) :
: :
where : denotes possible filesystem boundaries, (PROTOS and
ARCHIVES are always stored in the same filesystem).
rdist works poorly.
/etc/passwd
/etc/services
control:
netmask = ( 255.255.255.0 )
what's our network config?
domain = ( eecs.tufts.edu )
what's our network name?
moduledirectory = ( /cf/modules )
where are extensions?
sysadm = ( couch@eecs.tufts.edu )
who should know about changes?
Repository = ( /var/local/cfengine/backup )
where are backup files kept?
AddInstallable = ( has_local_usr )
what are modules?
actionsequence = (
module:has_local_usr
directories
copy
links
shellcommands
processes
tidy
)
what should I do for each machine?
groups:
server = ( allegro presto apex forte agony largo conmoto conbrio andante
)
These machines are servers
# real-time tests of machine state
ssh_keygen = ( "/bin/test -f /etc/ssh_host_key" )
ssh2_keygen = ( "/bin/test -f /etc/ssh2/hostkey" )
cshpeople = ( "/bin/test -f /etc/csh.people" )
Each one of these tests whether a particular file exists.
editfiles:
solaris::
{ /etc/inet/hosts
AppendIfNoSuchLine "130.64.23.33 largo mailhost loghost timehost"
}
solaris.jumpstart::
conjunction: solaris AND jumpstart
{ /etc/defaultdomain
AppendIfNoSuchLine "eecs.tufts.edu"
}
directories:
# needed for proper function of sendmail
/etc o=root m=go-w
/etc/mail o=root m=go-w
/usr o=root m=go-w
/var o=root m=go-w
/var/spool o=root m=go-w
/var/spool/mqueue o=root m=go-w
These change the owner and protection of all these directories as noted.
largo::
Only on largo:
/export/5/loc o=root g=staff m=2755
/export/6/loc o=root g=staff m=2755
/export/7/loc o=root g=staff m=2755
fix protections on exported filesystems.
copy:
# source file target location master copy check type
solaris::
/admin/cf/.rhosts dest=/.rhosts server=largo type=sum
solaris.!agony.!largo::
/admin/cf/etc/bootparams dest=/etc/bootparams server=largo type=sum
links:
solaris::
/etc/sendmail.cf ->! mail/sendmail.cf
/etc/csh.cshrc ->! ./.cshrc
/etc/csh.login ->! ./.login
/etc/csh.logout ->! ./.logout
/etc/rc2.d/S95cfd ->! ../init.d/cfd
/etc/rc2.d/K95cfd ->! ../init.d/cfd
/etc/motd ->! /var/mail/Motd
These links made for all solaris boxes.
solaris.has_ssh2::
/etc/rc2.d/S95ssh2 ->! ../init.d/ssh2
/etc/rc2.d/K95ssh2 ->! ../init.d/ssh2
These links made for all boxes serving ssh2.
shellcommands:
solaris.Saturday.Hr00::
Every saturday, on Solaris machines, if it's midnight(!)
`/usr/bin/catman -M /usr/openwin/share/man`
`/usr/bin/catman -M /usr/share/man`
`/usr/bin/catman -w`
build manual page indexes.
sunos_5_7.!largo.!sendmail_891::
If we're running sunos 5.7 (Solaris 7) and we're not largo,
and sendmail 8.9.1 isn't installed (as per above test)
`/loc/mail/sendmail-8.9.1/INSTALL`
install sendmail here!
`/bin/domainname eecs.tufts.edu`
Set our domain name.
`/bin/echo "eecs.tufts.edu" > /etc/defaultdomain`
Put into the default domain file.
links:
solaris.victim::
/etc/sendmail.cf ->! mail/sendmail.cf
/etc/services ->! inet/services
links:-solaris,victim,link('mail/sendmail.cf','/etc/sendmail.cf').
links:-solaris,victim,link('inet/services','/etc/services').
Literally:
editfiles:
ftp.solaris::
{ /etc/inet/inetd.conf
AppendIfNoSuchLine "ftp stream tcp nowait root /usr/sbin/in.ftpd in.ftpd"
}
editfiles:-
os(Os),
config_path('inetd.conf',Os,Path),
config_path('ftpd',Os,Ftpd),
file_base_name(Ftpd,FBase),
appendIfNoSuchLine(Path,
[ftp,stream,tcp,nowait,root,Ftpd,Fbase]).
Whoa there! What are the extra terms?
cfengine,rdist,make: all do this
pig(Login):- passwd(Login,_,_,_,_,Home,_), du(Home,Usage), Usage>20000.Literally, "a person is a pig if that person has more than 20000 bytes in her or his home."
?- pig(Login),
email(Login,
'you are a pig!',
'oink!'),
fail.
Literally, for every pig (caused by 'special' Prolog goal 'fail') email that pig a message (with subject 'oink!').
cfengine to handle dynamic policy enforcement.
lecture
in color