Skip to content

Commit

Permalink
add icingaweb2 api user
Browse files Browse the repository at this point in the history
  • Loading branch information
lbetz committed Apr 22, 2021
1 parent 6d5529a commit 74b109a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
9 changes: 5 additions & 4 deletions examples/mysql/standalone.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
}

class { '::icinga::server':
ca => true,
config_server => true,
global_zones => [ 'global-templates', 'linux-commands', 'windows-commands' ],
ca => true,
config_server => true,
global_zones => [ 'global-templates', 'linux-commands', 'windows-commands' ],
web_api_pass => 'icingaweb2',
}

class { '::icinga::ido':
Expand All @@ -23,5 +24,5 @@
db_host => 'localhost',
db_pass => 'icingaweb2',
manage_database => true,
api_pass => 'icingaweb2',
api_pass => $icinga::server::web_api_pass,
}
9 changes: 5 additions & 4 deletions examples/pgsql/standalone.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
}

class { '::icinga::server':
ca => true,
config_server => true,
global_zones => [ 'global-templates', 'linux-commands', 'windows-commands' ],
ca => true,
config_server => true,
global_zones => [ 'global-templates', 'linux-commands', 'windows-commands' ],
web_api_pass => 'icingaweb2',
}

class { '::icinga::ido':
Expand All @@ -23,5 +24,5 @@
db_host => 'localhost',
db_pass => 'icingaweb2',
manage_database => true,
api_pass => 'icingaweb2',
api_pass => $icinga::server::web_api_pass,
}
12 changes: 12 additions & 0 deletions manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
# @param [Optional[String]] ticket_salt
# Set an alternate ticket salt to icinga::ticket_salt from Hiera.
#
# @param [Optional[String]] web_api_pass
# Icinga API password for user icingaweb2.
#
class icinga::server(
Boolean $ca = false,
Boolean $config_server = false,
Expand All @@ -31,6 +34,7 @@
Array[String] $global_zones = [],
Optional[Stdlib::Host] $ca_server = undef,
Optional[String] $ticket_salt = undef,
Optional[String] $web_api_pass = undef,
) {

if empty($colocation_endpoints) {
Expand Down Expand Up @@ -77,4 +81,12 @@
}
}

if $_config_server {
::icinga2::object::apiuser { 'icingaweb2':
password => $web_api_pass,
permissions => [ 'status/query', 'actions/*', 'objects/modify/*', 'objects/query/*' ],
target => "/etc/icinga2/zones.d/${zone}/api-users.conf",
}
}

}
5 changes: 3 additions & 2 deletions manifests/web.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
String $db_name = 'icingaweb2',
String $db_user = 'icingaweb2',
Boolean $manage_database = false,
String $api_user = 'icingaweb2',
String $api_host = 'localhost',
Enum['mysql', 'pgsql'] $backend_db_type = 'mysql',
Stdlib::Host $backend_db_host = 'localhost',
Optional[Stdlib::Port::Unprivileged] $backend_db_port = undef,
Expand Down Expand Up @@ -198,7 +198,8 @@
commandtransports => {
'icinga2' => {
transport => 'api',
username => $api_user,
host => $api_host,
username => 'icingaweb2',
password => $api_pass,
}
},
Expand Down

0 comments on commit 74b109a

Please sign in to comment.