Install and start acpid on virtual nodes

Some users may be running various nodes (including master node since
7.0) as virtual machines – acpid allows them to do graceful shutdown or
reboot without using ssh.

The commit introduces custom fact to check if ACPI is available via
procfs on machine. acpid itself is only installed and started if node is
not physical and has ACPI.

Closes-Bug: 1470172
Change-Id: I4186b4a2fbb57a0c63123377f986f888c27aa13e
Co-authored-by: Bartłomiej Piotrowski <bpiotrowski@mirantis.com>
This commit is contained in:
Mykola Grygoriev 2015-07-09 15:22:45 +03:00 committed by Bartłomiej Piotrowski
parent 37e1a0ee9f
commit be35055538
7 changed files with 85 additions and 2 deletions

View File

@ -0,0 +1,5 @@
Facter.add('acpi_event') do
setcode do
File.exist?('/proc/acpi/event')
end
end

View File

@ -126,4 +126,11 @@ $admin_iface = 'eth0',
command => "sed -i -e 's|http://\(.*\):8000\(.*\)|https://\1:8443\2|g' /etc/issue", command => "sed -i -e 's|http://\(.*\):8000\(.*\)|https://\1:8443\2|g' /etc/issue",
onlyif => 'grep -q 8000 /etc/issue', onlyif => 'grep -q 8000 /etc/issue',
} }
if $::acpi_event == 'true' and $::virtual != 'physical' {
service { 'acpid':
ensure => 'running',
enable => true,
}
}
} }

View File

@ -20,4 +20,5 @@ class nailgun::packages(
nailgun_safe_package { "python-fuelclient": } nailgun_safe_package { "python-fuelclient": }
nailgun_safe_package { "screen": } nailgun_safe_package { "screen": }
nailgun_safe_package { "fuel-migrate": } nailgun_safe_package { "fuel-migrate": }
nailgun_safe_package { "acpid": }
} }

View File

@ -0,0 +1,27 @@
# == Class: osnailyfacter::acpid
#
# Allow to install and configure acpid.
#
# === Parameters
#
# [*service_enabled*]
# Enable acpid service, default to true.
#
# [*service_state*]
# Start acpid service, default to running.
#
class osnailyfacter::acpid (
$service_enabled = true,
$service_state = 'running',
){
package { 'acpid':
ensure => 'installed',
} ->
service { 'acpid':
ensure => $service_state,
enable => $service_enabled,
}
}

View File

@ -1,9 +1,12 @@
notice('MODULAR: tools.pp') notice('MODULAR: tools.pp')
class { 'osnailyfacter::atop': } class { 'osnailyfacter::atop': }
class { 'osnailyfacter::ssh': } class { 'osnailyfacter::ssh': }
if $::virtual != 'physical' {
class { 'osnailyfacter::acpid': }
}
$tools = [ $tools = [
'screen', 'screen',
'tmux', 'tmux',

View File

@ -1,6 +1,7 @@
require File.join File.dirname(__FILE__), '../test_common.rb' require File.join File.dirname(__FILE__), '../test_common.rb'
TOOLS = %w( TOOLS = %w(
acpid
screen screen
tmux tmux
man man

View File

@ -2,6 +2,18 @@ require 'spec_helper'
require 'shared-examples' require 'shared-examples'
manifest = 'tools/tools.pp' manifest = 'tools/tools.pp'
tools = [
'screen',
'tmux',
'man',
'htop',
'tcpdump',
'strace',
'fuel-misc'
]
puppet = Noop.hiera('puppet')
describe manifest do describe manifest do
shared_examples 'catalog' do shared_examples 'catalog' do
it "should contain ssh host keygen exec for Debian OS only" do it "should contain ssh host keygen exec for Debian OS only" do
@ -15,6 +27,33 @@ describe manifest do
end end
end end
shared_examples 'catalog' do
it 'should declare tools classes' do
should contain_class('osnailyfacter::atop')
should contain_class('osnailyfacter::ssh')
should contain_class('puppet::pull').with(
{'modules_source' => puppet['modules']},
{'manifests_source' => puppet['manifests']}
)
end
it 'should declare osnailyfacter::acpid on virtual machines' do
facts[:virtual] = 'kvm'
should contain_class('osnailyfacter::acpid')
end
tools.each do |i|
it do
should contain_package(i).with({
'ensure' => 'present'})
end
end
it do
should contain_package('cloud-init').with({
'ensure' => 'purged'})
end
end
test_ubuntu_and_centos manifest test_ubuntu_and_centos manifest
end end