Last active
January 22, 2016 09:12
-
-
Save vinzent/5e5f187a8d1dcb000f8a to your computer and use it in GitHub Desktop.
Referencing hash values within module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://groups.google.com/forum/#!topic/puppet-users/1ol4b1euTiE | |
class nvidia::driver_install ( | |
include stdlib | |
$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 (!empty($model_hash[$::video_card_id])) { | |
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 , | |
} | |
} else { | |
warning("Could not lookup video_card_id (${::video_card_id}) to driver name") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment