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

Add config_name parameter to define the name of the consul config #558

Merged
merged 1 commit into from Jan 15, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions manifests/config.pp
Expand Up @@ -123,9 +123,9 @@
recurse => $purge,
}

file { 'consul config.json':
file { 'consul config':
ensure => present,
path => "${consul::config_dir}/config.json",
path => "${consul::config_dir}/${consul::config_name}",
owner => $consul::user_real,
group => $consul::group_real,
mode => $consul::config_mode,
Expand Down
4 changes: 4 additions & 0 deletions manifests/init.pp
Expand Up @@ -58,6 +58,9 @@
# [*config_dir*]
# Directory to place consul configuration files in.
#
# [*config_name*]
# Name of the consul configuration file.
#
# [*config_hash*]
# Use this to populate the JSON config file for consul.
#
Expand Down Expand Up @@ -202,6 +205,7 @@
Hash $checks = {},
Hash $config_defaults = $consul::params::config_defaults,
Stdlib::Absolutepath $config_dir = $consul::params::config_dir,
String[1] $config_name = 'config.json',
Hash $config_hash = {},
String[1] $config_mode = '0664',
String[1] $data_dir_mode = $consul::params::data_dir_mode,
Expand Down
34 changes: 17 additions & 17 deletions spec/classes/init_spec.rb
Expand Up @@ -159,14 +159,14 @@
'ui' => true
},
}}
it { should contain_file('consul config.json').with_content(/"ui":true/) }
it { should contain_file('consul config').with_content(/"ui":true/) }
end

context "When not installing UI" do
let(:params) {{
:config_hash => { },
}}
it { should_not contain_file('consul config.json').with_content(/"ui":true/) }
it { should_not contain_file('consul config').with_content(/"ui":true/) }
end

context "By default, a user and group should be installed" do
Expand Down Expand Up @@ -194,8 +194,8 @@
:config_hash =>
{ 'bootstrap_expect' => '5' }
}}
it { should contain_file('consul config.json').with_content(/"bootstrap_expect":5/) }
it { should_not contain_file('consul config.json').with_content(/"bootstrap_expect":"5"/) }
it { should contain_file('consul config').with_content(/"bootstrap_expect":5/) }
it { should_not contain_file('consul config').with_content(/"bootstrap_expect":"5"/) }
end

context 'Config_defaults is used to provide additional config' do
Expand All @@ -207,8 +207,8 @@
'bootstrap_expect' => '5',
}
}}
it { should contain_file('consul config.json').with_content(/"bootstrap_expect":5/) }
it { should contain_file('consul config.json').with_content(/"data_dir":"\/dir1"/) }
it { should contain_file('consul config').with_content(/"bootstrap_expect":5/) }
it { should contain_file('consul config').with_content(/"data_dir":"\/dir1"/) }
end

context 'Config_defaults is used to provide additional config and is overridden' do
Expand All @@ -230,11 +230,11 @@
},
}
}}
it { should contain_file('consul config.json').with_content(/"bootstrap_expect":5/) }
it { should contain_file('consul config.json').with_content(/"data_dir":"\/dir1"/) }
it { should contain_file('consul config.json').with_content(/"server":true/) }
it { should contain_file('consul config.json').with_content(/"http":-1/) }
it { should contain_file('consul config.json').with_content(/"https":8500/) }
it { should contain_file('consul config').with_content(/"bootstrap_expect":5/) }
it { should contain_file('consul config').with_content(/"data_dir":"\/dir1"/) }
it { should contain_file('consul config').with_content(/"server":true/) }
it { should contain_file('consul config').with_content(/"http":-1/) }
it { should contain_file('consul config').with_content(/"https":8500/) }
end

context 'When pretty config is true' do
Expand All @@ -249,11 +249,11 @@
},
}
}}
it { should contain_file('consul config.json').with_content(/"bootstrap_expect": 5,/) }
it { should contain_file('consul config.json').with_content(/"server": true/) }
it { should contain_file('consul config.json').with_content(/"http": -1,/) }
it { should contain_file('consul config.json').with_content(/"https": 8500/) }
it { should contain_file('consul config.json').with_content(/"ports": \{/) }
it { should contain_file('consul config').with_content(/"bootstrap_expect": 5,/) }
it { should contain_file('consul config').with_content(/"server": true/) }
it { should contain_file('consul config').with_content(/"http": -1,/) }
it { should contain_file('consul config').with_content(/"https": 8500/) }
it { should contain_file('consul config').with_content(/"ports": \{/) }
end

context "When asked not to manage the user" do
Expand Down Expand Up @@ -311,7 +311,7 @@
:group => 'custom_consul_group',
:config_mode => '0600',
}}
it { should contain_file('consul config.json').with(
it { should contain_file('consul config').with(
:owner => 'custom_consul_user',
:group => 'custom_consul_group',
:mode => '0600'
Expand Down