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

Avoid duplicate inisection declarations #215

Merged
merged 2 commits into from
Sep 12, 2018
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
28 changes: 16 additions & 12 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@
mode => '0640',
}

icingaweb2::inisection {'logging':
target => "${conf_dir}/config.ini",
settings => {
icingaweb2::inisection { 'config-logging':
section_name => 'logging',
target => "${conf_dir}/config.ini",
settings => {
'log' => $logging,
'file' => $logging_file,
'level' => $logging_level
Expand All @@ -79,23 +80,26 @@
}


icingaweb2::inisection {'global':
target => "${conf_dir}/config.ini",
settings => delete_undef_values($settings),
icingaweb2::inisection { 'config-global':
section_name => 'global',
target => "${conf_dir}/config.ini",
settings => delete_undef_values($settings),
}

if $default_domain {
icingaweb2::inisection {'authentication':
target => "${conf_dir}/config.ini",
settings => {
icingaweb2::inisection { 'config-authentication':
section_name => 'authentication',
target => "${conf_dir}/config.ini",
settings => {
'default_domain' => $default_domain,
}
}
}

icingaweb2::inisection {'themes':
target => "${conf_dir}/config.ini",
settings => {
icingaweb2::inisection { 'config-themes':
section_name => 'themes',
target => "${conf_dir}/config.ini",
settings => {
'default' => $theme,
'disabled' => $theme_disabled,
},
Expand Down
9 changes: 5 additions & 4 deletions manifests/config/authmethod.pp
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@
}
}

icingaweb2::inisection { $title:
target => "${conf_dir}/authentication.ini",
settings => delete_undef_values($settings),
order => $order,
icingaweb2::inisection { "authmethod-${title}":
section_name => $title,
target => "${conf_dir}/authentication.ini",
settings => delete_undef_values($settings),
order => $order,
}
}
7 changes: 4 additions & 3 deletions manifests/config/groupbackend.pp
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@
}
}

icingaweb2::inisection { $title:
target => "${conf_dir}/groups.ini",
settings => delete_undef_values($settings),
icingaweb2::inisection { "groupbackend-${title}":
section_name => $title,
target => "${conf_dir}/groups.ini",
settings => delete_undef_values($settings),
}
}
9 changes: 5 additions & 4 deletions manifests/config/resource.pp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
String $resource_name = $title,
Enum['db', 'ldap'] $type = undef,
String $host = undef,
Integer[1,65535] $port = undef,
Optional[Integer[1,65535]] $port = undef,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't set a port in your resource declaration, Puppet will throw an error: Error while evaluating a Resource Statement, Icingaweb2::Config::Resource[Icingaweb2 Database]: parameter 'port' expects an Integer value, got Undef.

Optional[Enum['mysql', 'pgsql']] $db_type = undef,
Optional[String] $db_name = undef,
Optional[String] $db_username = undef,
Expand Down Expand Up @@ -107,8 +107,9 @@
}
}

icingaweb2::inisection { $resource_name:
target => "${conf_dir}/resources.ini",
settings => delete_undef_values($settings),
icingaweb2::inisection { "resource-${resource_name}":
section_name => $resource_name,
target => "${conf_dir}/resources.ini",
settings => delete_undef_values($settings),
}
}
7 changes: 4 additions & 3 deletions manifests/config/role.pp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@
'permissions' => $permissions,
}

icingaweb2::inisection{ $role_name:
target => "${conf_dir}/roles.ini",
settings => delete_undef_values(merge($settings,$filters))
icingaweb2::inisection{ "role-${role_name}":
section_name => $role_name,
target => "${conf_dir}/roles.ini",
settings => delete_undef_values(merge($settings,$filters))
}
}
8 changes: 4 additions & 4 deletions spec/classes/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
"class { 'icingaweb2': }"
end

it { is_expected.to contain_icingaweb2__inisection('logging') }
it { is_expected.to contain_icingaweb2__inisection('global')
it { is_expected.to contain_icingaweb2__inisection('config-logging') }
it { is_expected.to contain_icingaweb2__inisection('config-global')
.with_settings({ 'show_stacktraces' => false, 'module_path' => '/usr/share/icingaweb2/modules', 'config_backend' => 'ini' })
}
it { is_expected.to contain_icingaweb2__inisection('themes') }
it { is_expected.to contain_icingaweb2__inisection('config-themes') }
it { is_expected.to contain_file('/var/log/icingaweb2')
.with_ensure('directory')
.with_mode('0750')
Expand Down Expand Up @@ -74,7 +74,7 @@
"class { 'icingaweb2': config_backend => 'db' }"
end

it { is_expected.to contain_icingaweb2__inisection('global')
it { is_expected.to contain_icingaweb2__inisection('config-global')
.with_settings({ 'show_stacktraces' => false, 'module_path' => '/usr/share/icingaweb2/modules', 'config_backend' => 'db', 'config_resource' => 'mysql-icingaweb2' })
}

Expand Down
8 changes: 4 additions & 4 deletions spec/defines/authmethod_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
context "#{os} with backend 'external'" do
let(:params) { { :backend => 'external', :order => '10' } }

it { is_expected.to contain_icingaweb2__inisection('myauthmethod')
it { is_expected.to contain_icingaweb2__inisection('authmethod-myauthmethod')
.with_target('/etc/icingaweb2/authentication.ini')
.with_settings({'backend'=>'external'})
.with_order('10')}
Expand All @@ -25,7 +25,7 @@
context "#{os} with backend 'ldap'" do
let(:params) { { :backend => 'ldap', :resource => 'myresource', :ldap_user_class => 'users', :ldap_user_name_attribute => 'uid', :ldap_filter => 'foobar', :domain => 'icinga.com', :order => '10' } }

it { is_expected.to contain_icingaweb2__inisection('myauthmethod')
it { is_expected.to contain_icingaweb2__inisection('authmethod-myauthmethod')
.with_target('/etc/icingaweb2/authentication.ini')
.with_settings({'backend'=>'ldap', 'resource'=>'myresource', 'user_class'=>'users', 'user_name_attribute'=>'uid', 'filter'=>'foobar', 'domain'=>'icinga.com' }, )
.with_order('10')}
Expand All @@ -34,7 +34,7 @@
context "#{os} with backend 'msldap'" do
let(:params) { { :backend => 'msldap', :resource => 'myresource', :order => '10' } }

it { is_expected.to contain_icingaweb2__inisection('myauthmethod')
it { is_expected.to contain_icingaweb2__inisection('authmethod-myauthmethod')
.with_target('/etc/icingaweb2/authentication.ini')
.with_settings({'backend'=>'msldap', 'resource'=>'myresource'})
.with_order('10')}
Expand All @@ -43,7 +43,7 @@
context "#{os} with backend 'db'" do
let(:params) { { :backend => 'db', :resource => 'myresource', :order => '10' } }

it { is_expected.to contain_icingaweb2__inisection('myauthmethod')
it { is_expected.to contain_icingaweb2__inisection('authmethod-myauthmethod')
.with_target('/etc/icingaweb2/authentication.ini')
.with_settings({'backend'=>'db', 'resource'=>'myresource'})
.with_order('10')}
Expand Down
6 changes: 3 additions & 3 deletions spec/defines/groupbackend_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
context "#{os} with backend 'db'" do
let(:params) { { :backend => 'db', :resource => 'my-ldap' } }

it { is_expected.to contain_icingaweb2__inisection('mygroupbackend')
it { is_expected.to contain_icingaweb2__inisection('groupbackend-mygroupbackend')
.with_target('/etc/icingaweb2/groups.ini')
.with_settings({'backend'=>'db', 'resource' => 'my-ldap'})}

Expand All @@ -24,15 +24,15 @@
context "#{os} with backend 'ldap'" do
let(:params) { { :backend => 'ldap', :resource => 'my-ldap', :ldap_group_class => 'groupofnames', :ldap_group_name_attribute => 'cn', :ldap_group_member_attribute => 'member', :ldap_base_dn => 'foobar', :domain => 'icinga.com' } }

it { is_expected.to contain_icingaweb2__inisection('mygroupbackend')
it { is_expected.to contain_icingaweb2__inisection('groupbackend-mygroupbackend')
.with_target('/etc/icingaweb2/groups.ini')
.with_settings({'backend'=>'ldap', 'resource'=>'my-ldap', 'group_class'=>'groupofnames', 'group_name_attribute'=>'cn', 'group_member_attribute'=>'member', 'base_dn'=>'foobar', 'domain' => 'icinga.com'})}
end

context "#{os} with backend 'msldap'" do
let(:params) { { :backend => 'msldap', :resource => 'my-msldap', :ldap_user_backend => 'ad1', :ldap_nested_group_search => true, :ldap_group_filter => 'baz', :ldap_base_dn => 'foobar', :domain => 'icinga.com' } }

it { is_expected.to contain_icingaweb2__inisection('mygroupbackend')
it { is_expected.to contain_icingaweb2__inisection('groupbackend-mygroupbackend')
.with_target('/etc/icingaweb2/groups.ini')
.with_settings({'backend'=>'msldap', 'resource'=>'my-msldap', 'user_backend'=>'ad1', 'nested_group_search'=>'1', 'group_filter'=>'baz', 'base_dn'=>'foobar', 'domain' => 'icinga.com' })}
end
Expand Down
4 changes: 2 additions & 2 deletions spec/defines/resource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
:db_username => 'bar',
:db_password => 'secret' } }

it { is_expected.to contain_icingaweb2__inisection('myresource')
it { is_expected.to contain_icingaweb2__inisection('resource-myresource')
.with_target('/etc/icingaweb2/resources.ini')
.with_settings({'type'=>'db', 'db'=>'mysql', 'host'=>'localhost', 'port'=>'3306', 'dbname'=>'foo', 'username'=>'bar', 'password'=>'secret'}) }

Expand All @@ -37,7 +37,7 @@
:ldap_bind_dn => 'cn=root,dc=bar',
:ldap_bind_pw => 'secret' } }

it { is_expected.to contain_icingaweb2__inisection('myresource')
it { is_expected.to contain_icingaweb2__inisection('resource-myresource')
.with_target('/etc/icingaweb2/resources.ini')
.with_settings({'type'=>'ldap', 'hostname'=>'localhost', 'port'=>'389', 'root_dn'=>'cn=foo,dc=bar', 'bind_dn'=>'cn=root,dc=bar', 'bind_pw'=>'secret', 'encryption'=>'none'})}

Expand Down
4 changes: 2 additions & 2 deletions spec/defines/role_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
context "#{os} with users => 'bob, pete' and permissions => '*'" do
let(:params) { { :users => 'bob, pete', :permissions => '*' } }

it { is_expected.to contain_icingaweb2__inisection('myrole')
it { is_expected.to contain_icingaweb2__inisection('role-myrole')
.with_target('/etc/icingaweb2/roles.ini')
.with_settings({'users'=>'bob, pete', 'permissions' => '*'}) }

Expand All @@ -24,7 +24,7 @@
context "#{os} with users => 'bob, pete', permissions => 'module/monitoring', filters => {'monitoring/filter/objects' => 'host_name=linux-*'}" do
let(:params) { { :users => 'bob, pete', :permissions => 'module/monitoring', :filters => {'monitoring/filter/objects' => 'host_name=linux-*'} } }

it { is_expected.to contain_icingaweb2__inisection('myrole')
it { is_expected.to contain_icingaweb2__inisection('role-myrole')
.with_target('/etc/icingaweb2/roles.ini')
.with_settings({'users'=>'bob, pete', 'permissions'=>'module/monitoring', 'monitoring/filter/objects'=>'host_name=linux-*'}) }

Expand Down