Remove hardcoded NTP server role names

NTP server roles can be overriden.

Change-Id: Ib75dd9e2d1baac6c23489ac5b365bb643728d737
DocImpact: New paratemer ntp_server_roles
Closes-bug: #1563465
(cherry picked from commit 776a17dd94)
This commit is contained in:
Kyrylo Galanov 2016-04-01 05:53:24 +02:00 committed by Stanislaw Bogatkin
parent 84f109e243
commit edf32ea9e9
2 changed files with 39 additions and 3 deletions

View File

@ -2,10 +2,11 @@ class osnailyfacter::ntp::ntp_client {
notice('MODULAR: ntp/ntp_client.pp')
$management_vrouter_vip = hiera('management_vrouter_vip')
$ntp_servers = hiera_array('ntp_servers', [$management_vrouter_vip])
$management_vrouter_vip = hiera('management_vrouter_vip')
$ntp_servers = hiera_array('ntp_servers', [$management_vrouter_vip])
$ntp_server_roles = hiera('ntp_server_roles', ['controller', 'primary-controller'])
if ! roles_include(['primary-controller', 'controller']) {
unless roles_include($ntp_server_roles) {
class { '::ntp':
servers => $ntp_servers,
service_ensure => 'running',

View File

@ -10,6 +10,41 @@ require 'shared-examples'
manifest = 'ntp/ntp-client.pp'
describe manifest do
shared_examples 'catalog' do
ntp_server_roles = Noop.hiera('ntp_server_roles', ['controller', 'primary-controller'])
is_ntp_server = Noop.puppet_function 'roles_include', ntp_server_roles
it 'should set up NTP' do
management_vrouter_vip = Noop.hiera('management_vrouter_vip')
servers = Noop.hiera('ntp_servers', management_vrouter_vip)
unless is_ntp_server
should contain_class('ntp').with(
:servers => servers,
:service_ensure => 'running',
:service_enable => 'true',
:disable_monitor => 'true',
:iburst_enable => 'true',
:tinker => 'true',
:panic => '0',
:stepout => '5',
:minpoll => '3',
)
end
end
it 'should override ntp service on Ubuntu' do
if facts[:operatingsystem] == 'Ubuntu'
should contain_tweaks__ubuntu_service_override('ntpd').with(
:package_name => 'ntp',
:service_name => 'ntp',
)
end
end
end
test_ubuntu_and_centos manifest
end