Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
2 changes: 2 additions & 0 deletions data/kernel/Linux.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
os_patching::puppet_binary_dir: '/opt/puppetlabs/bin'
2 changes: 2 additions & 0 deletions data/kernel/windows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
os_patching::puppet_binary_dir: 'C:/Program Files/Puppet Labs/Puppet/bin'
13 changes: 13 additions & 0 deletions hiera.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
version: 5

defaults:
datadir: 'data'
data_hash: 'yaml_data'

hierarchy:
- name: 'System kernel'
path: 'kernel/%{facts.kernel}.yaml'

- name: 'common'
path: 'common.yaml'
6 changes: 5 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# @summary This manifest sets up a script and cron job to populate
# the `os_patching` fact.
#
# @param puppet_binary_dir [String]
# Location of the Puppet binaries
#
# @param patch_data_owner [String]
# User name for the owner of the patch data
#
Expand Down Expand Up @@ -130,6 +133,7 @@
# ensure => absent,
# }
class os_patching (
String $puppet_binary_dir,
String $patch_data_owner = 'root',
String $patch_data_group = 'root',
String $patch_cron_user = $patch_data_owner,
Expand Down Expand Up @@ -175,7 +179,7 @@
}
}
'windows': {
$fact_upload_cmd = '"C:/Program Files/Puppet Labs/Puppet/bin/puppet.bat" facts upload'
$fact_upload_cmd = "\"${puppet_binary_dir}/puppet.bat\" facts upload"
$cache_dir = 'C:/ProgramData/os_patching'
$fact_dir = $cache_dir
$fact_file = 'os_patching_fact_generation.ps1'
Expand Down
36 changes: 36 additions & 0 deletions spec/classes/os_patching_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,45 @@
when 'Linux'
let(:cache_dir) { '/var/cache/os_patching' }
let(:fact_cmd) { '/usr/local/bin/os_patching_fact_generation.sh' }

context 'default installation path for Puppet' do
it {
is_expected.to contain_exec('os_patching::exec::fact_upload').with(
'command' => '/opt/puppetlabs/bin/puppet facts upload',
)
}
end

context 'alternate installation path for Puppet' do
let(:params) { {'puppet_binary_dir' => '/usr/local/bin' } }

it {
is_expected.to contain_exec('os_patching::exec::fact_upload').with(
'command' => '/usr/local/bin/puppet facts upload',
)
}
end
when 'windows'
let(:cache_dir) { 'C:/ProgramData/os_patching' }
let(:fact_cmd) { 'C:/ProgramData/os_patching/os_patching_fact_generation.ps1' }

context 'default installation path for Puppet' do
it {
is_expected.to contain_exec('os_patching::exec::fact_upload').with(
'command' => '"C:/Program Files/Puppet Labs/Puppet/bin/puppet.bat" facts upload',
)
}
end

context 'alternate installation path for Puppet' do
let(:params) { {'puppet_binary_dir' => 'D:/Program Files/Puppet Labs/Puppet/bin' } }

it {
is_expected.to contain_exec('os_patching::exec::fact_upload').with(
'command' => '"D:/Program Files/Puppet Labs/Puppet/bin/puppet.bat" facts upload',
)
}
end
end

case os_facts[:osfamily]
Expand Down