Add memcached_addresses variable to hiera

Introduce new variable to have an ability for easy override memcache servers
addresses.

Closes-Bug: #1524275
Change-Id: I96c8e38e6be2fa865c870908cbbaf0d95034a952
This commit is contained in:
Stanislaw Bogatkin 2015-12-09 16:12:01 +03:00
parent 9dd5dbdf9c
commit a0792cfc77
14 changed files with 183 additions and 62 deletions

View File

@ -338,6 +338,15 @@ if $public_ssl_hash['services'] {
$nova_hash['vncproxy_protocol'] = 'http' $nova_hash['vncproxy_protocol'] = 'http'
} }
# Define how we should get memcache addresses
if hiera('memcached_addresses', false) {
# need this to successful lookup from template
$memcached_addresses = hiera('memcached_addresses')
} else {
$memcache_nodes = get_nodes_hash_by_roles(hiera_hash('network_metadata'), $memcache_roles)
$memcached_addresses = ipsort(values(get_node_to_ipaddr_map_by_network_role($memcache_nodes, 'mgmt/memcache')))
}
# save all these global variables into hiera yaml file for later use # save all these global variables into hiera yaml file for later use
# by other manifests with hiera function # by other manifests with hiera function
file { $globals_yaml_file : file { $globals_yaml_file :

View File

@ -3,8 +3,7 @@ notice('MODULAR: horizon.pp')
prepare_network_config(hiera('network_scheme', {})) prepare_network_config(hiera('network_scheme', {}))
$horizon_hash = hiera_hash('horizon', {}) $horizon_hash = hiera_hash('horizon', {})
$service_endpoint = hiera('service_endpoint') $service_endpoint = hiera('service_endpoint')
$memcache_nodes = get_nodes_hash_by_roles(hiera_hash('network_metadata'), hiera('memcache_roles')) $memcached_server = hiera('memcached_addresses')
$memcache_address_map = get_node_to_ipaddr_map_by_network_role($memcache_nodes, 'mgmt/memcache')
$bind_address = get_network_role_property('horizon', 'ipaddr') $bind_address = get_network_role_property('horizon', 'ipaddr')
$neutron_advanced_config = hiera_hash('neutron_advanced_configuration', {}) $neutron_advanced_config = hiera_hash('neutron_advanced_configuration', {})
$public_ssl = hiera('public_ssl') $public_ssl = hiera('public_ssl')
@ -30,7 +29,7 @@ $hypervisor_options = {'enable_quotas' => hiera('nova_quota')}
class { 'openstack::horizon': class { 'openstack::horizon':
secret_key => $secret_key, secret_key => $secret_key,
cache_server_ip => ipsort(values($memcache_address_map)), cache_server_ip => $memcached_server,
package_ensure => hiera('horizon_package_ensure', 'installed'), package_ensure => hiera('horizon_package_ensure', 'installed'),
bind_address => $bind_address, bind_address => $bind_address,
cache_server_port => hiera('memcache_server_port', '11211'), cache_server_port => hiera('memcache_server_port', '11211'),

View File

@ -55,10 +55,9 @@ $public_cert = $public_ssl_hash['services']? {
$admin_address = $service_endpoint $admin_address = $service_endpoint
$local_address_for_bind = get_network_role_property('keystone/api', 'ipaddr') $local_address_for_bind = get_network_role_property('keystone/api', 'ipaddr')
$memcache_server_port = hiera('memcache_server_port', '11211') $memcache_server_port = hiera('memcache_server_port', '11211')
$memcache_pool_maxsize = '100' $memcache_pool_maxsize = '100'
$memcache_nodes = get_nodes_hash_by_roles(hiera_hash('network_metadata'), hiera('memcache_roles')) $memcached_server = hiera('memcached_addresses')
$memcache_address_map = get_node_to_ipaddr_map_by_network_role($memcache_nodes, 'mgmt/memcache')
$public_port = '5000' $public_port = '5000'
$admin_port = '35357' $admin_port = '35357'
@ -123,7 +122,7 @@ class { 'openstack::keystone':
use_stderr => $use_stderr, use_stderr => $use_stderr,
syslog_log_facility => $syslog_log_facility, syslog_log_facility => $syslog_log_facility,
region => $region, region => $region,
memcache_servers => values($memcache_address_map), memcache_servers => $memcached_server,
memcache_server_port => $memcache_server_port, memcache_server_port => $memcache_server_port,
memcache_pool_maxsize => $memcache_pool_maxsize, memcache_pool_maxsize => $memcache_pool_maxsize,
max_retries => $max_retries, max_retries => $max_retries,

View File

@ -5,61 +5,61 @@ $override_configuration = hiera_hash('configuration', {})
$network_metadata = hiera_hash('network_metadata', {}) $network_metadata = hiera_hash('network_metadata', {})
prepare_network_config($network_scheme) prepare_network_config($network_scheme)
$nova_rate_limits = hiera('nova_rate_limits') $nova_rate_limits = hiera('nova_rate_limits')
$primary_controller = hiera('primary_controller') $primary_controller = hiera('primary_controller')
$use_neutron = hiera('use_neutron', false) $use_neutron = hiera('use_neutron', false)
$nova_report_interval = hiera('nova_report_interval') $nova_report_interval = hiera('nova_report_interval')
$nova_service_down_time = hiera('nova_service_down_time') $nova_service_down_time = hiera('nova_service_down_time')
$use_syslog = hiera('use_syslog', true) $use_syslog = hiera('use_syslog', true)
$use_stderr = hiera('use_stderr', false) $use_stderr = hiera('use_stderr', false)
$syslog_log_facility_glance = hiera('syslog_log_facility_glance', 'LOG_LOCAL2') $syslog_log_facility_glance = hiera('syslog_log_facility_glance', 'LOG_LOCAL2')
$syslog_log_facility_neutron = hiera('syslog_log_facility_neutron', 'LOG_LOCAL4') $syslog_log_facility_neutron = hiera('syslog_log_facility_neutron', 'LOG_LOCAL4')
$syslog_log_facility_nova = hiera('syslog_log_facility_nova','LOG_LOCAL6') $syslog_log_facility_nova = hiera('syslog_log_facility_nova','LOG_LOCAL6')
$syslog_log_facility_keystone = hiera('syslog_log_facility_keystone', 'LOG_LOCAL7') $syslog_log_facility_keystone = hiera('syslog_log_facility_keystone', 'LOG_LOCAL7')
$management_vip = hiera('management_vip') $management_vip = hiera('management_vip')
$public_vip = hiera('public_vip') $public_vip = hiera('public_vip')
$sahara_hash = hiera_hash('sahara', {}) $sahara_hash = hiera_hash('sahara', {})
$nodes_hash = hiera('nodes', {}) $nodes_hash = hiera('nodes', {})
$mysql_hash = hiera_hash('mysql', {}) $mysql_hash = hiera_hash('mysql', {})
$access_hash = hiera_hash('access', {}) $access_hash = hiera_hash('access', {})
$keystone_hash = hiera_hash('keystone', {}) $keystone_hash = hiera_hash('keystone', {})
$glance_hash = hiera_hash('glance', {}) $glance_hash = hiera_hash('glance', {})
$storage_hash = hiera_hash('storage', {}) $storage_hash = hiera_hash('storage', {})
$nova_hash = hiera_hash('nova', {}) $nova_hash = hiera_hash('nova', {})
$nova_config_hash = hiera_hash('nova_config', {}) $nova_config_hash = hiera_hash('nova_config', {})
$api_bind_address = get_network_role_property('nova/api', 'ipaddr') $api_bind_address = get_network_role_property('nova/api', 'ipaddr')
$rabbit_hash = hiera_hash('rabbit_hash', {}) $rabbit_hash = hiera_hash('rabbit_hash', {})
$ceilometer_hash = hiera_hash('ceilometer',{}) $ceilometer_hash = hiera_hash('ceilometer',{})
$syslog_log_facility_ceph = hiera('syslog_log_facility_ceph','LOG_LOCAL0') $syslog_log_facility_ceph = hiera('syslog_log_facility_ceph','LOG_LOCAL0')
$workloads_hash = hiera_hash('workloads_collector', {}) $workloads_hash = hiera_hash('workloads_collector', {})
$service_endpoint = hiera('service_endpoint') $service_endpoint = hiera('service_endpoint')
$db_host = pick($nova_hash['db_host'], hiera('database_vip')) $db_host = pick($nova_hash['db_host'], hiera('database_vip'))
$ssl_hash = hiera_hash('use_ssl', {}) $ssl_hash = hiera_hash('use_ssl', {})
$internal_auth_protocol = get_ssl_property($ssl_hash, {}, 'keystone', 'internal', 'protocol', 'http') $internal_auth_protocol = get_ssl_property($ssl_hash, {}, 'keystone', 'internal', 'protocol', 'http')
$internal_auth_address = get_ssl_property($ssl_hash, {}, 'keystone', 'internal', 'hostname', [$service_endpoint, $management_vip]) $internal_auth_address = get_ssl_property($ssl_hash, {}, 'keystone', 'internal', 'hostname', [$service_endpoint, $management_vip])
$glance_protocol = get_ssl_property($ssl_hash, {}, 'glance', 'internal', 'protocol', 'http') $glance_protocol = get_ssl_property($ssl_hash, {}, 'glance', 'internal', 'protocol', 'http')
$glance_endpoint = get_ssl_property($ssl_hash, {}, 'glance', 'internal', 'hostname', [hiera('glance_endpoint', ''), $management_vip]) $glance_endpoint = get_ssl_property($ssl_hash, {}, 'glance', 'internal', 'hostname', [hiera('glance_endpoint', ''), $management_vip])
$glance_ssl = get_ssl_property($ssl_hash, {}, 'glance', 'internal', 'usage', false) $glance_ssl = get_ssl_property($ssl_hash, {}, 'glance', 'internal', 'usage', false)
if $glance_ssl { if $glance_ssl {
$glance_api_servers = "${glance_protocol}://${glance_endpoint}:9292" $glance_api_servers = "${glance_protocol}://${glance_endpoint}:9292"
} else { } else {
$glance_api_servers = hiera('glance_api_servers', "${management_vip}:9292") $glance_api_servers = hiera('glance_api_servers', "${management_vip}:9292")
} }
$nova_db_user = pick($nova_hash['db_user'], 'nova') $nova_db_user = pick($nova_hash['db_user'], 'nova')
$keystone_user = pick($nova_hash['user'], 'nova') $keystone_user = pick($nova_hash['user'], 'nova')
$keystone_tenant = pick($nova_hash['tenant'], 'services') $keystone_tenant = pick($nova_hash['tenant'], 'services')
$region = hiera('region', 'RegionOne') $region = hiera('region', 'RegionOne')
$service_workers = pick($nova_hash['workers'], $service_workers = pick($nova_hash['workers'],
min(max($::processorcount, 2), 16)) min(max($::processorcount, 2), 16))
$ironic_hash = hiera_hash('ironic', {}) $ironic_hash = hiera_hash('ironic', {})
$memcache_nodes = get_nodes_hash_by_roles(hiera_hash('network_metadata'), hiera('memcache_roles')) $memcached_server = hiera('memcached_addresses')
$memcache_ipaddrs = ipsort(values(get_node_to_ipaddr_map_by_network_role($memcache_nodes,'mgmt/memcache'))) $memcached_port = hiera('memcache_server_port', '11211')
$roles = node_roles($nodes_hash, hiera('uid')) $roles = node_roles($nodes_hash, hiera('uid'))
$openstack_controller_hash = hiera_hash('openstack_controller', {}) $openstack_controller_hash = hiera_hash('openstack_controller', {})
$floating_hash = {} $floating_hash = {}
@ -134,7 +134,8 @@ class { '::openstack::controller':
amqp_user => $rabbit_hash['user'], amqp_user => $rabbit_hash['user'],
amqp_password => $rabbit_hash['password'], amqp_password => $rabbit_hash['password'],
rabbit_ha_queues => true, rabbit_ha_queues => true,
cache_server_ip => $memcache_ipaddrs, cache_server_ip => $memcached_server,
cache_server_port => $memcached_port,
api_bind_address => $api_bind_address, api_bind_address => $api_bind_address,
db_host => $db_host, db_host => $db_host,
service_endpoint => $service_endpoint, service_endpoint => $service_endpoint,

View File

@ -127,9 +127,9 @@ $floating_hash = {}
##CALCULATED PARAMETERS ##CALCULATED PARAMETERS
$memcached_server = hiera('memcached_addresses')
$memcached_port = hiera('memcache_server_port', '11211')
##TODO: simply parse nodes array ##TODO: simply parse nodes array
$memcache_nodes = get_nodes_hash_by_roles(hiera_hash('network_metadata'), hiera('memcache_roles'))
$memcache_ipaddrs = ipsort(values(get_node_to_ipaddr_map_by_network_role($memcache_nodes,'mgmt/memcache')))
$roles = $network_metadata['nodes'][$node_name]['node_roles'] $roles = $network_metadata['nodes'][$node_name]['node_roles']
$mountpoints = filter_hash($mp_hash,'point') $mountpoints = filter_hash($mp_hash,'point')
@ -271,7 +271,8 @@ class { 'openstack::compute':
manage_volumes => $manage_volumes, manage_volumes => $manage_volumes,
nova_user_password => $nova_hash[user_password], nova_user_password => $nova_hash[user_password],
nova_hash => merge({'reserved_host_memory' => $r_hostmem}, $nova_hash), nova_hash => merge({'reserved_host_memory' => $r_hostmem}, $nova_hash),
cache_server_ip => $memcache_ipaddrs, cache_server_ip => $memcached_server,
cache_server_port => $memcached_port,
service_endpoint => $service_endpoint, service_endpoint => $service_endpoint,
cinder => true, cinder => true,
cinder_iscsi_bind_addr => get_network_role_property('cinder/iscsi', 'ipaddr'), cinder_iscsi_bind_addr => get_network_role_property('cinder/iscsi', 'ipaddr'),

View File

@ -35,9 +35,9 @@ $db_name = pick($nova_hash['db_name'], 'nova')
$db_password = pick($nova_hash['db_password'], 'nova') $db_password = pick($nova_hash['db_password'], 'nova')
$database_connection = "mysql://${db_name}:${db_password}@${db_host}/${db_name}?read_timeout=60" $database_connection = "mysql://${db_name}:${db_password}@${db_host}/${db_name}?read_timeout=60"
$memcache_nodes = get_nodes_hash_by_roles(hiera_hash('network_metadata'), hiera('memcache_roles')) $memcached_servers = hiera('memcached_addresses')
$cache_server_ip = ipsort(values(get_node_to_ipaddr_map_by_network_role($memcache_nodes,'mgmt/memcache'))) $memcached_port = hiera('memcache_server_port', '11211')
$memcached_addresses = suffix($cache_server_ip, inline_template(":<%= @cache_server_port %>")) $memcached_addresses = suffix($memcached_servers, ":${memcached_port}")
$notify_on_state_change = 'vm_and_task_state' $notify_on_state_change = 'vm_and_task_state'

View File

@ -103,6 +103,7 @@
<% globals.store "management_vrouter_vip", @management_vrouter_vip -%> <% globals.store "management_vrouter_vip", @management_vrouter_vip -%>
<% globals.store "public_vrouter_vip", @public_vrouter_vip -%> <% globals.store "public_vrouter_vip", @public_vrouter_vip -%>
<% globals.store "memcache_roles", @memcache_roles -%> <% globals.store "memcache_roles", @memcache_roles -%>
<% globals.store "memcached_addresses", @memcached_addresses -%>
<% globals.store "swift_master_role", @swift_master_role -%> <% globals.store "swift_master_role", @swift_master_role -%>
<% globals.store "swift_nodes", @swift_nodes -%> <% globals.store "swift_nodes", @swift_nodes -%>
<% globals.store "swift_proxies", @swift_proxies -%> <% globals.store "swift_proxies", @swift_proxies -%>

View File

@ -405,6 +405,8 @@ metadata:
status: discover status: discover
swift: swift:
user_password: zr0zBVgi user_password: zr0zBVgi
memcached_addresses: [10.20.30.40, 10.20.30.41]
memcache_server_port: 11212
repo_setup: repo_setup:
installer_kernel: installer_kernel:
local: "/var/www/nailgun/ubuntu/x86_64/images/linux" local: "/var/www/nailgun/ubuntu/x86_64/images/linux"

View File

@ -694,6 +694,8 @@ storage:
storage_network_range: 192.168.1.0/24 storage_network_range: 192.168.1.0/24
swift: swift:
user_password: BP92J6tg user_password: BP92J6tg
memcached_addresses: [10.20.30.40, 10.20.30.41]
memcache_server_port: '11212'
syslog: syslog:
metadata: metadata:
label: Syslog label: Syslog

View File

@ -38,6 +38,25 @@ describe manifest do
} }
end end
memcache_addresses = Noop.hiera 'memcached_addresses', false
memcache_server_port = Noop.hiera 'memcache_server_port', '11211'
let(:memcache_nodes) do
Noop.puppet_function 'get_nodes_hash_by_roles', network_metadata, memcache_roles
end
let(:memcache_address_map) do
Noop.puppet_function 'get_node_to_ipaddr_map_by_network_role', memcache_nodes, 'mgmt/memcache'
end
let (:memcache_servers) do
if not memcache_addresses
memcache_address_map.values
else
memcache_addresses
end
end
########################################################################### ###########################################################################
it 'should declare openstack::horizon class' do it 'should declare openstack::horizon class' do
@ -49,7 +68,9 @@ describe manifest do
it 'should declare openstack::horizon class with keystone_url' do it 'should declare openstack::horizon class with keystone_url' do
should contain_class('openstack::horizon').with( should contain_class('openstack::horizon').with(
'keystone_url' => keystone_url 'keystone_url' => keystone_url,
'cache_server_ip' => memcache_servers,
'cache_server_port' => memcache_server_port
) )
end end

View File

@ -9,6 +9,7 @@ describe manifest do
network_metadata = Noop.hiera 'network_metadata' network_metadata = Noop.hiera 'network_metadata'
memcache_roles = Noop.hiera 'memcache_roles' memcache_roles = Noop.hiera 'memcache_roles'
memcache_addresses = Noop.hiera 'memcached_addresses', false
memcache_server_port = Noop.hiera 'memcache_server_port', '11211' memcache_server_port = Noop.hiera 'memcache_server_port', '11211'
let(:memcache_nodes) do let(:memcache_nodes) do
@ -20,7 +21,11 @@ describe manifest do
end end
let (:memcache_servers) do let (:memcache_servers) do
memcache_address_map.values.map { |server| "#{server}:#{memcache_server_port}" }.join(",") if not memcache_addresses
memcache_address_map.values.map { |server| "#{server}:#{memcache_server_port}" }.join(",")
else
memcache_addresses.map { |server| "#{server}:#{memcache_server_port}" }.join(",")
end
end end
let(:configuration_override) do let(:configuration_override) do

View File

@ -17,6 +17,27 @@ describe manifest do
configuration_override.fetch('nova_paste_api_ini', {}) configuration_override.fetch('nova_paste_api_ini', {})
end end
network_metadata = Noop.hiera 'network_metadata'
memcache_roles = Noop.hiera 'memcache_roles'
memcache_addresses = Noop.hiera 'memcached_addresses', false
memcache_server_port = Noop.hiera 'memcache_server_port', '11211'
let(:memcache_nodes) do
Noop.puppet_function 'get_nodes_hash_by_roles', network_metadata, memcache_roles
end
let(:memcache_address_map) do
Noop.puppet_function 'get_node_to_ipaddr_map_by_network_role', memcache_nodes, 'mgmt/memcache'
end
let (:memcache_servers) do
if not memcache_addresses
memcache_address_map.values.map { |server| "#{server}:#{memcache_server_port}" }.join(",")
else
memcache_addresses.map { |server| "#{server}:#{memcache_server_port}" }.join(",")
end
end
use_neutron = Noop.hiera 'use_neutron' use_neutron = Noop.hiera 'use_neutron'
primary_controller = Noop.hiera 'primary_controller' primary_controller = Noop.hiera 'primary_controller'
if !use_neutron && primary_controller if !use_neutron && primary_controller
@ -51,12 +72,19 @@ describe manifest do
'value' => '60', 'value' => '60',
) )
end end
it 'nova config should have service_down_time set to 180' do it 'nova config should have service_down_time set to 180' do
should contain_nova_config('DEFAULT/service_down_time').with( should contain_nova_config('DEFAULT/service_down_time').with(
'value' => '180', 'value' => '180',
) )
end end
it 'nova config should contain right memcached servers list' do
should contain_nova_config('DEFAULT/memcached_servers').with(
'value' => memcache_servers,
)
end
keystone_ec2_url = "http://#{keystone_host}:5000/v2.0/ec2tokens" keystone_ec2_url = "http://#{keystone_host}:5000/v2.0/ec2tokens"
it 'should declare class nova::api with keystone_ec2_url' do it 'should declare class nova::api with keystone_ec2_url' do
should contain_class('nova::api').with( should contain_class('nova::api').with(

View File

@ -7,6 +7,27 @@ describe manifest do
host_uuid = Noop.hiera 'host_uuid' host_uuid = Noop.hiera 'host_uuid'
network_metadata = Noop.hiera 'network_metadata'
memcache_roles = Noop.hiera 'memcache_roles'
memcache_addresses = Noop.hiera 'memcached_addresses', false
memcache_server_port = Noop.hiera 'memcache_server_port', '11211'
let(:memcache_nodes) do
Noop.puppet_function 'get_nodes_hash_by_roles', network_metadata, memcache_roles
end
let(:memcache_address_map) do
Noop.puppet_function 'get_node_to_ipaddr_map_by_network_role', memcache_nodes, 'mgmt/memcache'
end
let (:memcache_servers) do
if not memcache_addresses
memcache_address_map.values.map { |server| "#{server}:#{memcache_server_port}" }.join(",")
else
memcache_addresses.map { |server| "#{server}:#{memcache_server_port}" }.join(",")
end
end
let(:nova_hash) do let(:nova_hash) do
Noop.hiera_structure 'nova' Noop.hiera_structure 'nova'
end end
@ -112,6 +133,11 @@ describe manifest do
'value' => 'false', 'value' => 'false',
) )
end end
it 'nova config should contain right memcached servers list' do
should contain_nova_config('DEFAULT/memcached_servers').with(
'value' => memcache_servers,
)
end
it 'should install fping for nova API extension' do it 'should install fping for nova API extension' do
should contain_package('fping').with('ensure' => 'present') should contain_package('fping').with('ensure' => 'present')

View File

@ -7,6 +7,27 @@ describe manifest do
ironic_user_password = Noop.hiera_structure 'ironic/user_password' ironic_user_password = Noop.hiera_structure 'ironic/user_password'
ironic_enabled = Noop.hiera_structure 'ironic/enabled' ironic_enabled = Noop.hiera_structure 'ironic/enabled'
network_metadata = Noop.hiera 'network_metadata'
memcache_roles = Noop.hiera 'memcache_roles'
memcache_addresses = Noop.hiera 'memcached_addresses', false
memcache_server_port = Noop.hiera 'memcache_server_port', '11211'
let(:memcache_nodes) do
Noop.puppet_function 'get_nodes_hash_by_roles', network_metadata, memcache_roles
end
let(:memcache_address_map) do
Noop.puppet_function 'get_node_to_ipaddr_map_by_network_role', memcache_nodes, 'mgmt/memcache'
end
let (:memcache_servers) do
if not memcache_addresses
memcache_address_map.values.map { |server| "#{server}:#{memcache_server_port}" }.join(",")
else
memcache_addresses.map { |server| "#{server}:#{memcache_server_port}" }.join(",")
end
end
if ironic_enabled if ironic_enabled
it 'nova config should have correct nova_user_password' do it 'nova config should have correct nova_user_password' do
should contain_nova_config('ironic/admin_password').with(:value => ironic_user_password) should contain_nova_config('ironic/admin_password').with(:value => ironic_user_password)
@ -16,6 +37,12 @@ describe manifest do
it 'nova config should have reserved_host_memory_mb set to 0' do it 'nova config should have reserved_host_memory_mb set to 0' do
should contain_nova_config('DEFAULT/reserved_host_memory_mb').with(:value => '0') should contain_nova_config('DEFAULT/reserved_host_memory_mb').with(:value => '0')
end end
it 'nova config should contain right memcached servers list' do
should contain_nova_config('DEFAULT/memcached_servers').with(
'value' => memcache_servers,
)
end
end end
end end