Showing with 39 additions and 4 deletions.
  1. +6 −0 .github/pull_request_template.md
  2. +8 −0 CHANGELOG.md
  3. +5 −2 lib/facter/self_service.rb
  4. +1 −1 metadata.json
  5. +19 −1 spec/acceptance/self_service_spec.rb
6 changes: 6 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## Please check off the steps below as you complete each step
- [ ] Put the Jira ticket number in parentheses in the **Title** e.g. `(SUP-XXXX) Add Super Duper State Check`
- [ ] Update the Jira ticket status to `Ready for Review`
- [ ] Update the Scoring Spreadsheet
- [ ] Get a **review** from someone on the support team
- [ ] Get a **review** from @misseuropa, @davidbastedo, or @deleon365
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org).

## [v0.2.0](https://github.com/puppetlabs/puppetlabs-self_service/tree/v0.2.0) (2022-01-11)

[Full Changelog](https://github.com/puppetlabs/puppetlabs-self_service/compare/v0.1.0...v0.2.0)

### Added

- \(SUP-2898\) Available Memory on the platform is less than 10% [\#18](https://github.com/puppetlabs/puppetlabs-self_service/pull/18) ([MartyEwings](https://github.com/MartyEwings))

## [v0.1.0](https://github.com/puppetlabs/puppetlabs-self_service/tree/v0.1.0) (2021-12-14)

[Full Changelog](https://github.com/puppetlabs/puppetlabs-self_service/compare/f6d5d880a989fad41190a0df43e8dc0a34713df2...v0.1.0)
Expand Down
7 changes: 5 additions & 2 deletions lib/facter/self_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
chunk(:S0012) do
summary_path = Puppet.settings['lastrunfile']
next unless File.exist?(summary_path)
next unless PuppetSelfService.replica? || PuppetSelfService.postgres? || PuppetSelfService.primary? || PuppetSelfService.compiler? || PuppetSelfService.legacy_compiler?
# Did Puppet Produce a report in the last run interval
lastrunfile = YAML.load_file(summary_path)
time_lastrun = lastrunfile.dig('time', 'last_run')
Expand All @@ -105,8 +104,12 @@
chunk(:S0013) do
summary_path = Puppet.settings['lastrunfile']
next unless File.exist?(summary_path)
next unless PuppetSelfService.replica? || PuppetSelfService.postgres? || PuppetSelfService.primary? || PuppetSelfService.compiler? || PuppetSelfService.legacy_compiler?
# Did catalog apply successfully on last puppet run
{ S0013: File.open(summary_path).read.include?('catalog_application') }
end

chunk(:S0021) do
# Is there at least 9% memory available
{ S0021: Facter.value(:memory)['system']['capacity'].to_f <= 90 }
end
end
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "puppetlabs-self_service",
"version": "0.1.0",
"version": "0.2.0",
"author": "Marty Ewings",
"summary": "A Puppet Enterprise Module to Promote Preventative Maintenance and Self Service",
"license": "Apache-2.0",
Expand Down
20 changes: 19 additions & 1 deletion spec/acceptance/self_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# Test Confirms all facts are false which is another indicator the class is performing correctly
describe 'check no self_service fact is false' do
it 'if idempotent all facts should be true' do
expect(host_inventory['facter']['self_service'].size).to eq(13)
expect(host_inventory['facter']['self_service'].size).to eq(14)
expect(host_inventory['facter']['self_service'].filter { |_k, v| !v }).to be_empty
end
end
Expand Down Expand Up @@ -124,6 +124,24 @@ class {'self_service':
expect(result.stdout).to match(%r{false})
run_shell('export lastrunfile=$(puppet config print lastrunfile) && mv -f ${lastrunfile}.bk $lastrunfile')
end
it 'if S0021 conditions for false are met' do
run_shell('mkdir -p /etc/puppetlabs/facter/facts.d/;echo \'{
"memory": {
"system": {
"available": "10.32 GiB",
"available_bytes": 11076337664,
"capacity": "95.27%",
"total": "15.46 GiB",
"total_bytes": 16598274048,
"used": "5.14 GiB",
"used_bytes": 5521936384
}
}
}\' > /etc/puppetlabs/facter/facts.d/memory.json')
result = run_shell('facter -p self_service.S0021')
expect(result.stdout).to match(%r{false})
run_shell('rm -f /etc/puppetlabs/facter/facts.d/memory.json')
end
end
end
end