diff --git a/deployment/puppet/nailgun/lib/facter/acpi_event.rb b/deployment/puppet/nailgun/lib/facter/acpi_event.rb new file mode 100644 index 0000000000..c9ceaa85fa --- /dev/null +++ b/deployment/puppet/nailgun/lib/facter/acpi_event.rb @@ -0,0 +1,5 @@ +Facter.add('acpi_event') do + setcode do + File.exist?('/proc/acpi/event') + end +end diff --git a/deployment/puppet/nailgun/manifests/host.pp b/deployment/puppet/nailgun/manifests/host.pp index 420457ecc8..c19f00f71f 100644 --- a/deployment/puppet/nailgun/manifests/host.pp +++ b/deployment/puppet/nailgun/manifests/host.pp @@ -126,4 +126,11 @@ $admin_iface = 'eth0', command => "sed -i -e 's|http://\(.*\):8000\(.*\)|https://\1:8443\2|g' /etc/issue", onlyif => 'grep -q 8000 /etc/issue', } + + if $::acpi_event == 'true' and $::virtual != 'physical' { + service { 'acpid': + ensure => 'running', + enable => true, + } + } } diff --git a/deployment/puppet/nailgun/manifests/packages.pp b/deployment/puppet/nailgun/manifests/packages.pp index 61dd919572..6abf1108fe 100644 --- a/deployment/puppet/nailgun/manifests/packages.pp +++ b/deployment/puppet/nailgun/manifests/packages.pp @@ -20,4 +20,5 @@ class nailgun::packages( nailgun_safe_package { "python-fuelclient": } nailgun_safe_package { "screen": } nailgun_safe_package { "fuel-migrate": } + nailgun_safe_package { "acpid": } } diff --git a/deployment/puppet/osnailyfacter/manifests/acpid.pp b/deployment/puppet/osnailyfacter/manifests/acpid.pp new file mode 100644 index 0000000000..beb324e73e --- /dev/null +++ b/deployment/puppet/osnailyfacter/manifests/acpid.pp @@ -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, + } +} + diff --git a/deployment/puppet/osnailyfacter/modular/tools/tools.pp b/deployment/puppet/osnailyfacter/modular/tools/tools.pp index fe2a5747c1..82d876c77e 100644 --- a/deployment/puppet/osnailyfacter/modular/tools/tools.pp +++ b/deployment/puppet/osnailyfacter/modular/tools/tools.pp @@ -1,9 +1,12 @@ notice('MODULAR: tools.pp') class { 'osnailyfacter::atop': } - class { 'osnailyfacter::ssh': } +if $::virtual != 'physical' { + class { 'osnailyfacter::acpid': } +} + $tools = [ 'screen', 'tmux', diff --git a/deployment/puppet/osnailyfacter/modular/tools/tools_post.rb b/deployment/puppet/osnailyfacter/modular/tools/tools_post.rb index dec88a2da5..f083d86d99 100644 --- a/deployment/puppet/osnailyfacter/modular/tools/tools_post.rb +++ b/deployment/puppet/osnailyfacter/modular/tools/tools_post.rb @@ -1,6 +1,7 @@ require File.join File.dirname(__FILE__), '../test_common.rb' TOOLS = %w( +acpid screen tmux man diff --git a/tests/noop/spec/hosts/tools/tools_spec.rb b/tests/noop/spec/hosts/tools/tools_spec.rb index 7c8703a730..a025a06ddc 100644 --- a/tests/noop/spec/hosts/tools/tools_spec.rb +++ b/tests/noop/spec/hosts/tools/tools_spec.rb @@ -2,6 +2,18 @@ require 'spec_helper' require 'shared-examples' manifest = 'tools/tools.pp' +tools = [ + 'screen', + 'tmux', + 'man', + 'htop', + 'tcpdump', + 'strace', + 'fuel-misc' +] + +puppet = Noop.hiera('puppet') + describe manifest do shared_examples 'catalog' do it "should contain ssh host keygen exec for Debian OS only" do @@ -15,6 +27,33 @@ describe manifest do 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 end -