Skip to content

Commit

Permalink
Merge pull request #558 from vrtdev/feature/config-naming
Browse files Browse the repository at this point in the history
Add config_name parameter to define the name of the consul config
  • Loading branch information
solarkennedy committed Jan 15, 2021
2 parents 3d490c7 + ea4c9ab commit 815c488
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
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

0 comments on commit 815c488

Please sign in to comment.