Wednesday 25 June 2014

The Puppet modules - Part 3 (EnterpriseDB)

Over the last year or so I have been working on a Puppet module to replicate PostgreSQL databases between servers. Whilst this is working sort of (trying to merge this with the open source PostgreSQL server is hard and I haven't even start to look at PE internal DB), I decided that a cleaner approach was needed where I could have full control.

Enter PostgresPlus (EnterpriseDB), this version is available commercially and had no modules in the forge to work with.

In starting this I began with creating a manifest that would install the server which was simple enough. When it came to adding in roles,users and databases I found that it was easiest to just merge in parts of the existing Puppetlabs PostgreSQL module. 

Once all of this was done it was time to move onto the replication.

Replication is done through using exported resources. These are similar to virtual resources in that you use @ and spaceships with three major differances.
  1. The class/function is exported with @@
  2. The class/function is substantiated with <<|  |>>
  3. Requires a PuppetDB to work
So now in addition to the usual PostgreSQL module functions we also have classes for master and target.
By attaching the master class to the server it will push back an exported resource to the PuppetDB with a tag.
When we add the target class to the target server it will pull out the exported resource from the PuppetDB and apply it on this node, creating the configuration files for replication to start working.

This will also allow for dynamic creation of target nodes with as many as is required, even with the master in full production.

No comments:

Post a Comment