Modify the cron job to use specific version of the plugin
This patch modifies the cron job used to update the nagios configuration to solve a bug that occurs when several version of the plugin are available. This happens after an upgrade procedure. Change-Id: I41831e43707e7ca5e88fd0a329508ad4813d26bb Closes-Bug: #1622628
This commit is contained in:
parent
9b4e403327
commit
bccb10031c
|
@ -19,6 +19,7 @@ $env_id = hiera('deployment_id')
|
||||||
$fuel_version = 0 + hiera('fuel_version')
|
$fuel_version = 0 + hiera('fuel_version')
|
||||||
|
|
||||||
$plugin = hiera('lma_infrastructure_alerting')
|
$plugin = hiera('lma_infrastructure_alerting')
|
||||||
|
$plugin_version = $plugin['metadata']['plugin_version']
|
||||||
$nagios_authnz = hiera('lma::infrastructure_alerting::authnz')
|
$nagios_authnz = hiera('lma::infrastructure_alerting::authnz')
|
||||||
$password = $nagios_authnz['password']
|
$password = $nagios_authnz['password']
|
||||||
if $notify_warning == false and
|
if $notify_warning == false and
|
||||||
|
@ -92,6 +93,7 @@ class { 'lma_infra_alerting::nagios':
|
||||||
ldap_authorization_enabled => $nagios_authnz['ldap_authorization_enabled'],
|
ldap_authorization_enabled => $nagios_authnz['ldap_authorization_enabled'],
|
||||||
ldap_group_attribute => $nagios_authnz['ldap_group_attribute'],
|
ldap_group_attribute => $nagios_authnz['ldap_group_attribute'],
|
||||||
ldap_admin_group_dn => $nagios_authnz['ldap_admin_group_dn'],
|
ldap_admin_group_dn => $nagios_authnz['ldap_admin_group_dn'],
|
||||||
|
plugin_version => $plugin_version,
|
||||||
notify => Service['apache2-nagios'],
|
notify => Service['apache2-nagios'],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,26 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo "The name of the plugin is empty"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$2" ]; then
|
||||||
|
echo "The version of the plugin is empty"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
PLUGIN_NAME=$1
|
PLUGIN_NAME=$1
|
||||||
|
PLUGIN_VERSION=$2
|
||||||
|
PLUGIN_MAJOR=$(echo "$PLUGIN_VERSION" | cut -d. -f1)
|
||||||
|
PLUGIN_MINOR=$(echo "$PLUGIN_VERSION" | cut -d. -f2)
|
||||||
|
|
||||||
MANIFEST=nagios.pp
|
MANIFEST=nagios.pp
|
||||||
CONFIG_DIR=/etc/nagios3/conf.d
|
CONFIG_DIR=/etc/nagios3/conf.d
|
||||||
PREFIX_FILENAMES=lma_
|
PREFIX_FILENAMES=lma_
|
||||||
EXTENSION_FILENAMES=.cfg
|
EXTENSION_FILENAMES=.cfg
|
||||||
PUPPET=$(which puppet)
|
PUPPET=$(which puppet)
|
||||||
PLUGIN_PUPPET_DIR=$(ls -d /etc/fuel/plugins/"$PLUGIN_NAME"*/puppet)
|
PLUGIN_PUPPET_DIR=$(ls -d /etc/fuel/plugins/"$PLUGIN_NAME-$PLUGIN_MAJOR.$PLUGIN_MINOR"/puppet)
|
||||||
LAST_CHECK=/var/cache/lma_last_astute_yaml.md5sum
|
LAST_CHECK=/var/cache/lma_last_astute_yaml.md5sum
|
||||||
LAST_CHECK_NODES=/var/cache/lma_last_nodes_yaml.md5sum
|
LAST_CHECK_NODES=/var/cache/lma_last_nodes_yaml.md5sum
|
||||||
CURRENT_CHECK=/var/cache/lma_current_astute_yaml.md5sum
|
CURRENT_CHECK=/var/cache/lma_current_astute_yaml.md5sum
|
||||||
|
|
|
@ -40,6 +40,7 @@ class lma_infra_alerting::nagios (
|
||||||
$ldap_group_attribute = undef,
|
$ldap_group_attribute = undef,
|
||||||
$ldap_admin_group_dn = undef,
|
$ldap_admin_group_dn = undef,
|
||||||
$httpd_dir = '/etc/apache2',
|
$httpd_dir = '/etc/apache2',
|
||||||
|
$plugin_version = undef,
|
||||||
) inherits lma_infra_alerting::params {
|
) inherits lma_infra_alerting::params {
|
||||||
|
|
||||||
include nagios::params
|
include nagios::params
|
||||||
|
@ -104,7 +105,7 @@ class lma_infra_alerting::nagios (
|
||||||
$prefix = $lma_infra_alerting::params::nagios_config_filename_prefix
|
$prefix = $lma_infra_alerting::params::nagios_config_filename_prefix
|
||||||
cron { 'update lma infra alerting':
|
cron { 'update lma infra alerting':
|
||||||
ensure => present,
|
ensure => present,
|
||||||
command => "/usr/bin/flock -n /tmp/lma.lock -c \"${cron_bin} lma_infrastructure_alerting\"",
|
command => "/usr/bin/flock -n /tmp/lma.lock -c \"${cron_bin} lma_infrastructure_alerting ${plugin_version}\"",
|
||||||
minute => '*',
|
minute => '*',
|
||||||
hour => '*',
|
hour => '*',
|
||||||
month => '*',
|
month => '*',
|
||||||
|
|
|
@ -24,12 +24,14 @@ describe 'lma_infra_alerting::nagios' do
|
||||||
let(:params) do
|
let(:params) do
|
||||||
{:http_password => 'foo', :http_port => '999',
|
{:http_password => 'foo', :http_port => '999',
|
||||||
:nagios_ui_address => '1.1.1.1',
|
:nagios_ui_address => '1.1.1.1',
|
||||||
:nagios_address => '2.3.3.3'
|
:nagios_address => '2.3.3.3',
|
||||||
|
:plugin_version => '1.2.3',
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
it { should contain_class('nagios') }
|
it { should contain_class('nagios') }
|
||||||
it { should create_class('nagios::cgi') }
|
it { should create_class('nagios::cgi') }
|
||||||
it { should create_cron('update lma infra alerting') }
|
it { should create_cron('update lma infra alerting').
|
||||||
|
with_command("/usr/bin/flock -n /tmp/lma.lock -c \"/usr/local/bin/update-lma-configuration lma_infrastructure_alerting 1.2.3\"") }
|
||||||
it { should create_file('/usr/local/bin/update-lma-configuration') }
|
it { should create_file('/usr/local/bin/update-lma-configuration') }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue