From ebb7310f844eff1d99557b1b3c38ffa6fa5a7596 Mon Sep 17 00:00:00 2001 From: praj1001 <134480625+praj1001@users.noreply.github.com> Date: Tue, 4 Jul 2023 15:20:29 +0530 Subject: [PATCH 1/6] Removed specs for ntp.conf.erb template which is no longer being used --- REFERENCE.md | 7 ------- manifests/init.pp | 4 ---- readmes/README_ja_JP.md | 8 -------- spec/acceptance/ntp_parameters_spec.rb | 26 +++----------------------- spec/classes/ntp_spec.rb | 6 ------ 5 files changed, 3 insertions(+), 48 deletions(-) diff --git a/REFERENCE.md b/REFERENCE.md index cb7bb016b..20af8919c 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -153,13 +153,6 @@ Data type: `String` Specifies a file mode for the ntp configuration file. Default value: '0664'. -##### `config_template` - -Data type: `Optional[String]` - -Specifies an absolute or relative file path to an ERB template for the config file. -Example value: 'ntp/ntp.conf.erb'. A validation error is thrown if both this **and** the `config_epp` parameter are specified. - ##### `daemon_extra_opts` Data type: `Optional[String]` diff --git a/manifests/init.pp b/manifests/init.pp index 2fc853ea4..2b08e7c78 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -24,10 +24,6 @@ # @param config_file_mode # Specifies a file mode for the ntp configuration file. Default value: '0664'. # -# @param config_template -# Specifies an absolute or relative file path to an ERB template for the config file. -# Example value: 'ntp/ntp.conf.erb'. A validation error is thrown if both this **and** the `config_epp` parameter are specified. -# # @param daemon_extra_opts # Specifies any arguments to pass to ntp daemon. Default value: '-g'. # Example value: '-g -i /var/lib/ntp' to enable jaildir options. diff --git a/readmes/README_ja_JP.md b/readmes/README_ja_JP.md index 9b84d60b5..e4e86ed65 100644 --- a/readmes/README_ja_JP.md +++ b/readmes/README_ja_JP.md @@ -179,14 +179,6 @@ NTP構成ファイルのディレクトリを指定します。 デフォルト値: '0664' -#### `config_template` - -任意 - -データタイプ: 文字列 - -構成ファイルのERBテンプレートへの絶対パスまたは相対パスを指定します(値の例: 'ntp/ntp.conf.erb')。このパラメータと`config_epp`パラメータの**両方**を指定すると、バリデーションエラーが発生します。 - #### `disable_auth` データタイプ: 真偽値(boolean) diff --git a/spec/acceptance/ntp_parameters_spec.rb b/spec/acceptance/ntp_parameters_spec.rb index 8d66f50c1..dd1e7035a 100644 --- a/spec/acceptance/ntp_parameters_spec.rb +++ b/spec/acceptance/ntp_parameters_spec.rb @@ -46,26 +46,6 @@ end end - describe 'config_template' do - before :all do - run_shell("mkdir -p #{modulepath}/test/templates") - # Add spurious template logic to verify the use of the correct template rendering engine - run_shell("echo '<% [1].each do |i| %>erbserver<%= i %><%end %>' >> #{modulepath}/test/templates/ntp.conf.erb") - end - - it 'sets the ntp.conf erb template location' do - pp = "class { 'ntp': config_template => 'test/ntp.conf.erb' }" - apply_manifest(pp, catch_failures: true) - expect(file(config.to_s)).to be_file - expect(file(config.to_s).content).to match 'erbserver1' - end - - it 'sets the ntp.conf epp template location and the ntp.conf erb template location which should fail' do - pp = "class { 'ntp': config_template => 'test/ntp.conf.erb', config_epp => 'test/ntp.conf.epp' }" - expect(apply_manifest(pp, expect_failures: true).stderr).to match(%r{Cannot supply both config_epp and config_template}i) - end - end - describe 'config_epp' do before :all do run_shell("mkdir -p #{modulepath}/test/templates") @@ -80,9 +60,9 @@ expect(file(config.to_s).content).to match 'eppserver1' end - it 'sets the ntp.conf epp template location and the ntp.conf erb template location which should fail' do - pp = "class { 'ntp': config_template => 'test/ntp.conf.erb', config_epp => 'test/ntp.conf.epp' }" - expect(apply_manifest(pp, expect_failures: true).stderr).to match(%r{Cannot supply both config_epp and config_template}i) + it 'sets the ntp.conf epp template location which should fail' do + pp = "class { 'ntp': config_epp => 'test/ntp.conf.epp' }" + expect(apply_manifest(pp, expect_failures: true).stderr).to match(%r{Cannot supply config_epp}i) end end diff --git a/spec/classes/ntp_spec.rb b/spec/classes/ntp_spec.rb index 6d0906b98..6051de8ca 100644 --- a/spec/classes/ntp_spec.rb +++ b/spec/classes/ntp_spec.rb @@ -38,12 +38,6 @@ it { is_expected.to contain_file('/var/run/ntp/servers-netconfig').with_ensure_absent } if f[:os]['family'] == 'Suse' && f[:os]['release']['major'] == '12' - describe 'allows template to be overridden with erb template' do - let(:params) { { config_template: 'my_ntp/ntp.conf.erb' } } - - it { is_expected.to contain_file(conf_path).with_content(%r{erbserver1}) } - end - describe 'allows template to be overridden with epp template' do let(:params) { { config_epp: 'my_ntp/ntp.conf.epp' } } From bf402e7ae5dc1dbbab9f06714f92589723700020 Mon Sep 17 00:00:00 2001 From: praj1001 <134480625+praj1001@users.noreply.github.com> Date: Tue, 4 Jul 2023 15:21:22 +0530 Subject: [PATCH 2/6] Deleted the spec ntp.conf.erb --- spec/fixtures/my_ntp/templates/ntp.conf.erb | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 spec/fixtures/my_ntp/templates/ntp.conf.erb diff --git a/spec/fixtures/my_ntp/templates/ntp.conf.erb b/spec/fixtures/my_ntp/templates/ntp.conf.erb deleted file mode 100644 index 2284e2f9b..000000000 --- a/spec/fixtures/my_ntp/templates/ntp.conf.erb +++ /dev/null @@ -1,2 +0,0 @@ -# ERB template -<% [1].each do |i| %>erbserver<%= i %><%end %> From bbaac936e61a1152d61e7445110c813c849b51c9 Mon Sep 17 00:00:00 2001 From: praj1001 <134480625+praj1001@users.noreply.github.com> Date: Tue, 4 Jul 2023 15:57:56 +0530 Subject: [PATCH 3/6] Removed config template --- manifests/init.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 2b08e7c78..dfe1bcf70 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -230,7 +230,8 @@ # # @param user # Specifies user to run ntpd daemon. Default value: ntp. -# Usually set by default on Centos7 (/etc/systemd/system/multi-user.target.wants/ntpd.service) and ubuntu 18.04 (/usr/lib/ntp/ntp-systemd-wrapper) +# Usually set by default on Centos7 (/etc/systemd/system/multi-user.target.wants/ntpd.service) and +# ubuntu 18.04 (/usr/lib/ntp/ntp-systemd-wrapper) # This is currently restricted to Redhat based systems of version 7 and above and Ubuntu 18.04. # class ntp ( @@ -240,7 +241,6 @@ Optional[Stdlib::Absolutepath] $config_dir, String $config_file_mode, Optional[String] $config_epp, - Optional[String] $config_template, Boolean $disable_auth, Boolean $disable_dhclient, Boolean $disable_kernel, From e0bf72cc843ef0e96ab2e824a292bd16fa7f1355 Mon Sep 17 00:00:00 2001 From: praj1001 <134480625+praj1001@users.noreply.github.com> Date: Tue, 4 Jul 2023 16:14:50 +0530 Subject: [PATCH 4/6] ntp::config_template removed --- REFERENCE.md | 3 +-- data/common.yaml | 1 - manifests/config.pp | 12 +----------- manifests/init.pp | 2 +- 4 files changed, 3 insertions(+), 15 deletions(-) diff --git a/REFERENCE.md b/REFERENCE.md index 20af8919c..82c2de48a 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -46,7 +46,6 @@ The following parameters are available in the `ntp` class: * [`config_dir`](#-ntp--config_dir) * [`config_epp`](#-ntp--config_epp) * [`config_file_mode`](#-ntp--config_file_mode) -* [`config_template`](#-ntp--config_template) * [`daemon_extra_opts`](#-ntp--daemon_extra_opts) * [`disable_auth`](#-ntp--disable_auth) * [`disable_dhclient`](#-ntp--disable_dhclient) @@ -145,7 +144,7 @@ Specifies a directory for the NTP configuration files. Default value: undef. Data type: `Optional[String]` Specifies an absolute or relative file path to an EPP template for the config file. -Example value: 'ntp/ntp.conf.epp'. A validation error is thrown if both this **and** the `config_template` parameter are specified. +Example value: 'ntp/ntp.conf.epp'. A validation error is thrown if `config_epp` parameter is not specified. ##### `config_file_mode` diff --git a/data/common.yaml b/data/common.yaml index db1cb5151..20762e80f 100644 --- a/data/common.yaml +++ b/data/common.yaml @@ -5,7 +5,6 @@ ntp::burst: false ntp::config_dir: ~ ntp::config_file_mode: '0644' ntp::config: '/etc/ntp.conf' -ntp::config_template: ~ ntp::config_epp: ~ ntp::daemon_extra_opts: ~ ntp::disable_auth: false diff --git a/manifests/config.pp b/manifests/config.pp index 5b8691afa..1a28f9fec 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -90,17 +90,7 @@ } } - #If both epp and erb are defined, throw validation error. - #Otherwise use the defined erb/epp template, or use default - if $ntp::config_epp and $ntp::config_template { - fail('Cannot supply both config_epp and config_template templates for ntp config file.') - } elsif $ntp::config_template { - $config_content = template($ntp::config_template) - } elsif $ntp::config_epp { - $config_content = epp($ntp::config_epp) - } else { - $config_content = epp('ntp/ntp.conf.epp') - } + $config_content = epp('ntp/ntp.conf.epp') file { $ntp::config: ensure => file, diff --git a/manifests/init.pp b/manifests/init.pp index dfe1bcf70..8717d5f54 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -19,7 +19,7 @@ # # @param config_epp # Specifies an absolute or relative file path to an EPP template for the config file. -# Example value: 'ntp/ntp.conf.epp'. A validation error is thrown if both this **and** the `config_template` parameter are specified. +# Example value: 'ntp/ntp.conf.epp'. A validation error is thrown if `config_epp` parameter is not specified. # # @param config_file_mode # Specifies a file mode for the ntp configuration file. Default value: '0664'. From d6c61f77d25b8c1a82bf3681eebd344589da8ec2 Mon Sep 17 00:00:00 2001 From: praj1001 <134480625+praj1001@users.noreply.github.com> Date: Tue, 4 Jul 2023 17:43:24 +0530 Subject: [PATCH 5/6] modified logic in config.pp --- manifests/config.pp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/manifests/config.pp b/manifests/config.pp index 1a28f9fec..a3554cfa9 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -90,7 +90,11 @@ } } - $config_content = epp('ntp/ntp.conf.epp') + if $ntp::config_epp { + $config_content = epp($ntp::config_epp) + } else { + $config_content = epp('ntp/ntp.conf.epp') + } file { $ntp::config: ensure => file, From 2919c58fc3eaaf228211b9894c0f6bfb9fc817e6 Mon Sep 17 00:00:00 2001 From: praj1001 <134480625+praj1001@users.noreply.github.com> Date: Tue, 4 Jul 2023 18:10:57 +0530 Subject: [PATCH 6/6] unnecessary spec removed --- spec/acceptance/ntp_parameters_spec.rb | 5 ----- 1 file changed, 5 deletions(-) diff --git a/spec/acceptance/ntp_parameters_spec.rb b/spec/acceptance/ntp_parameters_spec.rb index dd1e7035a..1b4161d0b 100644 --- a/spec/acceptance/ntp_parameters_spec.rb +++ b/spec/acceptance/ntp_parameters_spec.rb @@ -59,11 +59,6 @@ expect(file(config.to_s)).to be_file expect(file(config.to_s).content).to match 'eppserver1' end - - it 'sets the ntp.conf epp template location which should fail' do - pp = "class { 'ntp': config_epp => 'test/ntp.conf.epp' }" - expect(apply_manifest(pp, expect_failures: true).stderr).to match(%r{Cannot supply config_epp}i) - end end describe 'package' do