I have it working with:
{% if grains['num_gpus'] > 1 %}
{%- do salt.log.error('This server has an Nvidia GPU') -%}
{% else %}
{%- do salt.log.error('No GPU on this server') -%}
{% endif %}
Now, the reason I'm trying to determine this is for servers with the Nvidia GPUs, I want to make sure the kernel-devel versions of the installed kernel packages are also installed. On those without an Nvidia GPU, I want to remove the kernel-devel rpms. First, we have the number of kernels installed limited to two. I know from a command line I can run:
# This will install the devel kernel of the running kernel:
yum install "kernel-devel-uname-r == $(uname -r)"
#
# This will install the devel kernel of the non-running kernel:
yum
install "kernel-devel-uname-r == $(salt-call kernelpkg.list_installed | grep -v 'local:' | head -1 | awk '{ print $2 }').x86_64"
I just need to figure out how to translate that into salt state files. I guess my first step is get a list of installed kernels and see if there is a corresponding installed kernel-devel rpm.