cluster:Cfengine/302
Contents |
Introduction
Common information
| |||
|
Cfengine is a relatively simple platform to implement the hard cluster configuration management problem. Cluster hosts are associated with autonomous agents and communication between them is based on the common configuration platform. There are some tasks which can be solved with cfengine:
To get things done cfengine uses the administrator-defined configuration templates (or configuration policies). From this view, the software itself is working as the configuration platform or "a configuration manager". Every host in the cluster with installed cfengine package is managed by the configuration manager. The management itself declared as a set of logically grouped policies, and each host implements a subset from the whole policies. The cfengine can work as a maintenance tool to setup a complete host or a set of software associated with the host. The policies to manage maintenance are grouped into tasks in the reference installation. Thus, there is site, os, app groups of tasks. The current set of cfengine policies can be found into the reference installation codebase repository. |
| ||
cf3 syntax
The syntax of Cfengine files is relatively simple and somewhat Perl like. However, Cfengine tends to be more sensitive to white space.
- Sections are contained withing brackets.
- Commas separate parts of the same action.
- Actions are ended with a semicolon.
- Body part lines end with semicolons.
- Variables are identified by $ and usually contained in brackets to separate them from surrounding text.
- Most user defined information is contained within double quotations.
- Comments begin with # or can be included in the promise so that Cfengine will print them during a run (comment => "My comment").
Directories and files
- script:/var/cfengine/promises.cf This is the main configuration file. The agent will automatically start with this file.
- script:/var/cfengine/update.cf This is a simplified file whose purpose is to ensure the agent is configured properly so that it can do its job.
- script:/var/cfengine/failsafe.cf This file is run by the agent if other files are missing or contain errors. This gives the agent the ability to recover itself from failure.
- script:/var/cfengine/cf-server.cf This file configures the Cfengine server. It can be named anything but choosing this name is logical.
- script:/var/cfengine/cf-execd.cf This file will configure the Cfengine executor. Like cfserver.cf this file could be named something else.
- script:/var/cfengine/cfbackup.cf This makes a local backup of Cfengine to ensure the agent can recover from serious data loss.
- script:/var/cfengine/crontabs.cf This manages host crontables.
- script:/var/cfengine/library.cf This contains a collection of reusable code similar to a subroutine library.
See also troubleshooting for this page.
cfengine v.3.0.4
Prepare
Strictly speaking, the cfengine software do not use a client-server model. It can be named as an agent-server model, where server is an agent, installed into the master host. The reference installation configuration are stored into the subversion (svn) repository of Karlsruhe Institute of Technology. Thus, some preparation steps include:
- download the dgiref.repo from
http://mirror.scc.kit.edu/downloads/yum.repo/sl-dgiref.repointo/etc/yum.repos.d/ - install
subversionto communicate with svn server
- Firewall configuration
Port 5308 should be open (how to open port in firewall).
administrator's script: prepare.sh
#!/bin/bash# prepare cfengine masterhost#-> start routine#arch=i386arch=x86_64wget -O /etc/yum.repos.d/sl-dgiref.repo http://mirror.scc.kit.edu/downloads/yum.repo/sl-dgiref.repo
yum -y install subversion db4 pcre.$arch gcc openssl
#<- end routine
Install
The following step is needed to install a cfengine agent (execute as root user):
| use yum or rpm to install cfengine masterhost from http://mirror.scc.kit.edu/downloads/
|
administrator's script: install.sh
#!/bin/bash# install cfengine masterhost#-> start routine#p_arch="el4.i386"p_arch="el5.x86_64"
rpm -ihv http://mirror.scc.kit.edu/downloads/rpms/cfengine/2010.2/cfengine-community-3.0.4-1.${p_arch}.rpm
#yum -y install cfengine-community-3.0.4-1#<- end routine
Configure
To configure the cfengine v.3 agent, the following steps should be done:
- download the
cf3.preconffrom codebase repository into cfengine directory/var/cfengine/ - change mode to executable and execute
/var/cfengine/cf3v.preconfbash script. - configure the site by changing the parameters in the
/var/cfengine/masterfiles/inputs/library/variables.cf - run
cf-agentto constrain cfengine master host configuration
administrator's script: configure.sh
#!/bin/bash# prepare cfengine masterhost#-> start routinewget -O /var/cfengine/cf3.preconf http://dgiref.d-grid.de/svn/dgiref/PROD/cf3/cf3.preconf
chmod +x /var/cfengine/cf3.preconf
sh /var/cfengine/cf3.preconf PROD
# or# cp -r host_which_has_cf3_configs:/var/cfengine/masterfiles /var/cfengine/# sh /var/cfengine/masterfiles/cf3-int.preconf# configure the /var/cfengine/masterfiles/inputs/library/variables.cf# run cf-agentcf-agent -K#<- end routine
Proceed
To run the agent use the cf-agent command.
administrator's script: proceed.sh
#!/bin/bash# prepare cfengine masterhost#-> start routine# run cf-agentcf-agent
#<- end routine
Initial test
Examine the output for the cf-agent or test the individual promise with cf-promise promise.name
administrator's script: test.sh
#!/bin/bash# prepare cfengine masterhost#-> start routine# Examine the output for the cf-agentcf-agent -vK#<- end routine
Update
Use yum update/remove to update or remove the package.
administrator's script: update.sh
#!/bin/bash# prepare cfengine masterhost#-> start routine# use yum to updateyum update cfengine-3.0.4# use yum to removeyum remove cfengine-3.0.4#<- end routine