Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(CONT-1151) erb to epp template conversion #691

Merged
merged 7 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -145,21 +144,14 @@ 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.

##### <a name="-ntp--config_file_mode"></a>`config_file_mode`

Data type: `String`

Specifies a file mode for the ntp configuration file. Default value: '0664'.

##### <a name="-ntp--config_template"></a>`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.

##### <a name="-ntp--daemon_extra_opts"></a>`daemon_extra_opts`

Data type: `Optional[String]`
Expand Down
1 change: 0 additions & 1 deletion data/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
praj1001 marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
8 changes: 1 addition & 7 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +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 {
if $ntp::config_epp {
$config_content = epp($ntp::config_epp)
} else {
$config_content = epp('ntp/ntp.conf.epp')
Expand Down
10 changes: 3 additions & 7 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,11 @@
#
# @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'.
#
# @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.
Expand Down Expand Up @@ -234,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 (
Expand All @@ -244,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,
Expand Down
8 changes: 0 additions & 8 deletions readmes/README_ja_JP.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,6 @@ NTP構成ファイルのディレクトリを指定します。

デフォルト値: '0664'

#### `config_template`

任意

データタイプ: 文字列

構成ファイルのERBテンプレートへの絶対パスまたは相対パスを指定します(値の例: 'ntp/ntp.conf.erb')。このパラメータと`config_epp`パラメータの**両方**を指定すると、バリデーションエラーが発生します。

#### `disable_auth`

データタイプ: 真偽値(boolean)
Expand Down
25 changes: 0 additions & 25 deletions spec/acceptance/ntp_parameters_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -79,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 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 'package' do
Expand Down
6 changes: 0 additions & 6 deletions spec/classes/ntp_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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' } }

Expand Down
2 changes: 0 additions & 2 deletions spec/fixtures/my_ntp/templates/ntp.conf.erb

This file was deleted.