Hello all, I've got a module that I've been working on in an attempt to make things a little smarter and I figured using a hash would be an elegant solution to my problem. The short story is that I've got various video cards in our production environment and I'd like to have a module that determines what driver will be installed, depending on the make of the card.
I've written some custom facts to help determine the class of the machine, what the video card id is and additionally, if the nvidia driver is currently installed. These facts have been working fine for quite some time and I can check the values by running a facter -p, which results in something like: nvidia_installed => false video_card_id => 17c2 class => workstation With that said, here's the module that I've written: class nvidia::driver_install ( $model_hash = { 009d => "$::nvidia::params::quadro_fx_4500_driver", 06dc => "$::nvidia::params::quadro_6000_driver", 06d9 => "$::nvidia::params::quadro_5000_driver", 11ba => "$::nvidia::params::quadro_K5000_driver", 17c2 => "$::nvidia::params::gtx_titanx_driver", 17f0 => "$::nvidia::params::quadro_M6000_driver", } ) inherits nvidia::params { if ($::is_virtual == true) and ($::class == 'server') { notify { 'This is a virtual machine and the nvidia driver doesn\'t get intalled' : } # only run nvidia installer if the machine is a workstation and the driver is not already installed } elsif ($::class == 'workstation') and ($::nvidia_installed == 'false') { if ($::video_card_id == $model_hash[key]) { notify { "Installing driver for ($model_hash[key])" : } exec { 'kdm-stop' : command => '/usr/bin/service kdm stop' , unless => '/usr/bin/service kdm status | grep -i "stop" ' , before => Exec['nvidia-driver-install'] , } # install nvidia driver exec { 'nvidia-driver-install' : command => "/usr/src/($model_hash[value]).run -s -X -N --force-tls=new --no-x-check --no-cc-version-check" , require => File["/usr/src/($model_hash[value]).run"] , notify => Exec['reboot_after_nvidia'] , } # reboot after nvidia install exec { 'reboot_after_nvidia' : command => "/sbin/reboot" , refreshonly => true , } } } } In addition, I've got most of my parameters saved into the ::nvidia::params.pp file of the module, which then points to hiera for its values: $quadro_fx_4500_driver = hiera('nvidia::quadro_fx_4500_driver') $quadro_6000_driver = hiera('nvidia::quadro_6000_driver') $quadro_5000_driver = hiera('nvidia::quadro_5000_driver') $quadro_K5000_driver = hiera('nvidia::quadro_K5000_driver') $quadro_M6000_driver = hiera('nvidia::quadro_M6000_driver') $gtx_titanx_driver = hiera('nvidia::gtx_titanx_driver') These values all resolve and if I use them by name (without the hash), things seem to work. My first question is, does it appear that my logic is correct? After reading the puppet docs about data types and hashes in particular, it appears to me that I've got the correct syntax. With the above module in place, I can run a puppet job; but nothing ever gets applied to the host (no errors are ever reported and the jobs completes successfully). This leads me to believe that I'm using the hash incorrectly and because of that, values aren't being determined and therefore this particular piece of the module doesn't get applied. Might you have any thoughts on why this doesn't appear to work? Also, as a bonus question, if I wanted to use this code in another module, is it as simple as "include ::nvidia::driver_install"? Thank you in advance to everybody for your help and your assistance. Your help is very much appreciated. Cheers, Mike -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/cfbdb396-0f91-4950-a161-a4e1c52eefe0%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.