0

novice question here. I know it is similar to others here but i am not finding i can apply those answers in my case

i have 2 servers that are blades and 2 that are regular rack mount servers. a puppet script runs on all 4. i want to set a specific value in $sriov_device if the script is running on a blade, but not the other servers.

the blades both have a /usr/local/blade file existing

in a manifest script am trying something like this, but $sriov_device is not being set

file { "/usr/local/blade":
  ensure => present,
  replace => false,
}

whatever {"foo":
  $sriov_device = "eno2"
  require => File["/usr/local/blade"],
}

thanks, sincerely,

-- novice

jodlgc
  • 25
  • 4
  • 1
    Possible duplicate of [How to detect NVIDIA GPU with Puppet](https://serverfault.com/questions/952825/how-to-detect-nvidia-gpu-with-puppet). You need to define a custom fact that will distinguish between the blades and other servers. – bodgit Feb 08 '19 at 11:18
  • Actually, there are likely already existing facts that you can use. See the various DMI facts under `$facts['dmi']`. There are ones for the hardware manufacturer and product name which should be set to something sensible, certainly they work for the major server vendors like Dell and HP, etc. – bodgit Feb 08 '19 at 11:28
  • ah nice thanks you very much. this worked for me `if ($type == 'Blade') { $sriov_device = "eno2" } else { $sriov_device = "None" }` – jodlgc Feb 14 '19 at 22:53

1 Answers1

0

This worked for me:

if ($type == 'Blade') { 
 $sriov_device = "eno2" 
} else {
 $sriov_device = "None" 
}

I was trying to use if ($facts[Type] == "Blade", but I kept getting the error that "Facts was not a hash or array", so then I tried the above which uses the classic facts which just uses the fact name $type.

jodlgc
  • 25
  • 4