I would like to create install_package module which can be called multi times, where packages are defined in hiera. I know class is skelton (can be called one time), and define type is designed for my purpose.
I have developped the following : hiera.yaml
--- version: 5 hierarchy: - name: "Common hierarchy level" path: "common.yaml" ./data/common.yaml
--- install_package::packages: - vim - logrotate classes: - install_package ./module/install_package/manifest/init.pp
class install_package( packages=[], ) { define def_package() notify{"package to install is $name":} } def_package{ [$packages]: } } Puppet returns "Error while evaluating a Resource Statement, Unknown resource type: 'def_package'".
My question is how can I define packages to install in variable (array) in /data/common.yaml for instance, and then call install_package module multiple times, with define type ?
install_packagegoing to do above just instantiating apackageresource?