Moving away from templates to usign inifile from Puppetlabs/inifile

This commit is contained in:
Steven Bambling 2015-03-16 13:44:56 -04:00
parent 53cdcf82a6
commit d91ca34935
18 changed files with 364 additions and 63 deletions

View file

@ -2,6 +2,7 @@ fixtures:
repositories:
apache: 'git://github.com/puppetlabs/puppetlabs-apache.git'
concat: 'git://github.com/puppetlabs/puppetlabs-concat.git'
inifile: 'git://github.com/puppetlabs/puppetlabs-inifile.git'
stdlib: 'git://github.com/puppetlabs/puppetlabs-stdlib.git'
vcsrepo: 'git://github.com/puppetlabs/puppetlabs-vcsrepo.git'

View file

@ -1,7 +1,11 @@
# == Class icingaweb2::config
#
class icingaweb2::config {
assert_private()
class icingaweb2::config {
if is_function_available('assert_private') {
assert_private()
} else {
private()
}
@user { 'icingaweb2':
ensure => present,
@ -39,26 +43,89 @@ class icingaweb2::config {
mode => $::icingaweb2::config_dir_mode;
"${::icingaweb2::config_dir}/authentication.ini":
ensure => present,
content => template("${::icingaweb2::template_auth}");
ensure => present;
"${::icingaweb2::config_dir}/config.ini":
ensure => present,
content => template("${::icingaweb2::template_config}");
ensure => present;
"${::icingaweb2::config_dir}/resources.ini":
ensure => present,
content => template("${::icingaweb2::template_resources}");
ensure => present;
"${::icingaweb2::config_dir}/roles.ini":
ensure => present,
content => template("${::icingaweb2::template_roles}");
ensure => present;
$::icingaweb2::web_root:
ensure => directory,
mode => $::icingaweb2::config_dir_mode;
}
# Configure authentication.ini settings
icingaweb2::config::authentication_database { 'Local Database Authenticaiton':
auth_section => 'icingaweb2',
auth_resource => "${::icingaweb2::auth_resource}",
}
# Configure config.ini settings
Ini_Setting {
ensure => present,
require => File["${::icingaweb2::config_dir}/config.ini"],
path => "${::icingaweb2::config_dir}/config.ini",
}
# Logging Configuration
ini_setting { 'icingaweb2 config logging method':
section => 'logging',
setting => 'log',
value => "\"${::icingaweb2::log_method}\"",
}
ini_setting { 'icingaweb2 config logging level':
section => 'logging',
setting => 'level',
value => "\"${::icingaweb2::log_level}\"",
}
ini_setting { 'icingaweb2 config logging application':
section => 'logging',
setting => 'application',
value => "\"${::icingaweb2::log_application}\"",
}
# Preferences Configuration
ini_setting { 'icingaweb2 config preferences store':
section => 'preferences',
setting => 'store',
value => "\"${::icingaweb2::log_store}\"",
}
ini_setting { 'icingaweb2 config preferences resource':
section => 'preferences',
setting => 'resource',
value => "\"${::icingaweb2::log_resource}\"",
}
# Configure resources.ini
icingaweb2::config::resource_database { 'icingaweb_db':
resource_db => "${::icingaweb2::web_db}",
resource_host => "${::icingaweb2::web_db_host}",
resource_port => "${::icingaweb2::web_db_port}",
resource_dbname => "${::icingaweb2::web_db_name}",
resource_username => "${::icingaweb2::web_db_user}",
resource_password => "${::icingaweb2::web_db_pass}",
}
icingaweb2::config::resource_database { 'icinga_ido':
resource_db => "${::icingaweb2::ido_db}",
resource_host => "${::icingaweb2::ido_db_host}",
resource_port => "${::icingaweb2::ido_db_port}",
resource_dbname => "${::icingaweb2::ido_db_name}",
resource_username => "${::icingaweb2::ido_db_user}",
resource_password => "${::icingaweb2::ido_db_pass}",
}
# Configure roles.ini
icingaweb2::config::roles { 'Admins':
role_name => "${::icingaweb2::admin_users}",
role_permissions => "${::icingaweb2::admin_permissions}",
}
if $::icingaweb2::manage_apache_vhost {
::apache::custom_config { 'icingaweb2':
content => template("${::icingaweb2::template_apache}"),

View file

@ -0,0 +1,25 @@
# Define for setting IcingaWeb2 Authentication
define icingaweb2::config::authentication_database (
$auth_section = undef,
$auth_resource = undef,
) {
Ini_Setting {
ensure => present,
require => File["${::icingaweb2::config_dir}/authentication.ini"],
path => "${::icingaweb2::config_dir}/authentication.ini",
}
ini_setting { "icingaweb2 authentication ${title} resource":
section => "$auth_section",
setting => 'resource',
value => "\"$auth_resource\"",
}
ini_setting { "icingaweb2 authentication ${title} backend":
section => "$auth_section",
setting => 'backend',
value => '"db"',
}
}

View file

@ -0,0 +1,25 @@
# Define for setting IcingaWeb2 Authentication
define icingaweb2::config::authentication_external (
$auth_section = undef,
$auth_filter = undef,
) {
Ini_Setting {
ensure => present,
require => File["${::icingaweb2::config_dir}/authentication.ini"],
path => "${::icingaweb2::config_dir}/authentication.ini",
}
ini_setting { "icingaweb2 authentication ${title} filter":
section => "$auth_section",
setting => 'strip_username_regexp',
value => "\"$auth_filter\"",
}
ini_setting { "icingaweb2 authentication ${title} backend":
section => "$auth_section",
setting => 'backend',
value => '"external"',
}
}

View file

@ -0,0 +1,60 @@
# Define for setting IcingaWeb2 Database Resource
define icingaweb2::config::resource_database (
$resource_name = $title,
$resource_db = undef,
$resource_host = undef,
$resource_port = undef,
$resource_dbname = undef,
$resource_username = undef,
$resource_password = undef,
) {
Ini_Setting {
ensure => present,
require => File["${::icingaweb2::config_dir}/resources.ini"],
path => "${::icingaweb2::config_dir}/resources.ini",
}
ini_setting { "icingaweb2 resources ${title} type":
section => $resource_name,
setting => 'type',
value => 'db',
}
ini_setting { "icingaweb2 resources ${title} db":
section => $resource_name,
setting => 'db',
value => "\"${resource_db}\"",
}
ini_setting { "icingaweb2 resources ${title} host":
section => $resource_name,
setting => 'host',
value => "\"${resource_host}\"",
}
ini_setting { "icingaweb2 resources ${title} port":
section => $resource_name,
setting => 'port',
value => "\"${resource_port}\"",
}
ini_setting { "icingaweb2 resources ${title} dbname":
section => $resource_name,
setting => 'dbname',
value => "\"${resource_dbname}\"",
}
ini_setting { "icingaweb2 resources ${title} username":
section => $resource_name,
setting => 'username',
value => "\"${resource_username}\"",
}
ini_setting { "icingaweb2 resources ${title} password":
section => $resource_name,
setting => 'password',
value => "\"${resource_password}\"",
}
}

View file

@ -0,0 +1,32 @@
# Define for setting IcingaWeb2 File Resource
define icingaweb2::config::resource_file (
$resource_name = $title,
$resource_filepath = undef,
$resource_pattern = undef,
) {
Ini_Setting {
ensure => present,
require => File["${::icingaweb2::config_dir}/resources.ini"],
path => "${::icingaweb2::config_dir}/resources.ini",
}
ini_setting { "icingaweb2 resources ${title} type":
section => $resource_name,
setting => 'type',
value => 'file',
}
ini_setting { "icingaweb2 resources ${title} filepath":
section => $resource_name,
setting => 'filename',
value => "\"${resource_filepath}\"",
}
ini_setting { "icingaweb2 resources ${title} fields":
section => $resource_name,
setting => 'fields',
value => "\"${resource_pattern}\"",
}
}

View file

@ -0,0 +1,53 @@
# Define for setting IcingaWeb2 LDAP Resource
define icingaweb2::config::resource_ldap (
$resource_name = $title,
$resource_host = undef,
$resource_port = undef,
$resource_root_dn = undef,
$resource_bind_dn = undef,
$resource_bind_pw = undef,
) {
Ini_Setting {
ensure => present,
require => File["${::icingaweb2::config_dir}/resources.ini"],
path => "${::icingaweb2::config_dir}/resources.ini",
}
ini_setting { "icingaweb2 resources ${title} type":
section => $resource_name,
setting => 'type',
value => 'ldap',
}
ini_setting { "icingaweb2 resources ${title} hostname":
section => $resource_name,
setting => 'hostname',
value => "\"${resource_hostname}\"",
}
ini_setting { "icingaweb2 resources ${title} port":
section => $resource_name,
setting => 'port',
value => "\"${resource_port}\"",
}
ini_setting { "icingaweb2 resources ${title} root_dn":
section => $resource_name,
setting => 'root_dn',
value => "\"${resource_root_dn}\"",
}
ini_setting { "icingaweb2 resources ${title} bind_dn":
section => $resource_name,
setting => 'bind_dn',
value => "\"${resource_bind_dn}\"",
}
ini_setting { "icingaweb2 resources ${title} bind_pw":
section => $resource_name,
setting => 'bind_pw',
value => "\"${resource_bind_pw}\"",
}
}

View file

@ -0,0 +1,26 @@
# Define for setting IcingaWeb2 LiveStatus
define icingaweb2::config::resource_livestatus (
$resource_name = $title,
$resource_socket = undef,
) {
Ini_Setting {
ensure => present,
require => File["${::icingaweb2::config_dir}/resources.ini"],
path => "${::icingaweb2::config_dir}/resources.ini",
}
ini_setting { "icingaweb2 resources ${title} type":
section => $resource_name,
setting => 'type',
value => 'livestatus',
}
ini_setting { "icingaweb2 resources ${title} socket":
section => $resource_name,
setting => 'socket',
value => "\"${resource_socket}\"",
}
}

47
manifests/config/roles.pp Normal file
View file

@ -0,0 +1,47 @@
# Define for setting IcingaWeb2 Roles
define icingaweb2::config::roles (
$role_name = $title,
$role_users = undef,
$role_groups = undef,
$role_permissions = undef,
$role_host_filter = undef,
$role_service_filter = undef,
) {
Ini_Setting {
ensure => present,
require => File["${::icingaweb2::config_dir}/roles.ini"],
path => "${::icingaweb2::config_dir}/roles.ini",
}
ini_setting { "icingaweb2 roles ${title} users":
section => $role_name,
setting => 'users',
value => "\"${role_users}\"",
}
ini_setting { "icingaweb2 roles ${title} groups":
section => $role_name,
setting => 'groups',
value => "\"${role_groups}\"",
}
ini_setting { "icingaweb2 roles ${title} permissions":
section => $role_name,
setting => 'permissions',
value => "\"${role_permissions}\"",
}
ini_setting { "icingaweb2 roles ${title} host filter":
section => $role_name,
setting => 'monitoring/hosts/filter',
value => "\"${role_host_filter}\"",
}
ini_setting { "icingaweb2 roles ${title} service filter":
section => $role_name,
setting => 'monitoring/services/filter',
value => "\"${role_service_filter}\"",
}
}

View file

@ -1,7 +1,11 @@
# == Class icingaweb2::install
#
class icingaweb2::install {
assert_private()
if is_function_available('assert_private') {
assert_private()
} else {
private()
}
if $::icingaweb2::install_method == 'package' {
if $::icingaweb2::pkg_list {

View file

@ -45,7 +45,7 @@ class icingaweb2::params {
$config_dir = '/etc/icingaweb2'
$config_dir_mode = '0755'
$config_dir_recurse = false
$config_file_mode = '0644'
$config_file_mode = '0664'
$config_group = 'icingaweb2'
$config_user = 'icingaweb2'
$pkg_ensure = present

View file

@ -1,7 +1,11 @@
# == Class icingaweb2::preinstall
#
class icingaweb2::preinstall {
assert_private()
if is_function_available('assert_private') {
assert_private()
} else {
private()
}
if $::icingaweb2::manage_repo and $::icingaweb2::install_method == 'package' {
case $::operatingsystem {

View file

@ -3,7 +3,11 @@
define icingaweb2::preinstall::redhat(
$pkg_repo_version,
) {
assert_private()
if is_function_available('assert_private') {
assert_private()
} else {
private()
}
case $::operatingsystem {
'RedHat', 'CentOS', 'Scientific': {

View file

@ -65,7 +65,8 @@
}
],
"dependencies": [
{"name":"puppetlabs/stdlib","version_requirement":">= 4.0.0"},
{"name":"puppetlabs/stdlib","version_requirement":">= 4.4.0"},
{"name":"puppetlabs/inifile","version_requirement":">= 1.2.0"},
{"name":"puppetlabs/vcsrepo","version_requirement":">= 1.2.0"}
]
}

View file

@ -1,7 +0,0 @@
; WARNING: This host definition is automatically generated by Puppet.
; ANY MANUAL CHANGES TO IT WILL GET OVERWRITTEN!
[icingaweb2]
backend = "<%= @auth_backend %>"
resource = "<%= @auth_resource %>"

View file

@ -1,12 +0,0 @@
; WARNING: This host definition is automatically generated by Puppet.
; ANY MANUAL CHANGES TO IT WILL GET OVERWRITTEN!
[logging]
log = "<%= @log_method %>"
level = "<%= @log_level %>"
application = "<%= @log_application %>"
[preferences]
store = "<%= @log_store %>"
resource = "<%= @log_resource %>"

View file

@ -1,22 +0,0 @@
; WARNING: This host definition is automatically generated by Puppet.
; ANY MANUAL CHANGES TO IT WILL GET OVERWRITTEN!
[icingaweb_db]
type = "<%= @web_type %>"
db = "<%= @web_db %>"
host = "<%= @web_db_host %>"
port = "<%= @web_db_port %>"
dbname = "<%= @web_db_name %>"
username = "<%= @web_db_user %>"
password = "<%= @web_db_pass %>"
prefix = "<%= @web_db_prefix %>"
[icinga_ido]
type = "<%= @ido_type %>"
db = "<%= @ido_db %>"
host = "<%= @ido_db_host %>"
port = "<%= @ido_db_port %>"
dbname = "<%= @ido_db_name %>"
username = "<%= @ido_db_user %>"
password = "<%= @ido_db_pass %>"

View file

@ -1,7 +0,0 @@
; WARNING: This host definition is automatically generated by Puppet.
; ANY MANUAL CHANGES TO IT WILL GET OVERWRITTEN!
[admins]
users = "<%= @admin_users %>"
permissions = "<%= @admin_permissions %>"