i got the task to implement hiera puppet script to manage sites_enabled for nginx.
Here is my puppet script:
common.yaml
---
classes:
- nginx
nginx:
enabled:
abc.com
xyz.com
disabled:
test.com
test2.com
init.pp
class nginx{
create_resources("site_enabled", hiera("nginx"), {})
}
define site_enabled($name){
file { '/etc/nginx/sites_enabled/${name}':
ensure => 'link',
target => '/etc/nginx/site_available/${name}',
}
}
But i got the error when puppet executed:
err: Could not retrieve catalog from remote server: Error 400 on SERVER: can't convert String into Integer at /etc/puppet/modules/nginx/manifests/init.pp:7 on node XX
When i tried to query hiera via commandline:
$ hiera nginx
{"enabled"=>["abc.com", "xyz.com"]}
I know i have wrong some where. Please kindly correct me. i don't understand much, how hiera query and process with array data. please point me some useful document if it is possible.
Thanks so much.