Coder Social home page Coder Social logo

puppet-pgpool's Introduction

pgpool

Build Status

Table of Contents

  1. Overview
  2. Module Description - What the module does and why it is useful
  3. Setup - The basics of getting started with pgpool
  4. Usage - Configuration options and additional functionality
  5. Reference - An under-the-hood peek at what the module is doing and how
  6. Limitations - OS compatibility, etc.
  7. Development - Guide for contributing to the module.

Overview

This module can be used to manage the installation and configuration of pgpool.

Module Description

The module leverages augeas to manage the configuration file for pgpool. Additionally it allows you to manage the pool hba configuration file via the augeas pg_hba provider. You can also manage the pool_password file with the pool password resource provided by the module. The module does not manage the installation of the pgdg repository for installation of the latest version of pgpool. You can provide the package name to the pgpool module if you have built your own or would like to leverage a version that is shipped with your OS.

Setup

Setup Requirements

As part of using this module, you will need to have the following modules installed.

  • camptocamp/augeas
  • puppetlabs/stdlib
  • herculesteam/augeasproviders_core
  • herculesteam/augeasproviders_postgresql

Additionally there is a submode that references an external Augeas lense. If you want to check out this module, make sure to recursively fetch the module to get the augeas-pgpool submodule.

git clone --recursive https://github.com/mwhahaha/puppet-pgpool.git

Usage

Here is a sample configuration for a streaming replica master/slave setup and pgpool on the same node as the application.

# install the package and the service
class { 'pgpool': }

# setup our pgpool.conf
class { 'pgpool::config::connection': }
class { 'pgpool::config::healthcheck':
  health_check_period      => 5,
  health_check_timeout     => 10,
  health_check_user        => 'pgpool',
  health_check_password    => 'mypassword',
  health_check_max_retries => 1,
}
class { 'pgpool::config::loadbalance':
  load_balance_mode => 'on',
}
class { 'pgpool::config::logs':
  log_connections  => 'on',
  log_statement    => 'on',
  log_min_messages => 'info',
}
class { 'pgpool::config::masterslave':
  master_slave_mode     => 'on',
  master_slave_sub_mode => 'stream',
  sr_check_period       => 5,
  sr_check_user         => 'pgpool',
  sr_check_password     => 'mypassword',
  delay_threshold       => 1024000,
}
class { 'pgpool::config::pools':
  enable_pool_hba => 'on',
}
class { 'pgpool::config::replication':
  replication_mode => 'off',
}
class { 'pgpool::config::service':
  pid_file_name => '/var/run/pgpool-II-93/pgpool-II-93.pid',
  logdir        => '/tmp',
}
class { 'pgpool::config::ssl': }
class { 'pgpool::config::watchdog': }

# configure our backend systems
pgpool::config::backend { 'db-n01':
  id               => '0',
  hostname         => '10.0.0.4',
  port             => 5432,
  application_name => 'db-n01',
  data_directory   => '/var/lib/pgsql/9.3/data',
}
pgpool::config::backend { 'db-n02':
  id               => '1',
  hostname         => '10.0.0.5',
  port             => 5432,
  application_name => 'db-n02',
  data_directory   => '/var/lib/pgsql/9.3/data',
}

# configure our application user password access
pgpool::pool_passwd { 'my_app_user':
  password_hash => 'md5d6d70ecf643d4sec9ca6623fee1233ea',
}

# configure the pgpool hba configuration
pgpool::hba { 'my_app_user':
  type        => 'host',
  database    => 'my_db_name',
  user        => 'my_app_user',
  address     => '127.0.0.1/32',
  auth_method => 'md5',
}

Reference

Here is a list of all the available classes and resources for this module.

Classes:

  • pgpool
  • pgpool::config
  • pgpool::service
  • pgpool::package
  • pgpool::monitor
  • pgpool::config::watchdog
  • pgpool::config::pools
  • pgpool::config::loadbalance
  • pgpool::config::healthcheck
  • pgpool::config::other
  • pgpool::config::memorycache
  • pgpool::config::ssl
  • pgpool::config::logs
  • pgpool::config::replication
  • pgpool::config::masterslave
  • pgpool::config::connection
  • pgpool::config::heartbeat
  • pgpool::config::service
  • pgpool::config::failover

Resources:

  • pgpool::pool_passwd
  • pgpool::pcp
  • pgpool::hba
  • pgpool::config::backend
  • pgpool::config::val
  • pgpool::config::wdother

Limitations

This has only been tested on RedHat/CentOS 6. It might work on Debian/Ubuntu.

Development

Pull requests welcome.

Other resources

To use pgpool::monitor, the code for the pgpool-monitor package is available from pgpool-monitor.

puppet-pgpool's People

Contributors

antaflos avatar brummett avatar ctlajoie avatar michaeljmonte avatar mwhahaha avatar olifre avatar oscarsix avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

puppet-pgpool's Issues

Use of deprecated "lens_source" and "lens_test" in pgpool::config class

Hi,
You're using the camptocamp/augeas module, and pass it a deprecated "lens_source". According to the current version of that module, "lens_content" should be used -- the same applies for "test_source", which should be "test_content".
It's resulting in the following log-lines on my puppet master:

Jul 14 09:04:37 puppet puppet-master[1971]: (Scope(Augeas::Lens[pgpool])) Passing "lens_source" is deprecated; please use "lens_content"
Jul 14 09:04:37 puppet puppet-master[1971]: (Scope(Augeas::Lens[pgpool])) Passing "test_source" is deprecated; please use "test_content"
Jul 14 09:04:38 puppet puppet-master[1971]: Compiled catalog for pgpool.example.com in environment production in 0.65 seconds

I've tried to fix it myself, but didn't succeed because I'm not that proficient in Puppet's language yet. What I figured out, is that the trigger can be found at: https://github.com/mwhahaha/puppet-pgpool/blob/master/manifests/config.pp#L74

Dependency cycle when ensuring pgpool is absent

Hi,
I ran into the problem that pgpool can't be removed by puppet, by using:

class { pgpool:
    ensure => absent,
}

According to the output from the Puppet agent, this will lead to a circular dependency:

vagrant@pgpool:~$ sudo puppet agent --test
Info: Retrieving plugin
Info: Loading facts in /var/lib/puppet/lib/facter/nodejs_stable_version.rb
Info: Loading facts in /var/lib/puppet/lib/facter/iptables_version.rb
Info: Loading facts in /var/lib/puppet/lib/facter/nodejs_installed_version.rb
Info: Loading facts in /var/lib/puppet/lib/facter/nodejs_functions.rb
Info: Loading facts in /var/lib/puppet/lib/facter/nodejs_latest_version.rb
Info: Loading facts in /var/lib/puppet/lib/facter/ip6tables_version.rb
Info: Loading facts in /var/lib/puppet/lib/facter/concat_basedir.rb
Info: Loading facts in /var/lib/puppet/lib/facter/iptables_persistent_version.rb
Info: Loading facts in /var/lib/puppet/lib/facter/root_home.rb
Info: Loading facts in /var/lib/puppet/lib/facter/facter_dot_d.rb
Info: Loading facts in /var/lib/puppet/lib/facter/pe_version.rb
Info: Loading facts in /var/lib/puppet/lib/facter/puppet_vardir.rb
Info: Caching catalog for pgpool.example.com
Info: Applying configuration version '1436863675'
Error: Could not apply complete catalog: Found 1 dependency cycle:
(Augeas[rm pgpool.conf failback_command] => Service[pgpool] => Class[Pgpool::Service] => Class[Pgpool::Config] => File[/etc/default/pgpool2] => Service[pgpool])
Try the '--graph' option and opening the resulting '.dot' file in OmniGraffle or GraphViz

The graph look likes this:
cycles

Shouldn't use Git submodule for Augeas lens

We ran into this today. It seems R10k does not support deploying Git submodules (https://tickets.puppetlabs.com/browse/RK-30) so the pgpool.aug Augeas is missing after the module is installed.

This also seems to be a problem for the release on the Forge. The latest release, when downloaded as a tarball, doesn't contain the pgpool.aug Augeas lens but only an empty directory named augeas-pgpool:

 $ tree mwhahaha-pgpool-0.1.14/
mwhahaha-pgpool-0.1.14/
├── checksums.json
├── files
│   └── augeas-pgpool
├── LICENSE
├── manifests
│   ├── config
│   │   ├── backend.pp
...

Obviously this is suboptimal :)

I suggest either maintaining the Augeas lens directly within this module, or releasing a proper module containing only the lens and listing that module as a dependency, like you do with camptocamp/augeas, herculesteam/augeasproviders_core, herculesteam/augeasproviders_postgresql and so on.

The latter approach is described in https://docs.puppetlabs.com/guides/plugins_in_modules.html, but I would favour the former, letting the Augeas lens live within the pgpool module, and making use of Puppet's plugin sync. The path would look like this:

{modulepath}/pgpool/lib/augeas/lenses/pgpool.aug

Thoughts?

Can you update module to use pgpool version 4.0.3 ?

Last my question is "Update pgpool version 4 ?", so I receive your answer "I don't think we specify the version, so i guess it would depend on where you're pulling your pgpool from." Can you point me the way to update pgpool version 4 ? I use ubuntu bionic (18.04) as OS version, and when install module, it occurs some error.

Why only pgpool 9.3?

Hello,

I am using postgresql94 and I wanted to use the same pgpool release (9.4) but it seems that the version 9.3 is hardcoded in e.g. config/service.pp.

Could you please fix it and make possible to determine the release by the user?

The files with pgpool-II-93 are:

  • modules/pgpool/spec/classes/init_spec.rb
  • modules/pgpool/README.md
  • modules/pgpool/manifests/config/service.pp
  • modules/pgpool/manifests/init.pp

Thank you,
Kamil

File e.g. pool_hba.conf not properly updated

Hello,

I see that the when you execute a pgpool::hba class with some content it will create a file /etc/pgpool-II-94/pool_hba.conf which is proper behavior. After this I may have something like this in it:
host inapp postgres 127.0.0.1/32 md5
host postgres postgres 127.0.0.1/32 md5

Now, lets say that I remove from puppet's configuration a configuration which creates the second line. I assume that the file should be updated and have a structure:

host inapp postgres 127.0.0.1/32 md5

...but it does not have it. It looks like it is not updated "backward". Values are not removed?

Is it an issue in your module or I use it in a wrong way?

Thank you,
Kamil

Update Pgpool version 4 ?

after install module, pgpool version is 3.4.3.
I want to use pgpool version 4.0.3.
Can you upgrade puppet-pgpool version ?

puppet entreprise 3.3.2 and augeas lens

Hi,

Thanks a lot for this module !
This is not really an issue, but a tip for other puppet entreprise users.

It doen't work with puppet entreprise because the lense is not at the pe-puppet environment.

the error is like :

Warning: Augeas[set pgpool.conf listen_addresses](provider=augeas): Loading failed for one or more files, see debug for /augeas//error output

With debug mode we can find more usefull info:

Debug: Augeas[set pgpool.conf listen_addresses](provider=augeas): Opening augeas with root /, lens path /var/opt/lib/pe-puppet/lib/augeas/lenses, flags 64
Debug: Augeas[set pgpool.conf listen_addresses](provider=augeas): Augeas version 1.1.0 is installed
Warning: Augeas[set pgpool.conf listen_addresses](provider=augeas): Loading failed for one or more files, see debug for /augeas//error output
Debug: Augeas[set pgpool.conf listen_addresses](provider=augeas): /augeas/load/Xfm/error = Can not find lens Pgpool.lns
Debug: Augeas[set pgpool.conf listen_addresses](provider=augeas): Will attempt to save and only run if files changed
Debug: Augeas[set pgpool.conf listen_addresses](provider=augeas): sending command 'set' with params ["/files/etc/pgpool-II-94/pgpool.conf/listen_addresses", "localhost"]
Debug: Augeas[set pgpool.conf listen_addresses](provider=augeas): Closed the augeas connection

It needs to be in /opt/puppet/share/augeas/lenses/dist/ or /var/opt/lib/pe-puppet/lib/augeas/lenses

Just a

cp /usr/share/augeas/lenses/pgpool.aug /opt/puppet/share/augeas/lenses/dist/

and it works like a charm.

Mélanie

ensure absent has dependency loop

Off v0.1.8 we ran into a dependency loop when setting ensure => absent

To resolve it we pulled the exec out of the equation and just set the service restart command to reload. Also set the Augeas require to point directly at the lens rather than the class.. but that may be optional. It was our first step.

# git diff
diff --git a/manifests/config.pp b/manifests/config.pp
index c8b45a7..897c5d8 100644
--- a/manifests/config.pp
+++ b/manifests/config.pp
@@ -69,7 +69,7 @@ class pgpool::config {

   file { $pgpool_config_file:
     ensure => $::pgpool::file_ensure,
-    notify => Exec['pgpool_reload']
+    notify => Service['pgpool']
   }

   file { $pgpool_sysconfig_file:
@@ -79,17 +79,17 @@ class pgpool::config {

   file { $pool_passwd_file:
     ensure => $::pgpool::file_ensure,
-    notify => Exec['pgpool_reload']
+    notify => Service['pgpool']
   }

   file { $pool_hba_file:
     ensure => $::pgpool::file_ensure,
-    notify => Exec['pgpool_reload']
+    notify => Service['pgpool']
   }

   file { $pcp_file:
     ensure => $::pgpool::file_ensure,
-    notify => Exec['pgpool_reload']
+    notify => Service['pgpool']
   }

   file { $log_dir:
diff --git a/manifests/config/val.pp b/manifests/config/val.pp
index 40100af..3488d9b 100644
--- a/manifests/config/val.pp
+++ b/manifests/config/val.pp
@@ -59,9 +59,8 @@ define pgpool::config::val (
   Augeas {
     incl    => $target_real,
     lens    => 'Pgpool.lns',
-    require => Class['pgpool::config'],
-    notify  => Exec['pgpool_reload'],
-    before  => Service['pgpool']
+    require => Augeas::Lens['pgpool'],
+    notify  => Service['pgpool']
   }

   case $ensure_real {
diff --git a/manifests/hba.pp b/manifests/hba.pp
index f80c98e..a41715e 100644
--- a/manifests/hba.pp
+++ b/manifests/hba.pp
@@ -95,7 +95,6 @@ define pgpool::hba (
     options  => $options,
     position => $position,
     target   => $target_real,
-    notify   => Exec['pgpool_reload'],
-    before   => Service['pgpool']
+    notify   => Service['pgpool'],
   }
 }
diff --git a/manifests/service.pp b/manifests/service.pp
index fa09f6b..51e3ac2 100644
--- a/manifests/service.pp
+++ b/manifests/service.pp
@@ -36,22 +36,17 @@ class pgpool::service {

   $pgpool_service_name = $::pgpool::service_name_real

-  service { 'pgpool':
-    ensure => $::pgpool::service_ensure_real,
-    name   => $pgpool_service_name,
-    enable => $::pgpool::service_enable_real
-  }
-
   $exec_command_reload = $::osfamily ? {
     /RedHat/ => '/usr/bin/pgpool reload',
     /Debian/ => '/usr/sbin/pgpool reload',
     default  => '/usr/bin/pgpool reload',
   }

-
-  exec { 'pgpool_reload':
-    command     => $exec_command_reload,
-    require     => Service['pgpool'],
-    refreshonly => true,
+  service { 'pgpool':
+    ensure  => $::pgpool::service_ensure_real,
+    name    => $::pgpool_service_name,
+    enable  => $::pgpool::service_enable_real,
+    restart => $exec_command_reload,
   }
+
 }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.