Download paper - AsiaBSDCon

Transcript
imac::
"This is $(sys.uqhost)";
which will output
R: imac14 is an old mac
R: This is imac14
There is no space to discuss CFEngine in detail
and a few very simple and perhaps slightly contrived
examples should suffice.
#
# $Id$ left out
#
bundle common macs {
classes:
"imacs" expression => "darwin";
}
bundle agent imac_files {
vars:
"master_location" string => \
"/var/cfengine/masterfiles/osx";
"policyhost" string => "cfengine.snow.nl";
files:
imacs::
"/etc/profile"
comment => "ensure that shell history is \
timestamped",
edit_line => AppendIfNoLine(’export \
HISTTIMEFORMAT="%F %T> "’);
imacs::
"/Library/LaunchDaemons/nl.snow.cfexecd.plist",
comment => "LaunchDaemon to start cf-execd \
at boot",
perms => mog("u+rw,og+r","root","wheel"),
copy_from =>
secure_cp("$(master_location)/nl.snow.\
cfexecd.plist", "$(policyhost)");
}
<string>/opt/local/sbin/cf-execd</string>
<string>-F</string>
</array>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
Files which are routinely copied (but only if necessary) include:
admindotprofile
auto_master
cupsd.conf
loginscript.sh
nl.snow.cfexecd.plist
nl.snow.cffailsafe.plist
nl.snow.failsafe.plist
nl.snow.swupdate.plist
nl.snow.loginscript.plist
sudoers
swupdate.sh
sysctl.conf
There is some trickery in the schdule for upates
nl.snow.swupdate.plist, One would not want all 35
iMacs to assault the update server at 17:00 every
Monday. CFEngine allows me to randomize day and
minute, however. This plist is only copied from the
server if it does not yet exist, and is only edited if
there is a zero to replace.
vars:
....
"run_minute" int => randomint(1,59);
"run_day" int => randomint(1,5);
....
"/Library/LaunchDaemons/nl.snow.swupdate.plist"
comment => "minute after 17:00 to start \
swupdate",
edit_line => my_replace( \
"<integer>0</integer>",
"<integer>$(run_minute)</integer>");
"/Library/LaunchDaemons/nl.snow.swupdate.plist"
comment => "day of week to run swupdate",
edit_line => \
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST \
my_replace("<integer>1</integer>",
1.0//EN" \
"<integer>$(run_day)</integer>");
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
This is the plist:
<plist version="1.0">
<dict>
<key>Label</key>
<string>nl.snow.cfexecd</string>
<key>ProgramArguments</key>
<array>
A copy action in CFEngine can be made dependent
upon another action; it is, for instance, pointless
to try and copy an authorized_keys unless the
.ssh directory exists.
195