Skip to content

Commit

Permalink
Merge pull request #7 from MiamiOH/6-change-config
Browse files Browse the repository at this point in the history
6 change config
  • Loading branch information
dstepe committed May 4, 2018
2 parents 4b1cb5c + e3c2db4 commit f18442b
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 12 deletions.
1 change: 0 additions & 1 deletion .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ fixtures:
stdlib: "puppetlabs/stdlib"
python: "stankevich/python"
archive: "puppet/archive"
inifile: "puppetlabs/inifile"
11 changes: 8 additions & 3 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
# don't use this class directly
class duo_authproxy::config {

create_ini_settings($duo_authproxy::settings, {
'path' => "${duo_authproxy::install_dir}/conf/authproxy.cfg",
})
file { 'authproxy.cfg':
ensure => file,
path => "${duo_authproxy::install_dir}/conf/authproxy.cfg",
owner => 'nobody',
group => 'root',
mode => '0640',
content => Sensitive(template("${module_name}/authproxy.cfg.erb")),
}
}
4 changes: 0 additions & 4 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
{
"name": "puppet/archive",
"version_requirement": ">= 1.1.0 < 4.0.0"
},
{
"name": "puppetlabs/inifile",
"version_requirement": ">= 1.3.0 < 3.0.0"
}
],
"operatingsystem_support": [
Expand Down
7 changes: 3 additions & 4 deletions spec/classes/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
context 'with settings' do
it { is_expected.to compile.with_all_deps }
it do
is_expected.to contain_ini_setting('/opt/duoauthproxy/conf/authproxy.cfg [main] debug').with(
'section' => 'main',
'setting' => 'debug',
'value' => 'true',
is_expected.to contain_file('authproxy.cfg').with(
'ensure' => 'file',
'path' => '/opt/duoauthproxy/conf/authproxy.cfg',
'content' => "# Managed by Puppet.\n\n[main]\ndebug=true\n\n",
)
end
end
Expand Down
18 changes: 18 additions & 0 deletions templates/authproxy.cfg.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Managed by Puppet.

<% scope['duo_authproxy::settings'].map do |k,v| -%>
<% if v.is_a?(Hash) -%>
[<%= k %>]
<% v.map do |ki, vi| -%>
<% if vi.is_a?(Array) -%>
<%= ki %>=<%= vi.join(',') %>
<% elsif vi != :undef -%>
<%= ki %>=<%= vi %>
<% end -%>
<% end -%>
<% else -%>
[<%= k %>]

<% end -%>
<% end -%>

0 comments on commit f18442b

Please sign in to comment.