diff --git a/REFERENCE.md b/REFERENCE.md index aacb11844..4836beddd 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -176,8 +176,7 @@ Default value: `true` Data type: `String[1]` The version of the package repo. - -Default value: `'5.0'` +If not specified, the module will use the most resent version for your OS distro. ##### `use_enterprise_repo` diff --git a/data/Debian-10.yaml b/data/Debian-10.yaml new file mode 100644 index 000000000..65fc24748 --- /dev/null +++ b/data/Debian-10.yaml @@ -0,0 +1,2 @@ +--- +mongodb::globals::repo_version: '6.0' diff --git a/data/common.yaml b/data/common.yaml new file mode 100644 index 000000000..448a559da --- /dev/null +++ b/data/common.yaml @@ -0,0 +1,2 @@ +--- +mongodb::globals::repo_version: '7.0' diff --git a/manifests/globals.pp b/manifests/globals.pp index 5ffbdb91a..d012e6207 100644 --- a/manifests/globals.pp +++ b/manifests/globals.pp @@ -50,6 +50,7 @@ # # @param repo_version # The version of the package repo. +# If not specified, the module will use the most resent version for your OS distro. # # @param use_enterprise_repo # When manage_package_repo is set to true, this setting indicates if it will use the Community Edition @@ -74,11 +75,11 @@ # This sets the password for the proxyserver, should authentication be required # class mongodb::globals ( - Optional[String[1]] $version = undef, - Optional[String[1]] $client_version = undef, + String[1] $repo_version, Boolean $manage_package_repo = true, - String[1] $repo_version = '5.0', Boolean $use_enterprise_repo = false, + Optional[String[1]] $version = undef, + Optional[String[1]] $client_version = undef, Optional[String] $repo_location = undef, Optional[String] $keyring_location = undef, Optional[String] $repo_proxy = undef, diff --git a/spec/classes/server_spec.rb b/spec/classes/server_spec.rb index 8eae0cbad..ec4f5e6a3 100644 --- a/spec/classes/server_spec.rb +++ b/spec/classes/server_spec.rb @@ -266,47 +266,66 @@ end end - describe 'with journal: true' do + describe 'with journal' do let :params do { journal: true } end - it do - config_data = YAML.safe_load(catalogue.resource("File[#{config_file}]")[:content]) - expect(config_data['storage']['journal']['enabled']).to be(true) + if (facts[:os]['name'] == 'Debian') && (facts[:os]['release']['major'] <= '10') + it do + config_data = YAML.safe_load(catalogue.resource("File[#{config_file}]")[:content]) + expect(config_data['storage']['journal']['enabled']).to be(true) + end + else + it { is_expected.to raise_error(Puppet::Error) } end end - describe 'with journal: false' do + describe 'with journal: true and package_ensure < 7.0.0' do let :params do { - journal: false + package_ensure: '6.0.0', + journal: true } end + let(:pre_condition) do + [ + 'class{"mongodb::globals": + manage_package_repo => false + }' + ] + end it do config_data = YAML.safe_load(catalogue.resource("File[#{config_file}]")[:content]) - expect(config_data['storage']['journal']['enabled']).to be(false) + expect(config_data['storage']['journal']['enabled']).to be(true) end end - describe 'with journal and package_version < 7.0.0' do + describe 'with journal: false and package_ensure < 7.0.0' do let :params do { package_ensure: '6.0.0', - journal: true + journal: false } end + let(:pre_condition) do + [ + 'class{"mongodb::globals": + manage_package_repo => false + }' + ] + end it do config_data = YAML.safe_load(catalogue.resource("File[#{config_file}]")[:content]) - expect(config_data['storage']['journal']['enabled']).to be(true) + expect(config_data['storage']['journal']['enabled']).to be(false) end end - describe 'with journal and package_version >= 7.0.0' do + describe 'with journal and package_ensure >= 7.0.0' do let :params do { package_ensure: '7.0.0', @@ -317,31 +336,7 @@ it { is_expected.to raise_error(Puppet::Error) } end - describe 'with journal and user defined repo_location without version' do - let :params do - { - journal: true - } - end - let(:pre_condition) do - [ - 'class mongodb::globals { - $manage_package_repo = true - $version = "5.0" - $edition = "org" - $repo_location = "https://repo.myorg.com/" - }', - 'class{"mongodb::globals": }' - ] - end - - it do - config_data = YAML.safe_load(catalogue.resource("File[#{config_file}]")[:content]) - expect(config_data['storage']['journal']['enabled']).to be(true) - end - end - - describe 'with journal and user defined repo_location with version < 7.0' do + describe 'with journal and user defined repo_version with version < 7.0' do let :params do { journal: true @@ -349,13 +344,9 @@ end let(:pre_condition) do [ - 'class mongodb::globals { - $manage_package_repo = true - $version = "5.0" - $edition = "org" - $repo_location = "https://repo.myorg.com/6.0/" - }', - 'class{"mongodb::globals": }' + 'class{"mongodb::globals": + repo_version => "6.0" + }' ] end @@ -365,7 +356,7 @@ end end - describe 'with journal and user defined repo_location with version >= 7.0' do + describe 'with journal and user defined repo_version with version >= 7.0' do let :params do { journal: true @@ -373,13 +364,9 @@ end let(:pre_condition) do [ - 'class mongodb::globals { - $manage_package_repo = true - $version = "5.0" - $edition = "org" - $repo_location = "https://repo.myorg.com/7.0/" - }', - 'class{"mongodb::globals": }' + 'class{"mongodb::globals": + repo_version => "7.0" + }' ] end