CFengine 3 Tutorial -- Part 2 -- Building Software and SMF Manifests / Scripts

** CFEngine and dependencies Building OpenSSL **

$ echo PATH
/var/tmp/openssl-1.0.0 $ ./Configure solaris-x86-gcc shared
--prefix=/usr/local/ssl --openssldir=/usr/local/ssl
/var/tmp/openssl-1.0.0 $ gmake
/var/tmp/openssl-1.0.0 $ gmake install

Building PCRE

/var/tmp/pcre-8.02 $ echo $LDFLAGS
-L/usr/sfw/lib -L/usr/sfw/lib
/var/tmp/pcre-8.02 $ ./configure --disable-cpp CFLAGS="-g -O3" CC=gcc
--enable-utf8 --enable-unicode-properties
/var/tmp/pcre-8.02 $ gmake
/var/tmp/pcre-8.02 $ sudo gmake install

Building CFEngine

Note: I modify the Makefile to statically compile in the BerkeleyDB, OpenSSL, and libpcre libraries into the CFEngine binaries. I also modify the reference for pthread to pthreads for Solaris. These adjustments to the Makefile are dependant on how you built the software above. Caveat emptor

/var/tmp/cfengine-3.0.4 $ export
/var/tmp/cfengine-3.0.4 $ export CC=/usr/sfw/bin/gcc
/var/tmp/cfengine-3.0.4 $ ./configure --prefix=/var/cfengine
--with-openssl=/usr/local/ssl --without-sql
--with-berkeleydb=/usr/local/BerkeleyDB/4.4 --enable-static
/var/tmp/cfengine-3.0.4 $ cd src
/var/tmp/cfengine-3.0.4/src $ perl -p -i.sav -e
"s:-ldb:/usr/local/BerkeleyDB/4.4/lib/libdb.a:" Makefile
/var/tmp/cfengine-3.0.4/src $ perl -p -i.sav -e
"s:-lcrypto:/usr/local/ssl/lib/libcrypto.a:" Makefile
/var/tmp/cfengine-3.0.4/src $ perl -p -i.sav -e
"s:-lpcre:/usr/local/lib/libpcre.a:" Makefile
/var/tmp/cfengine-3.0.4/src $ perl -p -i.sav -e
"s:-pthread:-pthreads:" Makefile
/var/tmp/cfengine-3.0.4/src $ cd ..
/var/tmp/cfengine-3.0.4 $ gmake
/var/tmp/cfengine-3.0.4 $ gmake install

Subversion and dependencies. Building apr

/var/tmp $ bunzip2 apr-1.4.2.tar.bz2
/var/tmp $ tar -xf apr-1.4.2.tar
/var/tmp $ cd apr-1.4.2
/var/tmp/apr-1.4.2 $ ./configure --prefix=/usr/local/apr
/var/tmp/apr-1.4.2 $ gmake
/var/tmp/apr-1.4.2 $ sudo gmake install

Building apr-util

/var/tmp $ bunzip2 apr-util-1.3.9.tar.bz2
/var/tmp $ tar -xf apr-util-1.3.9.tar
/var/tmp $ cd apr-util-1.3.9
/var/tmp/apr-util-1.3.9 $ ./configure --with-apr=/usr/local/apr
/var/tmp/apr-util-1.3.9 $ gmake
/var/tmp/apr-util-1.3.9 $ sudo gmake install

Building sqlite

/var/tmp $ tar -xf sqlite-amalgamation-
/var/tmp/sqlite- $ ./configure
/var/tmp/sqlite- $ gmake
/var/tmp/sqlite- $ gmake install

Building Subversion

/var/tmp $ tar -xf subversion-1.6.12.tar
/var/tmp/subversion-1.6.12 $ echo $LD_LIBRARY_PATH
/var/tmp/subversion-1.6.12 $ ./configure
--with-apr-util=/usr/local/apr --with-apr=/usr/local/apr
--without-berkeley-db --with-sqlite=/usr/local
/var/tmp/subversion-1.6.12 $ gmake
/var/tmp/subversion-1.6.12 $ gmake install

SMF Manifests / Scripts

I’ve created SMF manifests for cf-execd, cf-monitord, and cf-serverd. Clients should run cf-monitord and cf-execd. Master Policy Servers should run all three daemons. The SMF manifests / scripts for all 3 daemons are exactly the same, substitute the names of the daemons / descriptions. This is Solaris 10 specific.

$ ` svcs -a | grep cfengine`   
online Jun_30 svc:/application/cfengine/cf-serverd:default
online Jun_30 svc:/application/cfengine/cf-monitord:default
online Jun_30 svc:/application/cfengine/cf-execd:default

$ ` svccfg export cf-serverd`   
<?xml version='1.0'?>
<!DOCTYPE service_bundle SYSTEM
<service_bundle type='manifest' name='export'>
<service name='application/cfengine/cf-serverd' type='service'
<create_default_instance enabled='true'/>
<exec_method name='start' type='method'
exec='/var/cfengine/etc/ %m' timeout_seconds='60'>
<method_credential user='root'/>
<exec_method name='restart' type='method'
exec='/var/cfengine/etc/ %m' timeout_seconds='60'>
<method_credential user='root'/>
<exec_method name='stop' type='method'
exec='/var/cfengine/etc/ %m' timeout_seconds='60'>
<method_credential user='root'/>
<property_group name='startd' type='framework'>
<propval name='duration' type='astring' value='contract'/>
<loctext xml:lang='C'>Cfengine server process</loctext>
<doc_link name='Further information'

$ ` cat /var/cfengine/etc/`   


case "$1" in
echo "Starting cf-serverd"

echo "Stopping cf-serverd"
kill -15 `cat /var/cfengine/`

$ `0 stop`   
sleep 1
$ `0 start`   

echo "Usage: $N {start|stop|restart|force-reload}" >&2
exit 1
exit 0
This article was posted by Matty on 2010-07-02 12:06:00 -0400 EDT