Search code examples
nvidiasalt-project

How can I install NVIDIA in non-interactive by SaltStack


I'm new with SaltStack.

I need to install NVIDIA on minion server running CentOS 7 with SaltStack only.

In the gpu/init.sls file:

install_nvidia:
  cmd.script:
    - source: salt://gpu/files/NVIDIA-Linux-x86_64-375.20.run
    - user: root
    - group: root
    - shell: /bin/bash
    - args: -a

I run:

sudo salt minion_name state.apply gpu

I get the error:

...
 stderr:
                  Error opening terminal: unknown.
...
...
Summary for minion_name
------------
Succeeded: 0 (changed=1)
Failed:    1

How can I get more verbose information about the reason it failed? I believe it wait to user input but I don't know what

Also how can I install NVIDIA on CentOS 7 with non interactive way?

Thanks.


Solution

  • You can get more verbose information about why a Salt state has failed by running it locally using salt-call -l debug.

    salt-call -l debug state.apply gpu
    

    In your case, you have to be aware that installing the NVIDIA driver on Linux will require you to run the installer without a graphical session present. The simplest way to do this will be to check if you're currently in a graphical session (with systemd) and then drop do multi-user.target if so:

    enter-multiuser:
      cmd.run:
        - name: systemctl isolate multi-user.target
        - onlyif: systemctl status graphical.target
    

    Then, you can install the NVIDIA driver silently using something like

    gpu-prerequisites:
      pkg.installed:
        - pkgs:
          - kernel-devel
    
    download-installer:
      file.managed:
        - name: /tmp/NVIDIA-Linux-x86_64-375.20.run
        - source: salt://gpu/files/NVIDIA-Linux-x86_64-375.20.run
    
    
    install-driver:
      cmd.run:
        - name: /tmp/NVIDIA-Linux-x86_64-375.20.run -a -s -Z -X
        - require:
          - file: download-installer
          - pkg: gpu-prequisites
    
    start-graphical:
      cmd.run: 
        - name: systemctl start graphical.target
        - unless:  systemctl status graphical.target
        - watch:
          - cmd: install-driver