Add manage_service feature
puppet-heat lacks of disabling service managing. This patch adds $manage_service parameter to all relevant classes. Closes-bug: #1359823 Change-Id: I54245b39f3484ccdb9910aa0fa4c8dc2bae3f0ce
This commit is contained in:
		@@ -1,6 +1,16 @@
 | 
			
		||||
# Installs & configure the heat API service
 | 
			
		||||
 | 
			
		||||
#
 | 
			
		||||
# == Parameters
 | 
			
		||||
#  [*enabled*]
 | 
			
		||||
#    (optional) Should the service be enabled.
 | 
			
		||||
#    Defaults to true
 | 
			
		||||
#
 | 
			
		||||
#  [*manage_service*]
 | 
			
		||||
#    (optional) Whether the service should be managed by Puppet.
 | 
			
		||||
#    Defaults to true.
 | 
			
		||||
#
 | 
			
		||||
class heat::api (
 | 
			
		||||
  $manage_service    = true,
 | 
			
		||||
  $enabled           = true,
 | 
			
		||||
  $bind_host         = '0.0.0.0',
 | 
			
		||||
  $bind_port         = '8004',
 | 
			
		||||
@@ -32,11 +42,13 @@ class heat::api (
 | 
			
		||||
    name   => $::heat::params::api_package_name,
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if $manage_service {
 | 
			
		||||
    if $enabled {
 | 
			
		||||
      $service_ensure = 'running'
 | 
			
		||||
    } else {
 | 
			
		||||
      $service_ensure = 'stopped'
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  service { 'heat-api':
 | 
			
		||||
    ensure     => $service_ensure,
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,16 @@
 | 
			
		||||
# Installs & configure the heat CloudFormation API service
 | 
			
		||||
 | 
			
		||||
#
 | 
			
		||||
# == Parameters
 | 
			
		||||
#  [*enabled*]
 | 
			
		||||
#    (optional) Should the service be enabled.
 | 
			
		||||
#    Defaults to true
 | 
			
		||||
#
 | 
			
		||||
#  [*manage_service*]
 | 
			
		||||
#    (optional) Whether the service should be managed by Puppet.
 | 
			
		||||
#    Defaults to true.
 | 
			
		||||
#
 | 
			
		||||
class heat::api_cfn (
 | 
			
		||||
  $manage_service    = true,
 | 
			
		||||
  $enabled           = true,
 | 
			
		||||
  $bind_host         = '0.0.0.0',
 | 
			
		||||
  $bind_port         = '8000',
 | 
			
		||||
@@ -32,11 +42,13 @@ class heat::api_cfn (
 | 
			
		||||
    name   => $::heat::params::api_cfn_package_name,
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if $manage_service {
 | 
			
		||||
    if $enabled {
 | 
			
		||||
      $service_ensure = 'running'
 | 
			
		||||
    } else {
 | 
			
		||||
      $service_ensure = 'stopped'
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  Package['heat-common'] -> Service['heat-api-cfn']
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,16 @@
 | 
			
		||||
# Installs & configure the heat CloudWatch API service
 | 
			
		||||
 | 
			
		||||
#
 | 
			
		||||
# == Parameters
 | 
			
		||||
#  [*enabled*]
 | 
			
		||||
#    (optional) Should the service be enabled.
 | 
			
		||||
#    Defaults to true
 | 
			
		||||
#
 | 
			
		||||
#  [*manage_service*]
 | 
			
		||||
#    (optional) Whether the service should be managed by Puppet.
 | 
			
		||||
#    Defaults to true.
 | 
			
		||||
#
 | 
			
		||||
class heat::api_cloudwatch (
 | 
			
		||||
  $manage_service    = true,
 | 
			
		||||
  $enabled           = true,
 | 
			
		||||
  $bind_host         = '0.0.0.0',
 | 
			
		||||
  $bind_port         = '8003',
 | 
			
		||||
@@ -32,11 +42,14 @@ class heat::api_cloudwatch (
 | 
			
		||||
    name   => $::heat::params::api_cloudwatch_package_name,
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if $manage_service {
 | 
			
		||||
    if $enabled {
 | 
			
		||||
      $service_ensure = 'running'
 | 
			
		||||
    } else {
 | 
			
		||||
      $service_ensure = 'stopped'
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  Package['heat-common'] -> Service['heat-api-cloudwatch']
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -4,9 +4,13 @@
 | 
			
		||||
#
 | 
			
		||||
# == parameters
 | 
			
		||||
#  [*enabled*]
 | 
			
		||||
#    (optional) The state of the service
 | 
			
		||||
#    (optional) Should the service be enabled.
 | 
			
		||||
#    Defaults to true
 | 
			
		||||
#
 | 
			
		||||
#  [*manage_service*]
 | 
			
		||||
#    (optional) Whether the service should be managed by Puppet.
 | 
			
		||||
#    Defaults to true.
 | 
			
		||||
#
 | 
			
		||||
#  [*heat_stack_user_role*]
 | 
			
		||||
#    (optional) Keystone role for heat template-defined users
 | 
			
		||||
#    Defaults to 'heat_stack_user'
 | 
			
		||||
@@ -34,6 +38,7 @@
 | 
			
		||||
 | 
			
		||||
class heat::engine (
 | 
			
		||||
  $auth_encryption_key,
 | 
			
		||||
  $manage_service                = true,
 | 
			
		||||
  $enabled                       = true,
 | 
			
		||||
  $heat_stack_user_role          = 'heat_stack_user',
 | 
			
		||||
  $heat_metadata_server_url      = 'http://127.0.0.1:8000',
 | 
			
		||||
@@ -53,11 +58,13 @@ class heat::engine (
 | 
			
		||||
    name   => $::heat::params::engine_package_name,
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if $manage_service {
 | 
			
		||||
    if $enabled {
 | 
			
		||||
      $service_ensure = 'running'
 | 
			
		||||
    } else {
 | 
			
		||||
      $service_ensure = 'stopped'
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  service { 'heat-engine':
 | 
			
		||||
    ensure     => $service_ensure,
 | 
			
		||||
 
 | 
			
		||||
@@ -3,16 +3,14 @@ require 'spec_helper'
 | 
			
		||||
describe 'heat::api_cfn' do
 | 
			
		||||
 | 
			
		||||
  let :params do
 | 
			
		||||
    {
 | 
			
		||||
    { :enabled       => true,
 | 
			
		||||
      :manage_service => true,
 | 
			
		||||
      :bind_host      => '127.0.0.1',
 | 
			
		||||
      :bind_port      => '1234',
 | 
			
		||||
      :workers   => '0'
 | 
			
		||||
    }
 | 
			
		||||
      :workers        => '0' }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  let :facts do
 | 
			
		||||
    { :osfamily => 'Debian' }
 | 
			
		||||
  end
 | 
			
		||||
  shared_examples_for 'heat-api-cfn' do
 | 
			
		||||
 | 
			
		||||
    context 'config params' do
 | 
			
		||||
 | 
			
		||||
@@ -62,4 +60,70 @@ describe 'heat::api_cfn' do
 | 
			
		||||
      it { should contain_heat_config('heat_api_cfn/key_file').with_ensure('absent') }
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    [{:enabled => true}, {:enabled => false}].each do |param_hash|
 | 
			
		||||
      context "when service should be #{param_hash[:enabled] ? 'enabled' : 'disabled'}" do
 | 
			
		||||
        before do
 | 
			
		||||
          params.merge!(param_hash)
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        it 'configures heat-api-cfn service' do
 | 
			
		||||
 | 
			
		||||
          should contain_service('heat-api-cfn').with(
 | 
			
		||||
            :ensure     => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped',
 | 
			
		||||
            :name       => platform_params[:api_service_name],
 | 
			
		||||
            :enable     => params[:enabled],
 | 
			
		||||
            :hasstatus  => true,
 | 
			
		||||
            :hasrestart => true,
 | 
			
		||||
            :subscribe  => ['Exec[heat-dbsync]']
 | 
			
		||||
          )
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    context 'with disabled service managing' do
 | 
			
		||||
      before do
 | 
			
		||||
        params.merge!({
 | 
			
		||||
          :manage_service => false,
 | 
			
		||||
          :enabled        => false })
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      it 'configures heat-api-cfn service' do
 | 
			
		||||
 | 
			
		||||
        should contain_service('heat-api-cfn').with(
 | 
			
		||||
          :ensure     => nil,
 | 
			
		||||
          :name       => platform_params[:api_service_name],
 | 
			
		||||
          :enable     => false,
 | 
			
		||||
          :hasstatus  => true,
 | 
			
		||||
          :hasrestart => true,
 | 
			
		||||
          :subscribe  => ['Exec[heat-dbsync]']
 | 
			
		||||
        )
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  context 'on Debian platforms' do
 | 
			
		||||
    let :facts do
 | 
			
		||||
      { :osfamily => 'Debian' }
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    let :platform_params do
 | 
			
		||||
      { :api_service_name => 'heat-api-cfn' }
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it_configures 'heat-api-cfn'
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  context 'on RedHat platforms' do
 | 
			
		||||
    let :facts do
 | 
			
		||||
      { :osfamily => 'RedHat' }
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    let :platform_params do
 | 
			
		||||
      { :api_service_name => 'openstack-heat-api-cfn' }
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it_configures 'heat-api-cfn'
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -3,16 +3,14 @@ require 'spec_helper'
 | 
			
		||||
describe 'heat::api_cloudwatch' do
 | 
			
		||||
 | 
			
		||||
  let :params do
 | 
			
		||||
    {
 | 
			
		||||
    { :enabled        => true,
 | 
			
		||||
      :manage_service => true,
 | 
			
		||||
      :bind_host      => '127.0.0.1',
 | 
			
		||||
      :bind_port      => '1234',
 | 
			
		||||
      :workers   => '0'
 | 
			
		||||
    }
 | 
			
		||||
      :workers        => '0' }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  let :facts do
 | 
			
		||||
    { :osfamily => 'Debian' }
 | 
			
		||||
  end
 | 
			
		||||
  shared_examples_for 'heat-api-cloudwatch' do
 | 
			
		||||
 | 
			
		||||
    context 'config params' do
 | 
			
		||||
 | 
			
		||||
@@ -62,4 +60,69 @@ describe 'heat::api_cloudwatch' do
 | 
			
		||||
      it { should contain_heat_config('heat_api_cloudwatch/key_file').with_ensure('absent') }
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    [{:enabled => true}, {:enabled => false}].each do |param_hash|
 | 
			
		||||
      context "when service should be #{param_hash[:enabled] ? 'enabled' : 'disabled'}" do
 | 
			
		||||
        before do
 | 
			
		||||
          params.merge!(param_hash)
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        it 'configures heat-api-cloudwatch service' do
 | 
			
		||||
 | 
			
		||||
          should contain_service('heat-api-cloudwatch').with(
 | 
			
		||||
            :ensure     => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped',
 | 
			
		||||
            :name       => platform_params[:api_service_name],
 | 
			
		||||
            :enable     => params[:enabled],
 | 
			
		||||
            :hasstatus  => true,
 | 
			
		||||
            :hasrestart => true,
 | 
			
		||||
            :subscribe  => ['Exec[heat-dbsync]']
 | 
			
		||||
          )
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    context 'with disabled service managing' do
 | 
			
		||||
      before do
 | 
			
		||||
        params.merge!({
 | 
			
		||||
          :manage_service => false,
 | 
			
		||||
          :enabled        => false })
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      it 'configures heat-api-cloudwatch service' do
 | 
			
		||||
 | 
			
		||||
        should contain_service('heat-api-cloudwatch').with(
 | 
			
		||||
          :ensure     => nil,
 | 
			
		||||
          :name       => platform_params[:api_service_name],
 | 
			
		||||
          :enable     => false,
 | 
			
		||||
          :hasstatus  => true,
 | 
			
		||||
          :hasrestart => true,
 | 
			
		||||
          :subscribe  => ['Exec[heat-dbsync]']
 | 
			
		||||
        )
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  context 'on Debian platforms' do
 | 
			
		||||
    let :facts do
 | 
			
		||||
      { :osfamily => 'Debian' }
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    let :platform_params do
 | 
			
		||||
      { :api_service_name => 'heat-api-cloudwatch' }
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it_configures 'heat-api-cloudwatch'
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  context 'on RedHat platforms' do
 | 
			
		||||
    let :facts do
 | 
			
		||||
      { :osfamily => 'RedHat' }
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    let :platform_params do
 | 
			
		||||
      { :api_service_name => 'openstack-heat-api-cloudwatch' }
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it_configures 'heat-api-cloudwatch'
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -3,16 +3,14 @@ require 'spec_helper'
 | 
			
		||||
describe 'heat::api' do
 | 
			
		||||
 | 
			
		||||
  let :params do
 | 
			
		||||
    {
 | 
			
		||||
    { :enabled        => true,
 | 
			
		||||
      :manage_service => true,
 | 
			
		||||
      :bind_host      => '127.0.0.1',
 | 
			
		||||
      :bind_port      => '1234',
 | 
			
		||||
      :workers   => '0'
 | 
			
		||||
    }
 | 
			
		||||
      :workers        => '0' }
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  let :facts do
 | 
			
		||||
    { :osfamily => 'Debian' }
 | 
			
		||||
  end
 | 
			
		||||
  shared_examples_for 'heat-api' do
 | 
			
		||||
 | 
			
		||||
    context 'config params' do
 | 
			
		||||
 | 
			
		||||
@@ -62,4 +60,72 @@ describe 'heat::api' do
 | 
			
		||||
      it { should contain_heat_config('heat_api/key_file').with_ensure('absent') }
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    [{:enabled => true}, {:enabled => false}].each do |param_hash|
 | 
			
		||||
      context "when service should be #{param_hash[:enabled] ? 'enabled' : 'disabled'}" do
 | 
			
		||||
        before do
 | 
			
		||||
          params.merge!(param_hash)
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        it 'configures heat-api service' do
 | 
			
		||||
 | 
			
		||||
          should contain_service('heat-api').with(
 | 
			
		||||
            :ensure     => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped',
 | 
			
		||||
            :name       => platform_params[:api_service_name],
 | 
			
		||||
            :enable     => params[:enabled],
 | 
			
		||||
            :hasstatus  => true,
 | 
			
		||||
            :hasrestart => true,
 | 
			
		||||
            :require    => ['Package[heat-common]', 'Package[heat-api]'],
 | 
			
		||||
            :subscribe  => ['Exec[heat-dbsync]']
 | 
			
		||||
          )
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    context 'with disabled service managing' do
 | 
			
		||||
      before do
 | 
			
		||||
        params.merge!({
 | 
			
		||||
          :manage_service => false,
 | 
			
		||||
          :enabled        => false })
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      it 'configures heat-api service' do
 | 
			
		||||
 | 
			
		||||
        should contain_service('heat-api').with(
 | 
			
		||||
          :ensure     => nil,
 | 
			
		||||
          :name       => platform_params[:api_service_name],
 | 
			
		||||
          :enable     => false,
 | 
			
		||||
          :hasstatus  => true,
 | 
			
		||||
          :hasrestart => true,
 | 
			
		||||
          :require    => ['Package[heat-common]', 'Package[heat-api]'],
 | 
			
		||||
          :subscribe  => ['Exec[heat-dbsync]']
 | 
			
		||||
        )
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  context 'on Debian platforms' do
 | 
			
		||||
    let :facts do
 | 
			
		||||
      { :osfamily => 'Debian' }
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    let :platform_params do
 | 
			
		||||
      { :api_service_name => 'heat-api' }
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it_configures 'heat-api'
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  context 'on RedHat platforms' do
 | 
			
		||||
    let :facts do
 | 
			
		||||
      { :osfamily => 'RedHat' }
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    let :platform_params do
 | 
			
		||||
      { :api_service_name => 'openstack-heat-api' }
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it_configures 'heat-api'
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,7 @@ describe 'heat::engine' do
 | 
			
		||||
 | 
			
		||||
  let :default_params do
 | 
			
		||||
    { :enabled                       => true,
 | 
			
		||||
      :manage_service                => true,
 | 
			
		||||
      :heat_stack_user_role          => 'heat_stack_user',
 | 
			
		||||
      :heat_metadata_server_url      => 'http://127.0.0.1:8000',
 | 
			
		||||
      :heat_waitcondition_server_url => 'http://127.0.0.1:8000/v1/waitcondition',
 | 
			
		||||
@@ -38,7 +39,7 @@ describe 'heat::engine' do
 | 
			
		||||
      it { should contain_package('heat-engine').with_name(os_params[:package_name]) }
 | 
			
		||||
 | 
			
		||||
      it { should contain_service('heat-engine').with(
 | 
			
		||||
        :ensure     => expected_params[:enabled] ? 'running' : 'stopped',
 | 
			
		||||
        :ensure     => (expected_params[:manage_service] && expected_params[:enabled]) ? 'running' : 'stopped',
 | 
			
		||||
        :name       => os_params[:service_name],
 | 
			
		||||
        :enable     => expected_params[:enabled],
 | 
			
		||||
        :hasstatus  => 'true',
 | 
			
		||||
@@ -56,6 +57,26 @@ describe 'heat::engine' do
 | 
			
		||||
      it { should contain_heat_config('DEFAULT/heat_watch_server_url').with_value( expected_params[:heat_watch_server_url] ) }
 | 
			
		||||
      it { should contain_heat_config('DEFAULT/engine_life_check_timeout').with_value( expected_params[:engine_life_check_timeout] ) }
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    context 'with disabled service managing' do
 | 
			
		||||
      before do
 | 
			
		||||
        params.merge!({
 | 
			
		||||
          :manage_service => false,
 | 
			
		||||
          :enabled        => false })
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      it { should contain_service('heat-engine').with(
 | 
			
		||||
        :ensure     => nil,
 | 
			
		||||
        :name       => os_params[:service_name],
 | 
			
		||||
        :enable     => false,
 | 
			
		||||
        :hasstatus  => 'true',
 | 
			
		||||
        :hasrestart => 'true',
 | 
			
		||||
        :require    => [ 'File[/etc/heat/heat.conf]',
 | 
			
		||||
                         'Package[heat-common]',
 | 
			
		||||
                         'Package[heat-engine]'],
 | 
			
		||||
        :subscribe  => 'Exec[heat-dbsync]'
 | 
			
		||||
      ) }
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  context 'on Debian platforms' do
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user