Skip to content

Commit

Permalink
Merge pull request #10 from voxpupuli/tests
Browse files Browse the repository at this point in the history
bolt::project: fail if we are not on PE
  • Loading branch information
bastelfreak authored May 23, 2024
2 parents e0cc843 + 7123f78 commit a4d78a6
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 17 deletions.
1 change: 1 addition & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ fixtures:
stdlib: https://github.com/puppetlabs/puppetlabs-stdlib.git
sudo: https://github.com/saz/puppet-sudo.git
systemd: https://github.com/voxpupuli/puppet-systemd.git
pe_status_check: https://github.com/puppetlabs/puppetlabs-pe_status_check.git
yumrepo_core: https://github.com/puppetlabs/puppetlabs-yumrepo_core.git
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ jobs:
puppet:
name: Puppet
uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v2
with:
pidfile_workaround: 'false'
beaker_facter: 'pe_status_check_role:PE-Role:primary'
3 changes: 3 additions & 0 deletions .sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ spec/spec_helper_acceptance.rb:
enabled_lint_checks:
- parameter_documentation
- parameter_types
.github/workflows/ci.yml:
with:
beaker_facter: 'pe_status_check_role:PE-Role:primary'
3 changes: 3 additions & 0 deletions manifests/project.pp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
String[1] $environment = 'peadm',
Array[Stdlib::Absolutepath] $modulepaths = ["/etc/puppetlabs/code/environments/${environment}/modules", "/etc/puppetlabs/code/environments/${environment}/site",],
) {
unless $facts['pe_status_check_role'] in ['primary', 'legacy_primary', 'pe_compiler', 'legacy_compiler'] {
fail("bolt::project works only on PE primaries and compilers, not: ${facts['pe_status_check_role']}")
}
# installs bolt
require bolt

Expand Down
4 changes: 4 additions & 0 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
"name": "puppetlabs/stdlib",
"version_requirement": ">= 9.6.0 < 10.0.0"
},
{
"name": "puppetlabs/pe_status_check",
"version_requirement": ">= 4.2.0 < 5.0.0"
},
{
"name": "puppet/systemd",
"version_requirement": ">= 7.0.0 < 8.0.0"
Expand Down
47 changes: 30 additions & 17 deletions spec/defines/project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,39 @@

on_supported_os.each do |os, os_facts|
context "on #{os}" do
let :facts do
os_facts.merge({ sudoversion: '1.9.5p2' })
end

context 'with defaults' do
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_class('bolt') }
it { is_expected.to contain_file('/opt/peadm/bolt-project.yaml').with_ensure('file') }
it { is_expected.to contain_file('/opt/peadm/inventory.yaml').with_ensure('file') }
it { is_expected.to contain_file('/opt/peadm').with_ensure('directory') }
it { is_expected.to contain_user(title) }
it { is_expected.to contain_group(title) }
it { is_expected.to contain_package('puppet-bolt') }
it { is_expected.to contain_package('puppet-tools-release') }
it { is_expected.not_to contain_yumrepo('puppet-tools') }
it { is_expected.to contain_sudo__conf(title) }
it { is_expected.to contain_systemd__unit_file("#{title}@.service") }
context 'on FOSS' do
let :facts do
os_facts
end

it { is_expected.not_to compile }
end

context 'on PE' do
let :facts do
os_facts.merge({ pe_status_check_role: 'primary', sudoversion: '1.9.5p2' })
end

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_class('bolt') }
it { is_expected.to contain_file('/opt/peadm/bolt-project.yaml').with_ensure('file') }
it { is_expected.to contain_file('/opt/peadm/inventory.yaml').with_ensure('file') }
it { is_expected.to contain_file('/opt/peadm').with_ensure('directory') }
it { is_expected.to contain_user(title) }
it { is_expected.to contain_group(title) }
it { is_expected.to contain_package('puppet-bolt') }
it { is_expected.to contain_package('puppet-tools-release') }
it { is_expected.not_to contain_yumrepo('puppet-tools') }
it { is_expected.to contain_sudo__conf(title) }
it { is_expected.to contain_systemd__unit_file("#{title}@.service") }
end
end

context 'with manage_user=false' do
context 'with manage_user=false on PE' do
let :facts do
os_facts.merge({ pe_status_check_role: 'primary', sudoversion: '1.9.5p2' })
end
let :params do
{ manage_user: false }
end
Expand Down

0 comments on commit a4d78a6

Please sign in to comment.