Update the module for new config file method

Since we have now an only config file (heat.conf) with this patch:
https://review.openstack.org/#/c/36476/

This patch updates the module and delete old configuration files
support and add a test.

Also, I fixed some tab issues in manifests.
Fix bug #1207858

Change-Id: If3d044e2581156fa5ce4de19f5c740328efa0aa8
This commit is contained in:
Emilien Macchi 2013-08-02 21:08:49 +02:00
parent 1318bcbd83
commit 03ef6a7b7f
15 changed files with 198 additions and 237 deletions

View File

@ -1,22 +0,0 @@
Puppet::Type.type(:heat_api_cfn_config).provide(
:ini_setting,
:parent => Puppet::Type.type(:ini_setting).provider(:ruby)
) do
def section
resource[:name].split('/', 2).first
end
def setting
resource[:name].split('/', 2).last
end
def separator
'='
end
def file_path
'/etc/heat/heat-api-cfn.conf'
end
end

View File

@ -1,22 +0,0 @@
Puppet::Type.type(:heat_api_cloudwatch_config).provide(
:ini_setting,
:parent => Puppet::Type.type(:ini_setting).provider(:ruby)
) do
def section
resource[:name].split('/', 2).first
end
def setting
resource[:name].split('/', 2).last
end
def separator
'='
end
def file_path
'/etc/heat/heat-api-cloudwatch.conf'
end
end

View File

@ -1,4 +1,4 @@
Puppet::Type.type(:heat_api_config).provide(
Puppet::Type.type(:heat_config).provide(
:ini_setting,
:parent => Puppet::Type.type(:ini_setting).provider(:ruby)
) do
@ -16,7 +16,7 @@ Puppet::Type.type(:heat_api_config).provide(
end
def file_path
'/etc/heat/heat-api.conf'
'/etc/heat/heat.conf'
end
end

View File

@ -1,22 +0,0 @@
Puppet::Type.type(:heat_engine_config).provide(
:ini_setting,
:parent => Puppet::Type.type(:ini_setting).provider(:ruby)
) do
def section
resource[:name].split('/', 2).first
end
def setting
resource[:name].split('/', 2).last
end
def separator
'='
end
def file_path
'/etc/heat/heat-engine.conf'
end
end

View File

@ -1,19 +0,0 @@
Puppet::Type.newtype(:heat_api_cfn_config) do
ensurable
newparam(:name, :namevar => true) do
desc 'Section/setting name to manage from heat_api_cfn.conf'
newvalues(/\S+\/\S+/)
end
newproperty(:value) do
desc 'The value of the setting to be defined.'
munge do |value|
value = value.to_s.strip
value.capitalize! if value =~ /^(true|false)$/i
value
end
end
end

View File

@ -1,19 +0,0 @@
Puppet::Type.newtype(:heat_api_cloudwatch_config) do
ensurable
newparam(:name, :namevar => true) do
desc 'Section/setting name to manage from heat-api-cloudwatch.conf'
newvalues(/\S+\/\S+/)
end
newproperty(:value) do
desc 'The value of the setting to be defined.'
munge do |value|
value = value.to_s.strip
value.capitalize! if value =~ /^(true|false)$/i
value
end
end
end

View File

@ -1,9 +1,9 @@
Puppet::Type.newtype(:heat_api_config) do
Puppet::Type.newtype(:heat_config) do
ensurable
newparam(:name, :namevar => true) do
desc 'Section/setting name to manage from heat-api.conf'
desc 'Section/setting name to manage from heat.conf'
newvalues(/\S+\/\S+/)
end

View File

@ -1,19 +0,0 @@
Puppet::Type.newtype(:heat_engine_config) do
ensurable
newparam(:name, :namevar => true) do
desc 'Section/setting name to manage from heat-engine.conf'
newvalues(/\S+\/\S+/)
end
newproperty(:value) do
desc 'The value of the setting to be defined.'
munge do |value|
value = value.to_s.strip
value.capitalize! if value =~ /^(true|false)$/i
value
end
end
end

View File

@ -20,9 +20,9 @@ class heat::api-cfn (
validate_string($keystone_password)
Heat_api_cfn_config<||> ~> Service['heat-api-cfn']
Heat_config<||> ~> Service['heat-api-cfn']
Package['heat-api-cfn'] -> Heat_api_cfn_config<||>
Package['heat-api-cfn'] -> Heat_config<||>
Package['heat-api-cfn'] -> Service['heat-api-cfn']
package { 'heat-api-cfn':
ensure => installed,
@ -37,26 +37,6 @@ class heat::api-cfn (
Package['heat-common'] -> Service['heat-api-cfn']
if $rabbit_hosts {
heat_api_cfn_config { 'DEFAULT/rabbit_host': ensure => absent }
heat_api_cfn_config { 'DEFAULT/rabbit_port': ensure => absent }
heat_api_cfn_config { 'DEFAULT/rabbit_hosts':
value => join($rabbit_hosts, ',')
}
} else {
heat_api_cfn_config { 'DEFAULT/rabbit_host': value => $rabbit_host }
heat_api_cfn_config { 'DEFAULT/rabbit_port': value => $rabbit_port }
heat_api_cfn_config { 'DEFAULT/rabbit_hosts':
value => "${rabbit_host}:${rabbit_port}"
}
}
if size($rabbit_hosts) > 1 {
heat_api_cfn_config { 'DEFAULT/rabbit_ha_queues': value => true }
} else {
heat_api_cfn_config { 'DEFAULT/rabbit_ha_queues': value => false }
}
service { 'heat-api-cfn':
ensure => $service_ensure,
name => $::heat::params::api_cfn_service_name,
@ -66,10 +46,7 @@ class heat::api-cfn (
require => Class['heat::db'],
}
heat_api_cfn_config {
'DEFAULT/rabbit_userid' : value => $rabbit_userid;
'DEFAULT/rabbit_password' : value => $rabbit_password;
'DEFAULT/rabbit_virtualhost' : value => $rabbit_virtualhost;
heat_config {
'DEFAULT/debug' : value => $debug;
'DEFAULT/verbose' : value => $verbose;
'DEFAULT/log_dir' : value => $::heat::params::log_dir;

View File

@ -20,9 +20,9 @@ class heat::api-cloudwatch (
validate_string($keystone_password)
Heat_api_cloudwatch_config<||> ~> Service['heat-api-cloudwatch']
Heat_config<||> ~> Service['heat-api-cloudwatch']
Package['heat-api-cloudwatch'] -> Heat_api_cloudwatch_config<||>
Package['heat-api-cloudwatch'] -> Heat_config<||>
Package['heat-api-cloudwatch'] -> Service['heat-api-cloudwatch']
package { 'heat-api-cloudwatch':
ensure => installed,
@ -37,26 +37,6 @@ class heat::api-cloudwatch (
Package['heat-common'] -> Service['heat-api-cloudwatch']
if $rabbit_hosts {
heat_api_config { 'DEFAULT/rabbit_host': ensure => absent }
heat_api_config { 'DEFAULT/rabbit_port': ensure => absent }
heat_api_config { 'DEFAULT/rabbit_hosts':
value => join($rabbit_hosts, ',')
}
} else {
heat_api_cloudwatch_config { 'DEFAULT/rabbit_host': value => $rabbit_host }
heat_api_cloudwatch_config { 'DEFAULT/rabbit_port': value => $rabbit_port }
heat_api_cloudwatch_config { 'DEFAULT/rabbit_hosts':
value => "${rabbit_host}:${rabbit_port}"
}
}
if size($rabbit_hosts) > 1 {
heat_api_cloudwatch_config { 'DEFAULT/rabbit_ha_queues': value => true }
} else {
heat_api_cloudwatch_config { 'DEFAULT/rabbit_ha_queues': value => false }
}
service { 'heat-api-cloudwatch':
ensure => $service_ensure,
name => $::heat::params::api_cloudwatch_service_name,
@ -66,10 +46,7 @@ class heat::api-cloudwatch (
require => Class['heat::db'],
}
heat_api_cloudwatch_config {
'DEFAULT/rabbit_userid' : value => $rabbit_userid;
'DEFAULT/rabbit_password' : value => $rabbit_password;
'DEFAULT/rabbit_virtualhost' : value => $rabbit_virtualhost;
heat_config {
'DEFAULT/debug' : value => $debug;
'DEFAULT/verbose' : value => $verbose;
'DEFAULT/log_dir' : value => $::heat::params::log_dir;

View File

@ -14,16 +14,15 @@ class heat::api (
$bind_port = '8004',
$verbose = 'False',
$debug = 'False',
$rabbit_host = '127.0.0.1',
) {
include heat::params
validate_string($keystone_password)
Heat_api_config<||> ~> Service['heat-api']
Heat_config<||> ~> Service['heat-api']
Package['heat-api'] -> Heat_api_config<||>
Package['heat-api'] -> Heat_config<||>
Package['heat-api'] -> Service['heat-api']
package { 'heat-api':
@ -37,26 +36,6 @@ class heat::api (
$service_ensure = 'stopped'
}
if $rabbit_hosts {
heat_api_config { 'DEFAULT/rabbit_host': ensure => absent }
heat_api_config { 'DEFAULT/rabbit_port': ensure => absent }
heat_api_config { 'DEFAULT/rabbit_hosts':
value => join($rabbit_hosts, ',')
}
} else {
heat_api_config { 'DEFAULT/rabbit_host': value => $rabbit_host }
heat_api_config { 'DEFAULT/rabbit_port': value => $rabbit_port }
heat_api_config { 'DEFAULT/rabbit_hosts':
value => "${rabbit_host}:${rabbit_port}"
}
}
if size($rabbit_hosts) > 1 {
heat_api_config { 'DEFAULT/rabbit_ha_queues': value => true }
} else {
heat_api_config { 'DEFAULT/rabbit_ha_queues': value => false }
}
service { 'heat-api':
ensure => $service_ensure,
name => $::heat::params::api_service_name,
@ -64,20 +43,16 @@ class heat::api (
hasstatus => true,
hasrestart => true,
require => [Package['heat-common'],
Package['heat-api'],
Class['heat::db']],
Package['heat-api'],
Class['heat::db']],
}
heat_api_config {
'DEFAULT/rabbit_userid' : value => $rabbit_userid;
'DEFAULT/rabbit_password' : value => $rabbit_password;
'DEFAULT/rabbit_virtualhost' : value => $rabbit_virtualhost;
heat_config {
'DEFAULT/debug' : value => $debug;
'DEFAULT/verbose' : value => $verbose;
'DEFAULT/log_dir' : value => $::heat::params::log_dir;
'DEFAULT/bind_host' : value => $bind_host;
'DEFAULT/bind_port' : value => $bind_port;
'DEFAULT/rabbit_host ' : value => $rabbit_host;
'ec2authtoken/keystone_ec2_uri' : value => $keystone_ec2_uri;
'ec2authtoken/auth_uri' : value => $auth_uri;
'keystone_authtoken/auth_host' : value => $keystone_host;

View File

@ -40,7 +40,7 @@ class heat::db (
}
}
heat_engine_config {
heat_config {
'DEFAULT/sql_connection': value => $sql_connection;
}
}

View File

@ -43,26 +43,6 @@ class heat::engine (
$service_ensure = 'stopped'
}
if $rabbit_hosts {
heat_engine_config { 'DEFAULT/rabbit_host': ensure => absent }
heat_engine_config { 'DEFAULT/rabbit_port': ensure => absent }
heat_engine_config { 'DEFAULT/rabbit_hosts':
value => join($rabbit_hosts, ',')
}
} else {
heat_engine_config { 'DEFAULT/rabbit_host': value => $rabbit_host }
heat_engine_config { 'DEFAULT/rabbit_port': value => $rabbit_port }
heat_engine_config { 'DEFAULT/rabbit_hosts':
value => "${rabbit_host}:${rabbit_port}"
}
}
if size($rabbit_hosts) > 1 {
heat_engine_config { 'DEFAULT/rabbit_ha_queues': value => true }
} else {
heat_engine_config { 'DEFAULT/rabbit_ha_queues': value => false }
}
service { 'heat-engine':
ensure => $service_ensure,
name => $::heat::params::engine_service_name,
@ -72,8 +52,8 @@ class heat::engine (
require => [ File['/etc/heat/heat-engine.conf'],
Exec['heat-encryption-key-replacement'],
Package['heat-common'],
Package['heat-engine'],
Class['heat::db']],
Package['heat-engine'],
Class['heat::db']],
}
exec {'heat-encryption-key-replacement':
@ -82,10 +62,7 @@ class heat::engine (
onlyif => 'grep -c ENCRYPTION_KEY /etc/heat/heat-engine.conf',
}
heat_engine_config {
'DEFAULT/rabbit_userid' : value => $rabbit_userid;
'DEFAULT/rabbit_password' : value => $rabbit_password;
'DEFAULT/rabbit_virtualhost' : value => $rabbit_virtualhost;
heat_config {
'DEFAULT/debug' : value => $debug;
'DEFAULT/verbose' : value => $verbose;
'DEFAULT/log_dir' : value => $::heat::params::log_dir;

View File

@ -61,11 +61,45 @@ class heat(
mode => '0750',
}
file { '/etc/heat/heat.conf':
owner => 'heat',
group => 'heat',
mode => '0640',
}
package { 'heat-common':
ensure => $package_ensure,
name => $::heat::params::common_package_name,
}
# Package['heat-common'] -> Heat_config<||>
Package['heat-common'] -> Heat_config<||>
if $rabbit_hosts {
heat_config { 'DEFAULT/rabbit_host': ensure => absent }
heat_config { 'DEFAULT/rabbit_port': ensure => absent }
heat_config { 'DEFAULT/rabbit_hosts':
value => join($rabbit_hosts, ',')
}
} else {
heat_config { 'DEFAULT/rabbit_host': value => $rabbit_host }
heat_config { 'DEFAULT/rabbit_port': value => $rabbit_port }
heat_config { 'DEFAULT/rabbit_hosts':
value => "${rabbit_host}:${rabbit_port}"
}
}
if size($rabbit_hosts) > 1 {
heat_config { 'DEFAULT/rabbit_ha_queues': value => true }
} else {
heat_config { 'DEFAULT/rabbit_ha_queues': value => false }
}
heat_config {
'DEFAULT/rabbit_userid' : value => $rabbit_userid;
'DEFAULT/rabbit_password' : value => $rabbit_password;
'DEFAULT/rabbit_virtualhost' : value => $rabbit_virtualhost;
'DEFAULT/debug' : value => $debug;
'DEFAULT/verbose' : value => $verbose;
}
}

View File

@ -0,0 +1,144 @@
require 'spec_helper'
describe 'heat' do
let :params do
{
:package_ensure => 'present',
:verbose => 'False',
:debug => 'False',
:rabbit_host => '127.0.0.1',
:rabbit_port => 5672,
:rabbit_userid => 'guest',
:rabbit_password => '',
:rabbit_virtualhost => '/',
}
end
shared_examples_for 'heat' do
context 'with rabbit_host parameter' do
it_configures 'a heat base installation'
it_configures 'rabbit without HA support (with backward compatibility)'
end
context 'with rabbit_hosts parameter' do
context 'with one server' do
before { params.merge!( :rabbit_hosts => ['127.0.0.1:5672'] ) }
it_configures 'a heat base installation'
it_configures 'rabbit without HA support (without backward compatibility)'
end
context 'with multiple servers' do
before { params.merge!( :rabbit_hosts => ['rabbit1:5672', 'rabbit2:5672'] ) }
it_configures 'a heat base installation'
it_configures 'rabbit with HA support'
end
end
end
shared_examples_for 'a heat base installation' do
it { should include_class('heat::params') }
it 'configures heat group' do
should contain_group('heat').with(
:name => 'heat',
:require => 'Package[heat-common]'
)
end
it 'configures heat user' do
should contain_user('heat').with(
:name => 'heat',
:gid => 'heat',
:groups => ['heat'],
:system => true,
:require => 'Package[heat-common]'
)
end
it 'configures heat configuration folder' do
should contain_file('/etc/heat/').with(
:ensure => 'directory',
:owner => 'heat',
:group => 'heat',
:mode => '0750',
:require => 'Package[heat-common]'
)
end
it 'configures heat configuration file' do
should contain_file('/etc/heat/heat.conf').with(
:owner => 'heat',
:group => 'heat',
:mode => '0640',
:require => 'Package[heat-common]'
)
end
it 'installs heat common package' do
should contain_package('heat-common').with(
:ensure => 'present',
:name => platform_params[:common_package_name]
)
end
it 'configures rabbit' do
should contain_heat_config('DEFAULT/rabbit_userid').with_value( params[:rabbit_userid] )
should contain_heat_config('DEFAULT/rabbit_password').with_value( params[:rabbit_password] )
should contain_heat_config('DEFAULT/rabbit_virtualhost').with_value( params[:rabbit_virtualhost] )
end
it 'configures debug and verbose' do
should contain_heat_config('DEFAULT/debug').with_value( params[:debug] )
should contain_heat_config('DEFAULT/verbose').with_value( params[:verbose] )
end
end
shared_examples_for 'rabbit without HA support (with backward compatibility)' do
it { should contain_heat_config('DEFAULT/rabbit_host').with_value( params[:rabbit_host] ) }
it { should contain_heat_config('DEFAULT/rabbit_port').with_value( params[:rabbit_port] ) }
it { should contain_heat_config('DEFAULT/rabbit_hosts').with_value( "#{params[:rabbit_host]}:#{params[:rabbit_port]}" ) }
it { should contain_heat_config('DEFAULT/rabbit_ha_queues').with_value('false') }
end
shared_examples_for 'rabbit without HA support (without backward compatibility)' do
it { should contain_heat_config('DEFAULT/rabbit_host').with_ensure('absent') }
it { should contain_heat_config('DEFAULT/rabbit_port').with_ensure('absent') }
it { should contain_heat_config('DEFAULT/rabbit_hosts').with_value( params[:rabbit_hosts].join(',') ) }
it { should contain_heat_config('DEFAULT/rabbit_ha_queues').with_value('false') }
end
shared_examples_for 'rabbit with HA support' do
it { should contain_heat_config('DEFAULT/rabbit_host').with_ensure('absent') }
it { should contain_heat_config('DEFAULT/rabbit_port').with_ensure('absent') }
it { should contain_heat_config('DEFAULT/rabbit_hosts').with_value( params[:rabbit_hosts].join(',') ) }
it { should contain_heat_config('DEFAULT/rabbit_ha_queues').with_value('true') }
end
context 'on Debian platforms' do
let :facts do
{ :osfamily => 'Debian' }
end
let :platform_params do
{ :common_package_name => 'heat-common' }
end
it_configures 'heat'
end
context 'on RedHat platforms' do
let :facts do
{ :osfamily => 'RedHat' }
end
let :platform_params do
{ :common_package_name => 'openstack-heat-common' }
end
it_configures 'heat'
end
end