Archive for the ‘perl’ Category

pre-9.5 PostgreSQL upsert

No Comments »

With the recent PostgreSQL 9.5 release, one of the exciting new features is “upsert” support, which is where you want to either update an existing row or insert a new one if it doesn’t already exist. If you’re still on an old version of PostgreSQL, however, you here’s how I’ve been getting that accomplished. This example uses the Perl DBI mechanism, but I think it’s readable enough that it’d be easy to convert to anything else with parametrized query preparation.
Read the rest of this entry Ľ


Using a database to configure CFEngine

No Comments »

I’m responsible for a pretty large CFEngine installation. ¬†CFEngine is designed to be pretty self-sufficient even when the network is unavailable, so it basically¬†works by keeping¬†its configuration local on each machine, and running from that local copy. ¬†This is mostly implemented using¬†a file-based configuration structure. ¬†There’s a main configuration file (promises.cf) which includes several additional configuration files. ¬†In pretty much every situation, one of the promises (the name for an individual policy item) or bundles of promises will ensure that the local config files are in sync with the configuration files¬†on the central master.

While it’s possible to use LDAP or define some variables on the central master, the main way configuration is done is by putting the policy into some files on the master and then allowing individual systems to copy those files down; the central master is basically just a fairly efficient file server.

Read the rest of this entry Ľ