I'm sure I'm doing something silly, but I can't work out the correct syntax for the stdlib keys() function and can't find any examples on the internet.
Here is what I've tried:
file { ["/tmp/file1", "/tmp/file2"]: # <-- this works as expected
ensure => present,
}
$hash = {"/tmp/file1" => 1, "/tmp/file2" => 2}
file { keys($hash): # <-- syntax error occurs here
ensure => present,
}
It results in this error:
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Syntax error at ':'; expected '}' at /etc/puppet/modules/slony/manifests/master.pp:113 on node slonymaster
What am I missing? I'm using Puppet 3.6.2 with stdlib 4.3.2.
You are just overtaxing your expressions. The idea is sound, but you will have to take an intermediate step.
$filenames = keys($hash)
file { $filenames: ensure => present }
Puppet will only accept literal array values or variables as resource titles.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.