Tips, Tricks and Notes

From Cfwiki

Jump to: navigation, search

Here you can find various notes about using cfengine in the real world.

Contents

General Techniques

Executable Configuration Files : Using shebang to your advantage.

Common Traps and Pitfalls : About use of the any:: class.

Intro To Gdb : Using the GNU Debugger to troubleshoot cfengine crashes.

Using Cfengine with CVS: storing the policy files in a revision control system.

Importing Examples : Using import and classes to share common configuration data.

Co-operating with Vendor initscripts : Ensuring that the processes you start and stop now behave correctly after the next reboot.

Singlecopy Nirvana : A clean way to do hierarchical "most-specific" copies.

Autodefine Bliss : Using autodefine to simplify reactions to copies.

Specific Use Cases

Linking actions with define: One of the most frequently-asked questions: How do I restart a service if its config changes as a result of a copy action?

SMF for Solaris 10: SMF manifest for cfengine on Solaris 10

Solaris Auditing and CFEngine: A tip on how to use cfengine in an audited environment.

Copy failover example: This is an example of seeing a failover in action.

Universal SSHD restart: This is an example of a full proof way to restart SSHD, regardless of packaging or platform.

Multiple Domains : A code snippet that explains how to use multiple domains.

Alternate Split Character : A code snippet that shows how to use a ':' inside a variable.

Installing yum with Cfengine : Shows installing yum from cfengine.

Editfiles Examples : Editfiles in a reliable manner.

Managing Blocks of Code with Editfiles : Maintain a block of code in a file, instead of an entire file.

Define classes using lsb release: How to use lsb variables as classes (defined dynamically)

Kill processes older than a specified amount of time : How to kill processes that have been running for a certain amount of time.

Check for stray users in /etc/group : Check for users listed in /etc/group that don't have a corresponding /etc/passwd entry

How to use hostnames with hyphens as classes : The underscore is your friend.

Behavioral Quirks and Workarounds

Imported Classes Have Limited Scope : Classes you define in imported files can't be used by the including parent

Hung Shell Command : A tip for fixing shellcommands that hang and never exit.

Shellcomands and the Owner Attribute : A code snippet that explains the owner attribute with inside shellcomands.

Multiple Control Sections : A code snippet that shows how multiple control sections work in a single file.

Access Denied : How to deal with "Access Denied" errors.

Class In Action Sequence : A code snippet that illustrates what happens when you use defines in the actionsequence.

StrCmp and RegCmp Pitfall: If you leave a space (" ") after the comma (,) it will evaluate the space (" ") as part of the expression.

Excluding Pathname Patterns in Copy: How to exclude copying files that match a pattern in their pathname (not just their filename); very useful for excluding .svn directories.

Cfservd Confusion: What is the interaction between cfservd, cfagent, and cfrun? Why doesn't my cfrun succeed?

Define Class by shell command with no starting slash: something like "myclass = ( '${path}/script' )" will fail because cfagent does not recognize it as a shell command!

Adding Code Snippets

When adding a cfengine Code Snippet to this page, please follow these conventions:

  • Give a description of the code snippet, followed by a example that a person could run with, for example:
 /var/cfengine/bin/cfagent -v -f ./snippet.conf
  • Take sections of output that pertain exactly to the code in question, and follow up with any more information about the code snippet that came from the output. (See Shellcommands and the Owner Attribute for an example.)
  • Name your pages with Full Page Titles, not with StudlyCapTitles, and please don't prefix your page titles with a common prefix (at least until we decide on a convention for that!)
  • Check your snippets for syntax errors:
cfagent --parse-only -f ./snippet.conf

Quick Links

Main Page - Overview - Glossary - Links - Articles - Wishlist - Tips, Tricks and Notes - Current Events
Interview - Support - Books - Help - Mascot - Motto - All Pages - Statistics - Cfwiki.org Changes

Personal tools