Disable SMTP configuration if needed
If the user disables all notifications then the SMTP configuration is no more required in UI and there is no need to configure an email address for the Nagios contact. Fixes-bug: #1541458 Change-Id: I450fe4e5bd6cd0d2a5bfbd4575c4765ba573b6e6
This commit is contained in:
parent
a50ac05ca3
commit
2fb43d2935
@ -18,17 +18,29 @@ $env_id = hiera('deployment_id')
|
|||||||
|
|
||||||
$plugin = hiera('lma_infrastructure_alerting')
|
$plugin = hiera('lma_infrastructure_alerting')
|
||||||
$password = $plugin['nagios_password']
|
$password = $plugin['nagios_password']
|
||||||
$send_to = $plugin['send_to']
|
if $notify_warning == false and
|
||||||
$send_from = $plugin['send_from']
|
$notify_critical == false and
|
||||||
$smtp_host = $plugin['smtp_host']
|
$notify_unknown == false and
|
||||||
$smtp_auth = $plugin['smtp_auth']
|
$notify_recovery == false {
|
||||||
$smtp_user = $plugin['smtp_user']
|
|
||||||
$smtp_password = $plugin['smtp_password']
|
|
||||||
|
|
||||||
$notify_warning = $plugin['notify_warning']
|
$send_to = undef
|
||||||
$notify_critical = $plugin['notify_critical']
|
$send_from = undef
|
||||||
$notify_unknown = $plugin['notify_unknown']
|
$smtp_host = undef
|
||||||
$notify_recovery = $plugin['notify_recovery']
|
$smtp_auth = undef
|
||||||
|
$smtp_password = undef
|
||||||
|
} else {
|
||||||
|
$send_to = $plugin['send_to']
|
||||||
|
$send_from = $plugin['send_from']
|
||||||
|
$smtp_host = $plugin['smtp_host']
|
||||||
|
$smtp_auth = $plugin['smtp_auth']
|
||||||
|
$smtp_user = $plugin['smtp_user']
|
||||||
|
$smtp_password = $plugin['smtp_password']
|
||||||
|
|
||||||
|
$notify_warning = $plugin['notify_warning']
|
||||||
|
$notify_critical = $plugin['notify_critical']
|
||||||
|
$notify_unknown = $plugin['notify_unknown']
|
||||||
|
$notify_recovery = $plugin['notify_recovery']
|
||||||
|
}
|
||||||
|
|
||||||
$lma_collector = hiera_hash('lma_collector', {})
|
$lma_collector = hiera_hash('lma_collector', {})
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
class lma_infra_alerting::nagios::contact(
|
class lma_infra_alerting::nagios::contact(
|
||||||
$ensure = present,
|
$ensure = present,
|
||||||
$send_to = $lma_infra_alerting::params::nagios_contact_email,
|
$send_to = undef,
|
||||||
$notify_warning = true,
|
$notify_warning = true,
|
||||||
$notify_critical = true,
|
$notify_critical = true,
|
||||||
$notify_recovery = true,
|
$notify_recovery = true,
|
||||||
@ -35,8 +35,6 @@ class lma_infra_alerting::nagios::contact(
|
|||||||
|
|
||||||
) inherits lma_infra_alerting::params{
|
) inherits lma_infra_alerting::params{
|
||||||
|
|
||||||
validate_string($send_to)
|
|
||||||
|
|
||||||
nagios::contactgroup { $contact_groups:
|
nagios::contactgroup { $contact_groups:
|
||||||
ensure => $ensure,
|
ensure => $ensure,
|
||||||
prefix => $lma_infra_alerting::params::nagios_config_filename_prefix,
|
prefix => $lma_infra_alerting::params::nagios_config_filename_prefix,
|
||||||
@ -81,13 +79,19 @@ class lma_infra_alerting::nagios::contact(
|
|||||||
$_host_notify_options = join($host_notify_options, ',')
|
$_host_notify_options = join($host_notify_options, ',')
|
||||||
}
|
}
|
||||||
|
|
||||||
$alias = regsubst($send_to, '@', '_AT_')
|
if $send_to {
|
||||||
if is_array($contact_groups){
|
$alias = regsubst($send_to, '@', '_AT_')
|
||||||
$_contact_groups_string = join($contact_groups, '_')
|
if is_array($contact_groups){
|
||||||
}else{
|
$_contact_groups_string = join($contact_groups, '_')
|
||||||
|
}else{
|
||||||
|
$_contact_groups_string = $contact_groups
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$alias = 'noop'
|
||||||
$_contact_groups_string = $contact_groups
|
$_contact_groups_string = $contact_groups
|
||||||
}
|
}
|
||||||
$contact_name = "${_contact_groups_string}_${alias}"
|
$contact_name = "${_contact_groups_string}_${alias}"
|
||||||
|
|
||||||
nagios::contact { $contact_name:
|
nagios::contact { $contact_name:
|
||||||
ensure => $ensure,
|
ensure => $ensure,
|
||||||
prefix => $lma_infra_alerting::params::nagios_config_filename_prefix,
|
prefix => $lma_infra_alerting::params::nagios_config_filename_prefix,
|
||||||
|
@ -24,7 +24,6 @@ class lma_infra_alerting::params {
|
|||||||
$nagios_cmd_check_ssh = 'check_ssh'
|
$nagios_cmd_check_ssh = 'check_ssh'
|
||||||
|
|
||||||
$nagios_contactgroup = 'openstack'
|
$nagios_contactgroup = 'openstack'
|
||||||
$nagios_contact_email = 'root@localhost'
|
|
||||||
|
|
||||||
# All configuration files for nagios will be prepended with this prefix
|
# All configuration files for nagios will be prepended with this prefix
|
||||||
$nagios_config_filename_prefix = 'lma_'
|
$nagios_config_filename_prefix = 'lma_'
|
||||||
|
@ -9,37 +9,66 @@ attributes:
|
|||||||
source: '\S'
|
source: '\S'
|
||||||
error: "Invalid value"
|
error: "Invalid value"
|
||||||
|
|
||||||
|
notify_critical:
|
||||||
|
type: "checkbox"
|
||||||
|
weight: 43
|
||||||
|
value: true
|
||||||
|
label: "Receive CRITICAL notifications by email"
|
||||||
|
|
||||||
|
notify_warning:
|
||||||
|
type: "checkbox"
|
||||||
|
weight: 44
|
||||||
|
value: true
|
||||||
|
label: "Receive WARNING notifications by email"
|
||||||
|
|
||||||
|
notify_unknown:
|
||||||
|
type: "checkbox"
|
||||||
|
weight: 45
|
||||||
|
value: true
|
||||||
|
label: "Receive UNKNOWN notifications by email"
|
||||||
|
|
||||||
|
notify_recovery:
|
||||||
|
type: "checkbox"
|
||||||
|
weight: 46
|
||||||
|
value: true
|
||||||
|
label: "Receive RECOVERY notifications by email"
|
||||||
|
|
||||||
send_to:
|
send_to:
|
||||||
value: ''
|
value: ''
|
||||||
label: 'The recipient email address'
|
label: 'The recipient email address'
|
||||||
description: 'The recipient for the alert notifications'
|
description: 'The recipient for the alert notifications'
|
||||||
weight: 43
|
weight: 47
|
||||||
type: "text"
|
type: "text"
|
||||||
regex: &email
|
regex: &email
|
||||||
source: '[a-z0-9!#$%&*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.?)?[a-z0-9]?(?:[a-z0-9-]*[a-z0-9])?'
|
source: '[a-z0-9!#$%&*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.?)?[a-z0-9]?(?:[a-z0-9-]*[a-z0-9])?'
|
||||||
error: "Invalid Email"
|
error: "Invalid Email"
|
||||||
|
restrictions: &disable_notifications
|
||||||
|
- condition: "settings:lma_infrastructure_alerting.notify_critical.value == false and settings:lma_infrastructure_alerting.notify_warning.value == false and settings:lma_infrastructure_alerting.notify_unknown.value == false and settings:lma_infrastructure_alerting.notify_recovery.value == false"
|
||||||
|
action: "disable"
|
||||||
|
|
||||||
send_from:
|
send_from:
|
||||||
value: ''
|
value: ''
|
||||||
label: 'The sender email address'
|
label: 'The sender email address'
|
||||||
description: ''
|
description: ''
|
||||||
weight: 44
|
weight: 48
|
||||||
type: "text"
|
type: "text"
|
||||||
regex: *email
|
regex: *email
|
||||||
|
restrictions: *disable_notifications
|
||||||
|
|
||||||
smtp_host:
|
smtp_host:
|
||||||
value: ''
|
value: ''
|
||||||
label: 'SMTP server IP and port'
|
label: 'SMTP server IP and port'
|
||||||
description: 'ie: 10.2.2.3:25'
|
description: 'ie: 10.2.2.3:25'
|
||||||
weight: 45
|
weight: 49
|
||||||
type: "text"
|
type: "text"
|
||||||
regex:
|
regex:
|
||||||
source: '^[a-zA-Z\d][a-zA-Z\d_\-.]+(:[0-9]+)?$'
|
source: '^[a-zA-Z\d][a-zA-Z\d_\-.]+(:[0-9]+)?$'
|
||||||
error: 'Invalid address or name'
|
error: 'Invalid address or name'
|
||||||
|
restrictions: *disable_notifications
|
||||||
|
|
||||||
smtp_auth:
|
smtp_auth:
|
||||||
type: "radio"
|
type: "radio"
|
||||||
weight: 47
|
weight: 50
|
||||||
value: "none"
|
value: "none"
|
||||||
label: "SMTP authentication method"
|
label: "SMTP authentication method"
|
||||||
values:
|
values:
|
||||||
@ -51,45 +80,24 @@ attributes:
|
|||||||
label: "Plain"
|
label: "Plain"
|
||||||
- data: "cram-md5"
|
- data: "cram-md5"
|
||||||
label: "CRAMMD5"
|
label: "CRAMMD5"
|
||||||
|
restrictions: *disable_notifications
|
||||||
|
|
||||||
smtp_user:
|
smtp_user:
|
||||||
value: ''
|
value: ''
|
||||||
label: 'SMTP user'
|
label: 'SMTP user'
|
||||||
description: ''
|
description: ''
|
||||||
weight: 48
|
weight: 51
|
||||||
type: "text"
|
type: "text"
|
||||||
restrictions: &no_auth
|
restrictions: &no_auth
|
||||||
- condition: "settings:lma_infrastructure_alerting.smtp_auth.value == 'none'"
|
- condition: "settings:lma_infrastructure_alerting.smtp_auth.value == 'none'"
|
||||||
action: "disable"
|
action: "disable"
|
||||||
|
- condition: "settings:lma_infrastructure_alerting.notify_critical.value == false and settings:lma_infrastructure_alerting.notify_warning.value == false and settings:lma_infrastructure_alerting.notify_unknown.value == false and settings:lma_infrastructure_alerting.notify_recovery.value == false"
|
||||||
|
action: "disable"
|
||||||
|
|
||||||
smtp_password:
|
smtp_password:
|
||||||
value: ''
|
value: ''
|
||||||
label: 'SMTP password'
|
label: 'SMTP password'
|
||||||
description: ''
|
description: ''
|
||||||
weight: 49
|
weight: 52
|
||||||
type: "password"
|
type: "password"
|
||||||
restrictions: *no_auth
|
restrictions: *no_auth
|
||||||
|
|
||||||
notify_critical:
|
|
||||||
type: "checkbox"
|
|
||||||
weight: 50
|
|
||||||
value: true
|
|
||||||
label: "Receive CRITICAL notifications by email"
|
|
||||||
|
|
||||||
notify_warning:
|
|
||||||
type: "checkbox"
|
|
||||||
weight: 51
|
|
||||||
value: true
|
|
||||||
label: "Receive WARNING notifications by email"
|
|
||||||
|
|
||||||
notify_unknown:
|
|
||||||
type: "checkbox"
|
|
||||||
weight: 52
|
|
||||||
value: true
|
|
||||||
label: "Receive UNKNOWN notifications by email"
|
|
||||||
|
|
||||||
notify_recovery:
|
|
||||||
type: "checkbox"
|
|
||||||
weight: 53
|
|
||||||
value: true
|
|
||||||
label: "Receive RECOVERY notifications by email"
|
|
||||||
|
Loading…
Reference in New Issue
Block a user