Merge "Allow user to define a custom tuned profile"

This commit is contained in:
Zuul 2018-12-13 17:39:57 +00:00 committed by Gerrit Code Review
commit 9255b7d1c5
2 changed files with 43 additions and 2 deletions

View File

@ -8,11 +8,31 @@
# (optional) tuned active profile.
# Defaults to 'throughput-performance'
#
# [*custom_profile*]
# (optional) string in INI format defining a custom profile
# Defaults to undef
#
class tripleo::profile::base::tuned (
$profile = 'throughput-performance'
$profile = 'throughput-performance',
$custom_profile = undef
) {
ensure_resource('package', 'tuned', { ensure => 'present' })
if !empty($custom_profile) {
file { "/etc/tuned/${profile}":
ensure => 'directory',
owner => 'root',
group => 'root',
mode => '0755',
} ->
file { "/etc/tuned/${profile}/tuned.conf":
before => Exec['tuned-adm'],
ensure => present,
owner => 'root',
group => 'root',
mode => '0644',
content => $custom_profile,
}
}
exec { 'tuned-adm':
path => ['/bin', '/usr/bin', '/sbin', '/usr/sbin'],
command => "tuned-adm profile ${profile}",

View File

@ -30,8 +30,29 @@ describe 'tripleo::profile::base::tuned' do
is_expected.to contain_exec('tuned-adm')
end
end
end
context 'with custom profile' do
let :params do
{
:profile => 'custom',
:custom_profile => 'foo'
}
end
it 'should create a custom tuned profile' do
is_expected.to contain_file('/etc/tuned/custom/tuned.conf').with({
'content' => 'foo',
'owner' => 'root',
'group' => 'root',
'mode' => '0644',
})
end
it 'should run a tuned-adm exec to set the custom profile' do
is_expected.to contain_exec('tuned-adm').with_command(
'tuned-adm profile custom'
)
end
end
end
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) {