---
- name: install Nvidia driver
  yum: 
    name: 
      - kmod-nvidia
      #- nvidia-x11-drv
    state: present
  tags: install

#- name: add Nvidia container runtime support
  #get_url:
    #url: https://nvidia.github.io/nvidia-docker/centos7/nvidia-docker.repo
    #dest: /etc/yum.repos.d/nvidia-docker.repo
  #tags: install

- name: add Nvidia container runtime support
  get_url:
    url: https://nvidia.github.io/nvidia-container-runtime/centos7/nvidia-container-runtime.repo
    dest: /etc/yum.repos.d/nvidia-container-runtime.repo
  tags: install, testing

# disable gpg key (because Nvidia doesn't know how to make that work yet for some reason)
- replace:
    path: /etc/yum.repos.d/nvidia-container-runtime.repo
    regexp: 'repo_gpgcheck=1'
    replace: 'repo_gpgcheck=0'
    backup: yes
  tags: testing

- name: install Nvidia-container-runtime-hook
  yum: 
    name: 
      #- nvidia-detect
      #- kmod-nvidia-410.73-1.el7_5.elrepo
      - nvidia-container-runtime-hook
    state: present
  tags: install


# This needs to be done on GPU nodes 
#- name: Enable DevicePlugins for all GPU nodes (nvidia-container-runtime-hook)
  #copy: src=nvidia dest=/usr/libexec/oci/hooks.d/ owner=root group=root mode=755
  #tags: install

#- name: Add KUBE_EXTRA_ARGS to enable Plugins (GPU support)  --III alreday done in common
  #lineinfile:
    #path: /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
    #line: 'Environment="KUBELET_EXTRA_ARGS=--feature-gates=DevicePlugins=true"'
    #insertbefore: 'KUBELET_KUBECONFIG_ARGS='
  #tags: install

- name: Restart and Enable docker service
  service:
    name: docker
    state: restarted
    enabled: yes
  tags: install

- name: Restart and Enable Kubernetes - kubelet
  service:
    name: kubelet
    state: restarted
    enabled: yes
  tags: install
