From 8575d05827d5e2a68f0ede4fdeaaaed5855450dc Mon Sep 17 00:00:00 2001 From: nitishkrishna Date: Tue, 2 Feb 2016 21:20:39 -0800 Subject: [PATCH] Closes-Bug: #1541112 - Duplicate declaration errors in SM Kilo parallel provision Three duplication declarations fixed: 1. Augeas conf set changed as it used key as title. 2. Two conflicting Resources called in config only if node not same as openstack node 3. Augeas conf ins modified as it might cause duplicate declaration if inserting same key in two files Patch 2: Missed out define of host_roles in neutron/server.pp Patch 3: Chnaged augeas_conf_ins to avoid duplicate declaration Change-Id: I58681efa940be5803e653a5ef0aa986f2971f796 --- .../contrail/manifests/collector/config.pp | 3 +-- .../contrail/manifests/compute/config.pp | 2 +- .../contrail/manifests/config/config.pp | 9 +++------ .../contrail/manifests/database/config.pp | 12 +++++------- .../database/new_config_zk_files_setup.pp | 3 +-- .../contrail/manifests/lib/augeas_conf_ins.pp | 13 +++++++------ .../contrail/manifests/lib/augeas_conf_set.pp | 17 +++++++++-------- .../manifests/profile/neutron/server.pp | 11 +++++++---- .../modules/neutron/manifests/server.pp | 18 ++++++++++-------- 9 files changed, 44 insertions(+), 44 deletions(-) diff --git a/contrail/environment/modules/contrail/manifests/collector/config.pp b/contrail/environment/modules/contrail/manifests/collector/config.pp index da9aa240..5068655a 100644 --- a/contrail/environment/modules/contrail/manifests/collector/config.pp +++ b/contrail/environment/modules/contrail/manifests/collector/config.pp @@ -145,8 +145,7 @@ contrail_collector_config { 'REDIS/password': value => $redis_password; } contrail_query_engine_config { 'REDIS/password': value => $redis_password; } $redis_config = { 'redis_conf' => { 'requirepass' => $redis_password,},} - $redis_conf_keys = keys($redis_config['redis_conf']) - contrail::lib::augeas_conf_set { $redis_conf_keys: + contrail::lib::augeas_conf_set { 'redis_conf_keys': config_file => $redis_config_file, settings_hash => $redis_config['redis_conf'], lens_to_use => $redis_augeas_lens_to_use, diff --git a/contrail/environment/modules/contrail/manifests/compute/config.pp b/contrail/environment/modules/contrail/manifests/compute/config.pp index d58d9665..b88f0d5b 100644 --- a/contrail/environment/modules/contrail/manifests/compute/config.pp +++ b/contrail/environment/modules/contrail/manifests/compute/config.pp @@ -269,7 +269,7 @@ if inline_template('<%= @operatingsystem.downcase %>') == 'centos' { # Ensure modprobe.conf file is present with right content. $modprobe_conf_file = '/etc/modprobe.conf' - contrail::lib::augeas_conf_set { ['alias']: + contrail::lib::augeas_conf_set { 'alias': config_file => $modprobe_conf_file, settings_hash => {'alias' => 'bridge off',}, lens_to_use => 'spacevars.lns', diff --git a/contrail/environment/modules/contrail/manifests/config/config.pp b/contrail/environment/modules/contrail/manifests/config/config.pp index 81c326fe..657569b2 100644 --- a/contrail/environment/modules/contrail/manifests/config/config.pp +++ b/contrail/environment/modules/contrail/manifests/config/config.pp @@ -208,9 +208,8 @@ }, } - $log4j_properties_keys = keys($log4j_properties_config['log4j_properties']) $log4j_augeas_lens_to_use = 'properties.lns' - contrail::lib::augeas_conf_set { $log4j_properties_keys: + contrail::lib::augeas_conf_set { 'log4j_properties_keys': config_file => $log4j_properties_file, settings_hash => $log4j_properties_config['log4j_properties'], lens_to_use => $log4j_augeas_lens_to_use, @@ -224,9 +223,8 @@ # Ensure authorization.properties file is present with right content. $authorizaion_properties_file = '/etc/ifmap-server/authorization.properties' $authorizaion_properties_config = { 'authorizaion_properties' => {'reader' => 'ro',},} - $authorizaion_properties_keys = keys($authorizaion_properties_config['authorizaion_properties']) $authorizaion_augeas_lens_to_use = 'properties.lns' - contrail::lib::augeas_conf_set { $authorizaion_properties_keys: + contrail::lib::augeas_conf_set { 'authorizaion_properties_keys': config_file => $authorizaion_properties_file, settings_hash => $authorizaion_properties_config['authorizaion_properties'], lens_to_use => $authorizaion_augeas_lens_to_use, @@ -257,9 +255,8 @@ 'control-node-10' => 'control-node-10--1870931930-1', }, } - $publisher_properties_keys = keys($publisher_properties_config['publisher_properties']) $publisher_augeas_lens_to_use = 'properties.lns' - contrail::lib::augeas_conf_set { $publisher_properties_keys: + contrail::lib::augeas_conf_set { 'publisher_properties_keys': config_file => $publisher_properties_file, settings_hash => $publisher_properties_config['publisher_properties'], lens_to_use => $publisher_augeas_lens_to_use, diff --git a/contrail/environment/modules/contrail/manifests/database/config.pp b/contrail/environment/modules/contrail/manifests/database/config.pp index 6d0d466a..29e5122d 100644 --- a/contrail/environment/modules/contrail/manifests/database/config.pp +++ b/contrail/environment/modules/contrail/manifests/database/config.pp @@ -102,9 +102,8 @@ }, } - $kafka_server_properties_keys = keys($kafka_server_properties_config['kafka_server_properties']) $kafka_server_augeas_lens_to_use = 'properties.lns' - contrail::lib::augeas_conf_set { $kafka_server_properties_keys: + contrail::lib::augeas_conf_set { 'kafka_server_properties_keys': config_file => $kafka_server_properties_file, settings_hash => $kafka_server_properties_config['kafka_server_properties'], lens_to_use => $kafka_server_augeas_lens_to_use, @@ -131,15 +130,14 @@ 'log4j.appender.controllerAppender.MaxBackupIndex' => '10', }, } - $kafka_log4j_properties_keys = keys($kafka_log4j_properties_config['kafka_log4j_properties']) $kafka_log4j_augeas_lens_to_use = 'properties.lns' - contrail::lib::augeas_conf_ins { ['kafka.logs.dir']: + contrail::lib::augeas_conf_ins { 'setting_kafka.logs.dir': + key => 'kafka.logs.dir', + value => 'logs', config_file => $kafka_log4j_properties_file, - settings_hash => {'kafka.logs.dir' => 'logs',}, lens_to_use => $kafka_log4j_augeas_lens_to_use, - } - contrail::lib::augeas_conf_set { $kafka_log4j_properties_keys: + contrail::lib::augeas_conf_set { 'kafka_log4j_properties_keys': config_file => $kafka_log4j_properties_file, settings_hash => $kafka_log4j_properties_config['kafka_log4j_properties'], lens_to_use => $kafka_log4j_augeas_lens_to_use, diff --git a/contrail/environment/modules/contrail/manifests/database/new_config_zk_files_setup.pp b/contrail/environment/modules/contrail/manifests/database/new_config_zk_files_setup.pp index 9cfa1dd6..07135640 100644 --- a/contrail/environment/modules/contrail/manifests/database/new_config_zk_files_setup.pp +++ b/contrail/environment/modules/contrail/manifests/database/new_config_zk_files_setup.pp @@ -8,8 +8,7 @@ 'autopurge.purgeInterval' => "3", }, } - $zk_cfg_keys = keys($zk_cfg['zk_cfg']) - contrail::lib::augeas_conf_set { $zk_cfg_keys: + contrail::lib::augeas_conf_set { 'zk_cfg_keys': config_file => '/etc/zookeeper/conf/zoo.cfg', settings_hash => $zk_cfg['zk_cfg'], lens_to_use => 'properties.lns', diff --git a/contrail/environment/modules/contrail/manifests/lib/augeas_conf_ins.pp b/contrail/environment/modules/contrail/manifests/lib/augeas_conf_ins.pp index a7d5b700..7e214bb3 100644 --- a/contrail/environment/modules/contrail/manifests/lib/augeas_conf_ins.pp +++ b/contrail/environment/modules/contrail/manifests/lib/augeas_conf_ins.pp @@ -2,21 +2,22 @@ ## Example of call: ## $redis_config_file = '/etc/redis/redis.conf' ## $redis_config = { 'redis_conf' => } -## $redis_conf_keys = keys($redis_config['redis_conf']) -## contrail::lib::augeas_conf_set { $redis_conf_keys: +## $key = +## $value = +## contrail::lib::augeas_conf_ins { 'inserting_${key}_in_${config_file}': +## key => $key, +## value => $value, ## config_file => $redis_config_file, -## settings_hash => $redis_config['redis_conf'], ## lens_to_use => 'spacevars.lns', ## based on separator, whether conf file has section, etc ## } ## define contrail::lib::augeas_conf_ins( - $key = $title, - $settings_hash, + $key, + $value, $config_file, $lens_to_use, ) { - $value = $settings_hash[$key] augeas {"${config_file}_setting_${key}": incl => "${config_file}", lens => "${lens_to_use}", diff --git a/contrail/environment/modules/contrail/manifests/lib/augeas_conf_set.pp b/contrail/environment/modules/contrail/manifests/lib/augeas_conf_set.pp index c8f7c181..deaf0719 100644 --- a/contrail/environment/modules/contrail/manifests/lib/augeas_conf_set.pp +++ b/contrail/environment/modules/contrail/manifests/lib/augeas_conf_set.pp @@ -2,26 +2,27 @@ ## Example of call: ## $redis_config_file = '/etc/redis/redis.conf' ## $redis_config = { 'redis_conf' => } -## $redis_conf_keys = keys($redis_config['redis_conf']) -## contrail::lib::augeas_conf_set { $redis_conf_keys: +## contrail::lib::augeas_conf_set { 'redis_conf': ## config_file => $redis_config_file, ## settings_hash => $redis_config['redis_conf'], ## lens_to_use => 'spacevars.lns', ## based on separator, whether conf file has section, etc ## } ## define contrail::lib::augeas_conf_set( - $key = $title, $settings_hash, $config_file, $lens_to_use, ) { - $value = $settings_hash[$key] - augeas {"${config_file}_setting_${key}": + $keys_list = keys($settings_hash) + $key_and_values = join_keys_to_values($settings_hash, " \"") + $prefix = prefix($key_and_values, "set ") + $change_set = suffix($prefix, "\"") + augeas {"${config_file}_setting_${title}": incl => "${config_file}", lens => "${lens_to_use}", context => "/files${config_file}", - changes => "set ${key} \"${value}\"", - onlyif => "match ${key} not_include ${value}", - } + changes => $change_set, + } + notify {"change_set = ${change_set}":;} } diff --git a/contrail/environment/modules/contrail/manifests/profile/neutron/server.pp b/contrail/environment/modules/contrail/manifests/profile/neutron/server.pp index ef7f6eb4..206eb23e 100644 --- a/contrail/environment/modules/contrail/manifests/profile/neutron/server.pp +++ b/contrail/environment/modules/contrail/manifests/profile/neutron/server.pp @@ -1,7 +1,10 @@ # The profile to set up the neutron server on Config node -class contrail::profile::neutron::server { - - openstack::resources::database { 'neutron': } - +class contrail::profile::neutron::server( +$host_roles = $::contrail::params::host_roles +) +{ + if (!("openstack" in $host_roles)) { + openstack::resources::database { 'neutron': } + } include ::contrail::config::neutron } diff --git a/contrail/environment/modules/neutron/manifests/server.pp b/contrail/environment/modules/neutron/manifests/server.pp index fec2a1ee..ad0f65c7 100644 --- a/contrail/environment/modules/neutron/manifests/server.pp +++ b/contrail/environment/modules/neutron/manifests/server.pp @@ -177,7 +177,7 @@ $log_file = undef, $report_interval = undef, ) { - + $host_roles = $::contrail::params::host_roles include neutron::params require keystone::python @@ -288,13 +288,15 @@ } if ($::neutron::params::server_package) { - Package['neutron-server'] -> Neutron_api_config<||> - Package['neutron-server'] -> Neutron_config<||> - Package['neutron-server'] -> Service['neutron-server'] - package { 'neutron-server': - ensure => $package_ensure, - name => $::neutron::params::server_package, - } + if (!("openstack" in $host_roles)) { + Package['neutron-server'] -> Neutron_api_config<||> + Package['neutron-server'] -> Neutron_config<||> + Package['neutron-server'] -> Service['neutron-server'] + package { 'neutron-server': + ensure => $package_ensure, + name => $::neutron::params::server_package, + } + } } else { # Some platforms (RedHat) does not provide a neutron-server package. # The neutron api config file is provided by the neutron package.