example42 / puppet-tp

Tiny Puppet - The Universal Installer
http://tiny-puppet.com
Apache License 2.0
68 stars 21 forks source link

install_hash should support arrays #44

Closed logicminds closed 6 years ago

logicminds commented 7 years ago

Expected Behavior

Install_hash parameter should accept arrays. I would expect that when I use hieradata to specify multiple apps I want installed that I can easily supply an array.

Example:

tp::install_hash: 
  - redis
  - bash
  - iotop

Actual Behavior

install_hash is limited to just hashes.

tp::install_hash: 
  redis:
    ensure: present
  bash:
    ensure: present
  iotop:
    ensure: present

Possible Fix

If we change the datatype to Variant[Hash,Array[String]] we can at least accept both hashes and arrays.

Furthermore, we would also have to do something like:

if $install_hash =~ Array {
  $installables = $install_hash.map | $name| { tp_install($name, {ensure => present}) }
} else {
  $installables = $install_hash.map | $name, $options| { tp_install($name, $options) }
}
alvagante commented 7 years ago

+1 for me, PR welcomed. I suppose you mean .each instead of .map when the variables is not an Array.

logicminds commented 7 years ago

I did mean map but only for debugging purposes. We probably don't need an array of what was processed.