Skip to content

Commit

Permalink
fwv
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoblitt committed Dec 1, 2023
1 parent 048eafe commit 744f3df
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 13 deletions.
6 changes: 0 additions & 6 deletions .fixtures.yml

This file was deleted.

3 changes: 3 additions & 0 deletions examples/powertop_absent.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class { 'powertop':
ensure => 'absent',
}
1 change: 1 addition & 0 deletions examples/powertop_present.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include powertop
20 changes: 19 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
#
# @summary Manages powertop
#
class powertop {
# @param ensure
# Whether powertop should be present or absent.
#
class powertop (
Enum['present', 'absent'] $ensure = 'present',
) {
$pkg_name = 'powertop'

package { $pkg_name:
ensure => $ensure,
}

if $ensure == present {
# powertop service unit tweaks values and then exits. There is no persistent daemon.
service { 'powertop':
enable => true,
require => Package[$pkg_name],
}
}
}
7 changes: 1 addition & 6 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@
"summary": "powertop module",
"license": "AGPL-3.0",
"source": "https://github.com/lsst-it/puppet-powertop",
"dependencies": [
{
"name": "puppetlabs/stdlib",
"version_requirement": ">= 8.0.0 < 10.0.0"
}
],
"dependencies": [],
"operatingsystem_support": [
{
"operatingsystem": "CentOS",
Expand Down
29 changes: 29 additions & 0 deletions spec/acceptance/powertop_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: true

require 'spec_helper_acceptance'

describe 'powertop class' do
context 'without any parameters' do
include_examples 'the example', 'powertop_present.pp'

describe package('powertop') do
it { is_expected.to be_installed }
end

describe service('powertop') do
it { is_expected.to be_enabled }
end
end

context 'with parameters =>' do
include_examples 'the example', 'powertop_absent.pp'

describe package('powertop') do
it { is_expected.not_to be_installed }
end

describe service('powertop') do
it { is_expected.not_to be_enabled }
end
end
end
13 changes: 13 additions & 0 deletions spec/classes/powertop_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

require 'spec_helper'

describe 'powertop' do
on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:facts) { os_facts }

it { is_expected.to compile.with_all_deps }
end
end
end

0 comments on commit 744f3df

Please sign in to comment.