diff --git a/README.md b/README.md index 437c055bc..3a878e040 100644 --- a/README.md +++ b/README.md @@ -461,6 +461,11 @@ class mongodb::server { } ``` +##### `repl_enable_majority_read_concern` +Use this setting to configure replication.enableMajorityReadConcern setting. +For more information please refer to [MongoDB Read Concern "majority"](https://dochub.mongodb.org/core/psa-disable-rc-majority-3.6). +Default: undef (which implies the MongoDB default setting of true) + ##### `config_data` A hash to allow for additional configuration options to be set in user-provided template. diff --git a/manifests/server.pp b/manifests/server.pp index 007f52f76..6c0f54ec1 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -79,6 +79,7 @@ Boolean $handle_creds = $mongodb::params::handle_creds, Boolean $store_creds = $mongodb::params::store_creds, Array $admin_roles = $mongodb::params::admin_roles, + Optional[Boolean] $repl_enable_majority_read_concern = undef, ) inherits mongodb::params { contain mongodb::server::install diff --git a/manifests/server/config.pp b/manifests/server/config.pp index 486af7557..9ea53b2d3 100644 --- a/manifests/server/config.pp +++ b/manifests/server/config.pp @@ -67,6 +67,7 @@ $ssl_invalid_hostnames = $mongodb::server::ssl_invalid_hostnames $ssl_mode = $mongodb::server::ssl_mode $storage_engine = $mongodb::server::storage_engine + $repl_enable_majority_read_concern = $mongodb::server::repl_enable_majority_read_concern File { owner => $user, diff --git a/spec/classes/server_spec.rb b/spec/classes/server_spec.rb index ffeab1355..4a234d5c3 100644 --- a/spec/classes/server_spec.rb +++ b/spec/classes/server_spec.rb @@ -47,7 +47,8 @@ with_content(%r{^storage\.dbPath: /var/lib/mongodb$}). with_content(%r{^net\.bindIp: 127\.0\.0\.1$}). with_content(%r{^systemLog\.logAppend: true$}). - with_content(%r{^systemLog\.path: #{log_path}$}) + with_content(%r{^systemLog\.path: #{log_path}$}). + without_content(%r{^replication\.enableMajorityReadConcern:}) end if facts[:os]['family'] == 'Debian' @@ -329,6 +330,24 @@ end end + describe 'repl_enable_majority_read_concern param' do + context 'set to true' do + let(:params) do + { repl_enable_majority_read_concern: true } + end + + it { is_expected.to contain_file(config_file).with_content(%r{^\s*replication\.enableMajorityReadConcern: true$}) } + end + + context 'set to false' do + let(:params) do + { repl_enable_majority_read_concern: false } + end + + it { is_expected.to contain_file(config_file).with_content(%r{^\s*replication\.enableMajorityReadConcern: false$}) } + end + end + context 'when setting up replicasets' do describe 'should setup using replset_config' do let(:rsConf) do diff --git a/templates/mongodb.conf.2.6.erb b/templates/mongodb.conf.2.6.erb index 3da682a77..b39884451 100644 --- a/templates/mongodb.conf.2.6.erb +++ b/templates/mongodb.conf.2.6.erb @@ -129,6 +129,9 @@ replication.replSetName: <%= @replset %> <% if @oplog_size -%> replication.oplogSizeMB: <%= @oplog_size %> <% end -%> +<% if defined?(@repl_enable_majority_read_concern) -%> +replication.enableMajorityReadConcern: <%= @repl_enable_majority_read_concern %> +<% end -%> #Sharding <% if @configsvr -%>