Skip to content

Commit

Permalink
Merge pull request #31 from plmayekar/standby-cluster
Browse files Browse the repository at this point in the history
adding standby cluster config
  • Loading branch information
ghoneycutt authored Dec 3, 2024
2 parents cacdff3 + 9b7f741 commit 87e8ba2
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
12 changes: 12 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,14 @@
# Patroni service enable property
# @param custom_pip_provider
# Use custom pip path when installing pip packages
# @param is_standby
# Boolean to use Standby cluster
# @param standby_cluster_host
# Refer to Standby configuration `host` setting
# @param standby_cluster_port
# Refer to Standby configuration `port` setting
# @param standby_cluster_primary_slot_name
# Refer to Standby configuration `slot` setting
class patroni (

# Global Settings
Expand Down Expand Up @@ -272,6 +280,10 @@
Hash $bootstrap_users = {},
Variant[Undef,String] $bootstrap_post_bootstrap = undef,
Variant[Undef,String] $bootstrap_post_init = undef,
Boolean $is_standby = false,
String $standby_cluster_host = '127.0.0.1',
Stdlib::Port $standby_cluster_port = 5432,
Optional[String] $standby_cluster_primary_slot_name = 'patroni',

Check warning on line 286 in manifests/init.pp

View workflow job for this annotation

GitHub Actions / Puppet 7 (Ruby 2.7.8 fixtures=.fixtures.yml)

Optional parameter defaults to something other than undef (check: optional_default)

Check warning on line 286 in manifests/init.pp

View workflow job for this annotation

GitHub Actions / Puppet 7 (Ruby 2.7.8 fixtures=.fixtures-latest.yml)

Optional parameter defaults to something other than undef (check: optional_default)

Check warning on line 286 in manifests/init.pp

View workflow job for this annotation

GitHub Actions / Puppet 8 (Ruby 3.2.2 fixtures=.fixtures.yml)

Optional parameter defaults to something other than undef (check: optional_default)

Check warning on line 286 in manifests/init.pp

View workflow job for this annotation

GitHub Actions / Puppet 8 (Ruby 3.2.2 fixtures=.fixtures-latest.yml)

Optional parameter defaults to something other than undef (check: optional_default)

# PostgreSQL Settings
String $superuser_username = 'postgres',
Expand Down
17 changes: 17 additions & 0 deletions spec/classes/patroni_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,23 @@
)
end

context 'is_standby => true' do
let(:params) { { 'scope' => 'testscope', 'is_standby' => true } }

it 'has valid config' do
content = catalogue.resource('file', 'patroni_config').send(:parameters)[:content]
config = YAML.safe_load(content)
expected = {
'standby_cluster' => {
'host' => '127.0.0.1',
'port' => '5432',
'primary_slot_name' => 'patroni',
},
}
expect(config).to include(expected)
end
end

context 'use_etcd => true' do
let(:params) { { 'scope' => 'testscope', 'use_etcd' => true } }

Expand Down
6 changes: 6 additions & 0 deletions templates/postgresql.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ name: <%= @hostname %>

bootstrap:
dcs:
<%- if @is_standby -%>
standby_cluster:
host: <%= @standby_cluster_host %>
port: <%= @standby_cluster_port %>
primary_slot_name: <%= @standby_cluster_primary_slot_name %>
<%- end -%>
ttl: <%= @dcs_ttl %>
loop_wait: <%= @dcs_loop_wait %>
retry_timeout: <%= @dcs_retry_timeout %>
Expand Down

0 comments on commit 87e8ba2

Please sign in to comment.