diff --git a/manifests/profile/base/tuned.pp b/manifests/profile/base/tuned.pp index 48951bdf5..089e5fb91 100644 --- a/manifests/profile/base/tuned.pp +++ b/manifests/profile/base/tuned.pp @@ -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}", diff --git a/spec/classes/tripleo_profile_base_tuned_spec.rb b/spec/classes/tripleo_profile_base_tuned_spec.rb index 95b0f268e..58b94fd71 100644 --- a/spec/classes/tripleo_profile_base_tuned_spec.rb +++ b/spec/classes/tripleo_profile_base_tuned_spec.rb @@ -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) {