Showing with 48 additions and 17 deletions.
  1. +9 −3 .github/workflows/auto_release.yml
  2. +8 −0 CHANGELOG.md
  3. +5 −1 functions/hosts_with_pe_profile.pp
  4. +1 −1 metadata.json
  5. +14 −2 spec/acceptance/functions/hosts_with_pe_profile_spec.rb
  6. +11 −10 spec/acceptance/pe_metric_spec.rb
12 changes: 9 additions & 3 deletions .github/workflows/auto_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,14 @@ jobs:
run: |
echo "::set-output name=ver::$(jq --raw-output .version metadata.json)"
- name: "Commit changes"
- name: "Check if a release is necessary"
if: ${{ github.repository_owner == 'puppetlabs' }}
id: check
run: |
git diff --quiet CHANGELOG.md && echo "::set-output name=release::false" || echo "::set-output name=release::true"
- name: "Commit changes"
if: ${{ github.repository_owner == 'puppetlabs' && steps.check.outputs.release == 'true' }}
run: |
git config --local user.email "${{ github.repository_owner }}@users.noreply.github.com"
git config --local user.name "GitHub Action"
Expand All @@ -59,7 +65,7 @@ jobs:
- name: Create Pull Request
id: cpr
uses: puppetlabs/peter-evans-create-pull-request@v3
if: ${{ github.repository_owner == 'puppetlabs' }}
if: ${{ github.repository_owner == 'puppetlabs' && steps.check.outputs.release == 'true' }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Release prep v${{ steps.gv.outputs.ver }}"
Expand All @@ -75,7 +81,7 @@ jobs:
labels: "maintenance"

- name: PR outputs
if: ${{ github.repository_owner == 'puppetlabs' }}
if: ${{ github.repository_owner == 'puppetlabs' && steps.check.outputs.release == 'true' }}
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
Expand Down
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).

## [v7.0.3](https://github.com/puppetlabs/puppetlabs-puppet_metrics_collector/tree/v7.0.3) (2021-07-20)

[Full Changelog](https://github.com/puppetlabs/puppetlabs-puppet_metrics_collector/compare/v7.0.2...v7.0.3)

### Fixed

- \(maint\) Change default for hosts\_with\_pe\_profile when storeconfigs is false [\#141](https://github.com/puppetlabs/puppetlabs-puppet_metrics_collector/pull/141) ([nmburgan](https://github.com/nmburgan))

## [v7.0.2](https://github.com/puppetlabs/puppetlabs-puppet_metrics_collector/tree/v7.0.2) (2021-07-19)

[Full Changelog](https://github.com/puppetlabs/puppetlabs-puppet_metrics_collector/compare/v7.0.1...v7.0.2)
Expand Down
6 changes: 5 additions & 1 deletion functions/hosts_with_pe_profile.pp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ function puppet_metrics_collector::hosts_with_pe_profile($profile) {
}

if empty($hosts) {
['127.0.0.1']
$default = $facts['clientcert'] ? {
undef => '127.0.0.1',
default => $facts['clientcert']
}
[$default]
}
else {
sort($hosts)
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "puppetlabs-puppet_metrics_collector",
"version": "7.0.2",
"version": "7.0.3",
"author": "puppetlabs",
"summary": "A Puppet module for gathering metrics from PE components",
"license": "Apache-2.0",
Expand Down
16 changes: 14 additions & 2 deletions spec/acceptance/functions/hosts_with_pe_profile_spec.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
require 'spec_helper_acceptance'

describe 'hosts_with_pe_profile function' do
it 'returns 127.0.0.1 when no hosts are found' do
it 'returns the certname of the node when no hosts are found' do
pp = <<-MANIFEST
$result=puppet_metrics_collector::hosts_with_pe_profile('non_existant')
notice "Received=$result"
MANIFEST
output = apply_manifest(pp).stdout
expect(output).to match(%r{Received=\[127.0.0.1\]})
expect(output).to match(%r{Received=\[#{host_inventory['fqdn']}\]})
end

it 'return the FQDN for the master profile' do
# This influences the custom facts
run_shell('puppet config set storeconfigs true --section user', expect_failures: false)
Expand All @@ -20,4 +21,15 @@
expect(output).to match(%r{Received=\[#{host_inventory['fqdn']}\]})
run_shell('puppet config set storeconfigs false --section user', expect_failures: false)
end

it 'returns the certname of the node when storeconfigs is false' do
# Should be set to false in the previous section
# In this case, the certname == fqdn, so we use that here
pp = <<-MANIFEST
$result=puppet_metrics_collector::hosts_with_pe_profile('master')
notice "Received=$result"
MANIFEST
output = apply_manifest(pp).stdout
expect(output).to match(%r{Received=\[#{host_inventory['fqdn']}\]})
end
end
21 changes: 11 additions & 10 deletions spec/acceptance/pe_metric_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'spec_helper_acceptance'

certname = host_inventory['fqdn']
describe 'default includes' do
before(:all) do
pp = <<-MANIFEST
Expand Down Expand Up @@ -31,52 +32,52 @@
expect(files.split("\n").count).to eq(5)
end

describe file('/opt/puppetlabs/puppet-metrics-collector/puppetserver/127.0.0.1') do
describe file("/opt/puppetlabs/puppet-metrics-collector/puppetserver/#{certname}") do
before(:each) { run_shell('systemctl start puppet_puppetserver-metrics.service') }

it { is_expected.to be_directory }
it 'contains metric files' do
files = run_shell('ls /opt/puppetlabs/puppet-metrics-collector/puppetserver/127.0.0.1/*').stdout
files = run_shell("ls /opt/puppetlabs/puppet-metrics-collector/puppetserver/#{certname}/*").stdout
expect(files.split('\n')).not_to be_empty
end
end

describe file('/opt/puppetlabs/puppet-metrics-collector/puppetdb/127.0.0.1') do
describe file("/opt/puppetlabs/puppet-metrics-collector/puppetdb/#{certname}") do
before(:each) { run_shell('systemctl start puppet_puppetdb-metrics.service') }

it { is_expected.to be_directory }
it 'contains metric files' do
files = run_shell('ls /opt/puppetlabs/puppet-metrics-collector/puppetdb/127.0.0.1/*').stdout
files = run_shell("ls /opt/puppetlabs/puppet-metrics-collector/puppetdb/#{certname}/*").stdout
expect(files.split('\n')).not_to be_empty
end
end

describe file('/opt/puppetlabs/puppet-metrics-collector/orchestrator/127.0.0.1') do
describe file("/opt/puppetlabs/puppet-metrics-collector/orchestrator/#{certname}") do
before(:each) { run_shell('systemctl start puppet_orchestrator-metrics.service') }

it { is_expected.to be_directory }
it 'contains metric files' do
files = run_shell('ls /opt/puppetlabs/puppet-metrics-collector/orchestrator/127.0.0.1/*').stdout
files = run_shell("ls /opt/puppetlabs/puppet-metrics-collector/orchestrator/#{certname}/*").stdout
expect(files.split('\n')).not_to be_empty
end
end

describe file('/opt/puppetlabs/puppet-metrics-collector/ace/127.0.0.1') do
describe file("/opt/puppetlabs/puppet-metrics-collector/ace/#{certname}") do
before(:each) { run_shell('systemctl start puppet_ace-metrics.service') }

it { is_expected.to be_directory }
it 'contains metric files' do
files = run_shell('ls /opt/puppetlabs/puppet-metrics-collector/ace/127.0.0.1/*').stdout
files = run_shell("ls /opt/puppetlabs/puppet-metrics-collector/ace/#{certname}/*").stdout
expect(files.split('\n')).not_to be_empty
end
end

describe file('/opt/puppetlabs/puppet-metrics-collector/bolt/127.0.0.1') do
describe file("/opt/puppetlabs/puppet-metrics-collector/bolt/#{certname}") do
before(:each) { run_shell('systemctl start puppet_bolt-metrics.service') }

it { is_expected.to be_directory }
it 'contains metric files' do
files = run_shell('ls /opt/puppetlabs/puppet-metrics-collector/bolt/127.0.0.1/*').stdout
files = run_shell("ls /opt/puppetlabs/puppet-metrics-collector/bolt/#{certname}/*").stdout
expect(files.split('\n')).not_to be_empty
end
end
Expand Down