I'm using puppet 3.6.2 and trying to use data out of hiera for a windows patching solution. I'm on a disconnect network and cannot use WSUS.
I have a file patches.yml, which looks like this:
windows::patches:
- Firefox-Setup-119.0b9.exe
- KB5007255-x64.msu
- KB5008285-x64.msu
- KB5008897-x64.msu
- KB5009595-x64.msu
- KB5010395-x64.msu
- KB5011560-x64.msu
- KB5012144-x64.msu
I have my windowspatches.pp file that looks like this:
class profile::windowspatches (
$filename = hiera("windows::patches")
)
{
include stdlib
notify{ "$filename":
message => $filename
}
#$downloadUrl = "http://server1/Microsoft/"
#package {$patches:
# ensure => "installed",
# source => "$downloadUrl+$filename"
#
# }
}
I'm working through my idea and have the other actions commented out.
The results currently look like this:
Firefox-Setup-119.0b9.exeKB5007255-x64. msuKB5008285-x64.msuKB5008897-x64.msuKB5009595-x64.msuKB5010395-x64.msuKB5011560 -x64.msuKB5012144-x64.msuKB5012670-x64.msuKB5013616-x64.msuKB5014011-x64.msuKB50 14746-x64.msuKB5015877-x64.msuKB5016683-x64.msuKB5017365-x64.msuKB5018476-x64.ms uKB5020010-x64.msuKB5020608-x64.msuKB5020902-x64.msuKB5021296-x64.msuKB5022346-x 64.msuKB5022508-x64.msuKB5022894-x64.msuKB5023764-x64.msuKB5025288-x64.msuKB5026 409-x64.msuKB5027109-x64.msuKB5027282-x64.msuKB5028223-x64.msuKB5028974-x64.msuK B5029304-x64.msuKB5029942-x64.msuKB5030287-x64.msuKB5031407-x64.msu (noop)
I have tired $filename = hiera("windows::patches"), which gives me the same results.
I'm not sure what I'm missing. I know I have an old version of puppet and I can't upgrade.
You are supplying an array, and you need to iterate trough this array or maybe change the data structure.
Solution for OLD puppet servers
You may try changing your data structure in Hiera as follows:
Please ensure that
%{hiera('download_url')}works with your version of puppet and hiera. If it errors, you shuold change it as follows:and your puppet manifest will look like this (according to the Puppet language style guide, you should not use lookup in the class parameters):
Solution for RECENT puppet servers
If you did not have such an old version of puppet, you could stick with your data structure in hiera, and you could have done as following (with 2 bonus tips):
p.s.: I'd also recommend to not use the double colon separator in the key names in hiera, unless you're using the autolookup feature. It will help distinguishing between auto-lookup and normal lookup.
Let's use
windows_patchesinstead ofwindows::patches