Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
puppet-icinga2_testing
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
15
Issues
15
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
testing
puppet-icinga2_testing
Commits
47c6f16e
Commit
47c6f16e
authored
Jan 04, 2017
by
Markus Frosch
📣
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
master/icinga2/selftest: Replace icinga2 with the rewritten module
parent
90bc9e6f
Pipeline
#201
failed with stage
in 2 minutes and 26 seconds
Changes
10
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
49 additions
and
144 deletions
+49
-144
manifests/helpers/icinga2/ido_mysql.pp
manifests/helpers/icinga2/ido_mysql.pp
+0
-58
manifests/helpers/icinga2/ido_pgsql.pp
manifests/helpers/icinga2/ido_pgsql.pp
+0
-58
manifests/profiles/icinga2.pp
manifests/profiles/icinga2.pp
+2
-18
manifests/profiles/selftest.pp
manifests/profiles/selftest.pp
+2
-1
manifests/roles/autorole.pp
manifests/roles/autorole.pp
+3
-2
manifests/roles/master.pp
manifests/roles/master.pp
+2
-2
templates/selftest/hosts.conf.erb
templates/selftest/hosts.conf.erb
+6
-3
templates/selftest/services.conf.erb
templates/selftest/services.conf.erb
+2
-2
templates/selftest/templates.conf.erb
templates/selftest/templates.conf.erb
+3
-0
templates/selftest/test_services.conf.erb
templates/selftest/test_services.conf.erb
+29
-0
No files found.
manifests/helpers/icinga2/ido_mysql.pp
deleted
100644 → 0
View file @
90bc9e6f
class
icinga2_testing::helpers::icinga2::ido_mysql
(
$ido_dbname
=
$::icinga2::feature::ido_mysql::database
,
$ido_username
=
$::icinga2::feature::ido_mysql::user
,
$ido_password
=
$::icinga2::feature::ido_mysql::password
,
)
inherits
::
icinga2::feature::ido_mysql
# lint:ignore:inherits_across_namespaces
{
# Install schema
if
$::osfamily
==
'Debian'
{
$_schema_create
=
'/usr/share/dbconfig-common/data/icinga2-ido-mysql/install/mysql'
}
elsif
$::osfamily
==
'Redhat'
{
$_schema_create
=
'/usr/share/icinga2-ido-mysql/schema/mysql.sql'
}
else
{
fail
(
"Schema creating not supported on
${::operatingsystem}
(
${::osfamily}
)"
)
}
$_mysql
=
"mysql -B -u '
${ido_username}
' '
${ido_dbname}
'"
Package
[
'icinga2-ido-mysql'
]
->
exec
{
'import icinga2 mysql schema'
:
user
=>
'root'
,
path
=>
$::path
,
command
=>
"
${_mysql}
< '
${_schema_create}
'"
,
unless
=>
"
${_mysql}
--execute='SELECT version FROM icinga_dbversion;'"
,
environment
=>
[
"MYSQL_PWD=
${ido_password}
"
,
],
}
~>
Class
[
'::icinga2::service'
]
unless
defined
(
File
[
'icinga2-schema-upgrade'
])
{
file
{
'icinga2-schema-upgrade'
:
ensure
=>
file
,
owner
=>
'root'
,
group
=>
'root'
,
mode
=>
'0755'
,
path
=>
'/usr/local/bin/icinga2-schema-upgrade'
,
content
=>
file
(
'icinga2_testing/icinga2-schema-upgrade'
),
}
}
exec
{
'icinga2-schema-upgrade-mysql'
:
path
=>
$::path
,
environment
=>
[
"IDO_DATABASE=
${ido_dbname}
"
,
"IDO_USERNAME=
${ido_username}
"
,
"IDO_PASSWORD=
${ido_password}
"
,
],
logoutput
=>
true
,
command
=>
'/usr/local/bin/icinga2-schema-upgrade'
,
onlyif
=>
'/usr/local/bin/icinga2-schema-upgrade --check'
,
notify
=>
Class
[
'::icinga2::service'
],
require
=>
[
Exec
[
'import icinga2 mysql schema'
],
File
[
'icinga2-schema-upgrade'
],
],
}
}
manifests/helpers/icinga2/ido_pgsql.pp
deleted
100644 → 0
View file @
90bc9e6f
class
icinga2_testing::helpers::icinga2::ido_pgsql
(
$ido_dbname
=
$::icinga2::feature::ido_pgsql::database
,
$ido_username
=
$::icinga2::feature::ido_pgsql::user
,
$ido_password
=
$::icinga2::feature::ido_pgsql::password
,
)
inherits
::
icinga2::feature::ido_pgsql
# lint:ignore:inherits_across_namespaces
{
# Install schema
if
$::osfamily
==
'Debian'
{
$_schema_create
=
'/usr/share/dbconfig-common/data/icinga2-ido-pgsql/install/pgsql'
}
elsif
$::osfamily
==
'Redhat'
{
$_schema_create
=
'/usr/share/icinga2-ido-pgsql/schema/pgsql.sql'
}
else
{
fail
(
"Schema creating not supported on
${::operatingsystem}
(
${::osfamily}
)"
)
}
$_psql
=
"psql -U '
${ido_username}
' -h '
${icinga2::feature::ido_pgsql::host}
' -d '
${ido_dbname}
'"
Package
[
'icinga2-ido-pgsql'
]
->
exec
{
'import icinga2 pgsql schema'
:
user
=>
'root'
,
path
=>
$::path
,
command
=>
"
${_psql}
< '
${_schema_create}
'"
,
unless
=>
"
${_psql}
-c 'SELECT version FROM icinga_dbversion'"
,
environment
=>
[
"PGPASSWORD=
${ido_password}
"
,
],
}
~>
Class
[
'::icinga2::service'
]
unless
defined
(
File
[
'icinga2-schema-upgrade'
])
{
file
{
'icinga2-schema-upgrade'
:
ensure
=>
file
,
owner
=>
'root'
,
group
=>
'root'
,
mode
=>
'0755'
,
path
=>
'/usr/local/bin/icinga2-schema-upgrade'
,
content
=>
file
(
'icinga2_testing/icinga2-schema-upgrade'
),
}
}
exec
{
'icinga2-schema-upgrade-pgsql'
:
path
=>
$::path
,
environment
=>
[
"IDO_DATABASE=
${ido_dbname}
"
,
"IDO_USERNAME=
${ido_username}
"
,
"IDO_PASSWORD=
${ido_password}
"
,
],
logoutput
=>
true
,
command
=>
'/usr/local/bin/icinga2-schema-upgrade'
,
onlyif
=>
'/usr/local/bin/icinga2-schema-upgrade --check'
,
notify
=>
Class
[
'::icinga2::service'
],
require
=>
[
Exec
[
'import icinga2 pgsql schema'
],
File
[
'icinga2-schema-upgrade'
],
],
}
}
manifests/profiles/icinga2.pp
View file @
47c6f16e
class
icinga2_testing::profiles::icinga2
{
class
{
'::icinga2'
:
manage_repos
=>
false
,
manage_database
=>
false
,
purge_confd
=>
true
,
}
include
::icinga2::objects
contain
::
icinga2
contain
::
icinga2::feature::command
contain
::
icinga2::pki::puppet
Class
[
'icinga2::pki::puppet'
]
~>
Class
[
'icinga2::service'
]
# setup API connections
class
{
'::icinga2::feature::api'
:
accept_commands
=>
true
,
accept_config
=>
true
,
manage_zone
=>
false
,
}
contain
::
icinga2::feature::api
contain
::
icinga2_notificationtest
}
\ No newline at end of file
manifests/profiles/selftest.pp
View file @
47c6f16e
...
...
@@ -20,7 +20,8 @@ class icinga2_testing::profiles::selftest (
ensure_resource
(
file
,
$zone_dir
,
{
ensure
=>
directory
})
ensure_resource
(
file
,
$global_zone
,
{
ensure
=>
directory
})
$_zones
=
hiera_hash
(
'icinga2::object::zone'
)
$_zones
=
hiera_hash
(
'icinga2::feature::api::zones'
)
$_endpoints
=
hiera_hash
(
'icinga2::feature::api::endpoints'
)
file
{
$config_base
:
ensure
=>
directory
,
...
...
manifests/roles/autorole.pp
View file @
47c6f16e
...
...
@@ -8,8 +8,9 @@ class icinga2_testing::roles::autorole
notice
(
"Running autorole in instance=
${::icingatest_instance}
- role=
${::icingatest_role}
- hostno=
${::icingatest_hostno}
"
)
# check config that has to be present in hiera
$zones_config
=
hiera
(
'icinga2::object::zone'
)
$repo_version
=
hiera
(
'icinga2_testing::profiles::repository::version'
)
$_UNUSED_endpoint_config
=
hiera
(
'icinga2::feature::api::endpoints'
)
$_UNUSED_zones_config
=
hiera
(
'icinga2::feature::api::zones'
)
$_UNUSED_repo_version
=
hiera
(
'icinga2_testing::profiles::repository::version'
)
if
$::icingatest_role
==
'master'
{
validate_integer
(
$::icingatest_hostno
)
...
...
manifests/roles/master.pp
View file @
47c6f16e
...
...
@@ -8,10 +8,10 @@ class icinga2_testing::roles::master(
contain
::
icinga2_testing::profiles::repository
contain
"::icinga2_testing::profiles::
${database}
"
Class
[
"::icinga2_testing::profiles::
${database}
"
]
->
Class
[
"::icinga2
_testing::helpers::icinga2::ido_
${database}
"
]
Class
[
"::icinga2_testing::profiles::
${database}
"
]
->
Class
[
"::icinga2
::feature::ido
${database}
"
]
contain
::
icinga2_testing::profiles::icinga2
contain
"::icinga2
_testing::helpers::icinga2::ido_
${database}
"
contain
"::icinga2
::feature::ido
${database}
"
contain
::
icinga2_testing::profiles::icingaweb2
...
...
templates/selftest/hosts.conf.erb
View file @
47c6f16e
...
...
@@ -10,13 +10,16 @@
# Zone
<%=
zone
%>
#######################################
<%
zone_hash
[
'endpoints'
].
each
do
|
host
,
details
|
-%>
<%-
zone_hash
[
'endpoints'
].
each
do
|
host
|
details
=
@_endpoints
[
host
]
-%>
object Host "
<%=
host
%>
" {
import "generic-host"
address =
<%=
scope
.
function_icinga2_config_value
([
details
[
'host'
]])
%>
address =
<%=
details
[
'host'
].
dump
%>
vars.zone =
<%=
scope
.
function_icinga2_config_value
([
zone
])
%>
vars.zone =
<%=
zone
.
dump
%>
vars.role = "icinga"
<%-
# NOTE: We are assuming all hosts are the same!
-%>
...
...
templates/selftest/services.conf.erb
View file @
47c6f16e
...
...
@@ -67,10 +67,10 @@ apply Service "icinga cluster zone <%= zone %>" {
check_command = "cluster-zone"
vars.cluster_zone =
<%=
scope
.
function_icinga2_config_value
([
zone
])
%>
vars.cluster_zone =
<%=
zone
.
dump
%>
assign where host.vars.role == "icinga"
ignore where host.vars.zone ==
<%=
scope
.
function_icinga2_config_value
([
zone
])
%>
ignore where host.vars.zone ==
<%=
zone
.
dump
%>
}
<%
end
-%>
...
...
templates/selftest/templates.conf.erb
View file @
47c6f16e
...
...
@@ -8,6 +8,9 @@ template Host "generic-host" {
check_interval = 1m
retry_interval = 30s
enable_flapping = true
flapping_threshold = 60.0
check_command = "hostalive4"
}
...
...
templates/selftest/test_services.conf.erb
View file @
47c6f16e
...
...
@@ -11,6 +11,7 @@ apply Service "test-ok" {
vars.dummy_text = "This check is always OK."
vars.dummy_state = 0
vars.type = "test"
vars.notification = "test"
assign where host.vars.test_type == "simple"
...
...
@@ -24,6 +25,7 @@ apply Service "test-warning" {
vars.dummy_text = "This check is always WARNING."
vars.dummy_state = 1
vars.type = "test"
vars.notification = "test"
assign where host.vars.test_type == "simple"
...
...
@@ -37,6 +39,7 @@ apply Service "test-critical" {
vars.dummy_text = "This check is always CRITICAL."
vars.dummy_state = 2
vars.type = "test"
vars.notification = "test"
assign where host.vars.test_type == "simple"
...
...
@@ -50,6 +53,7 @@ apply Service "test-unknown" {
vars.dummy_text = "This check is always UNKNOWN."
vars.dummy_state = 3
vars.type = "test"
vars.notification = "test"
assign where host.vars.test_type == "simple"
...
...
@@ -60,6 +64,7 @@ apply Service "test-random" {
check_command = "random"
vars.type = "test"
vars.notification = "test"
assign where host.vars.test_type == "simple"
...
...
@@ -71,7 +76,31 @@ apply Service "test-random-hard" {
check_command = "random"
max_check_attempts = 1
vars.type = "test"
vars.notification = "test"
assign where host.vars.test_type == "simple"
}
apply Service "test-random-hard-expectation" {
import "generic-service"
check_command = "dummy"
max_check_attempts = 1
var dyn_output = "UNKNOWN: ??"
vars.dummy_text = function() use(dyn_output) { return dyn_output }
vars.dummy_state = function() use(dyn_output) {
var test = get_service(host.name, "test-random-hard").last_check_result
// service.vars.dummy_state = test.state
dyn_output = test.state + " " + test.output
return 3
}
vars.type = "expectation"
assign where host.vars.test_type == "simple"
}
Markus Frosch
📣
@mfrosch
mentioned in issue
#15 (closed)
·
Jan 09, 2017
mentioned in issue
#15 (closed)
mentioned in issue #15
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment