- 'control' section controls behavior:
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 has_local_cache get_subnet )
what are modules?
actionsequence = (
module:has_local
module:get_subnet
directories
copy
links
shellcommands
processes
tidy
)
what should I do for each machine?
- 'groups' section defines machine groups
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" )
had_ssh2 = ( "/bin/test -f /etc/init.d/ssh2" )
had_ssh = ( "/bin/test -f /etc/init.d/ssh" )
ntpd = ( "/bin/test -f /etc/init.d/ntpd" )
sendmail_891 = ( "/bin/test -f /etc/mail/sendmail.cf-pre8.9.1" )
nisplus = ( "/bin/test -f /var/nis/NIS_COLD_START" )
cshpeople = ( "/bin/test -f /etc/csh.people" ) # dert 1999-09-05
Each one of these tests whether a particular file exists.
- 'editfiles': dynamic convergent editing of system files!
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': assert mode and owner of directories
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': copy files to specific places:
copy:
# source file target location master copy check type
solaris::
/admin/cf/.rhosts dest=/.rhosts server=largo type=sum
- 'links': make symbolic links if not present
links:
solaris::
/etc/sendmail.cf ->! mail/sendmail.cf
/loc1 ->! /loc
/loc2 ->! /loc
/loc3 ->! /loc
/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.(had_ssh|has_ssh).!had_ssh2.!has_ssh2::
$(a)/etc/rc2.d/S95ssh ->! ../init.d/ssh
$(a)/etc/rc2.d/K95ssh ->! ../init.d/ssh
These links made for all boxes serving ssh1 but not ssh2 (forte).
solaris.(had_ssh2|has_ssh2)::
$(a)/etc/rc2.d/S95ssh2 ->! ../init.d/ssh2
$(a)/etc/rc2.d/K95ssh2 ->! ../init.d/ssh2
These links made for all boxes serving ssh2.
- 'shellcommands': these are commands to execute in particular cases.
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!
solaris.!largo.!nisplus::
If we're running solaris and we're not largo, and don't have nisplus
installed, INSTALL IT!
`/bin/domainname eecs.tufts.edu`
Set our domain name.
`/bin/echo "eecs.tufts.edu" > /etc/defaultdomain`
Put into the default domain file.
`/usr/sbin/nisinit -c -H largo`
Run nisinit to bind us into eecs.tufts.edu!
- cfengine code:
links:
solaris.victim::
/etc/sendmail.cf ->! mail/sendmail.cf
/etc/services ->! inet/services
- translates into Prolog as:
links:-solaris,victim,link('mail/sendmail.cf','/etc/sendmail.cf').
links:-solaris,victim,link('inet/services','/etc/services').
Literally:
- If you're solaris,
- and you're a victim,
- then make sure the link exists.
- Similar translations for every kind of service:
editfiles:
ftp.solaris::
{ /etc/inet/inetd.conf
AppendIfNoSuchLine "ftp stream tcp nowait root /usr/sbin/in.ftpd in.ftpd"
}
- translates into Prolog as
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?
- os(Os): figure out operating system.
- config_path('inetd.conf',Os,Path): where's inetd.conf in this OS?
- config_path('ftpd',Os,Ftpd): where's ftpd in this OS?