configure-host.yml 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. - name: Discover NVIDIA renderD devices (vendor 0x10de)
  2. shell: |
  3. for d in /sys/class/drm/renderD*; do
  4. [ -e "$d/device/vendor" ] && grep -qi "10de" "$d/device/vendor" 2>/dev/null && basename "$d"
  5. done | sort -V
  6. register: nvidia_render_discovery
  7. changed_when: false
  8. become: true
  9. - name: Set NVIDIA render device paths for template
  10. set_fact:
  11. nvidia_render_devices: "{{ nvidia_render_discovery.stdout_lines | default([]) | map('regex_replace', '^', '/dev/dri/') | list }}"
  12. become: true
  13. - name: Create container device configuration file
  14. template:
  15. src: host_container_device.yml.j2
  16. dest: /etc/yunion/host_container_device.yml
  17. mode: '0644'
  18. become: true
  19. - name: Ensure hwdata directory exists
  20. file:
  21. path: /usr/share/hwdata
  22. state: directory
  23. become: true
  24. - name: Update PCI IDs
  25. copy:
  26. src: "{{ role_path }}/../gpu-init/files/pci.ids"
  27. dest: /usr/share/hwdata/pci.ids
  28. owner: root
  29. group: root
  30. mode: '0644'
  31. become: true
  32. - name: Update host configuration
  33. lineinfile:
  34. path: /etc/yunion/host.conf
  35. line: "{{ item }}"
  36. state: present
  37. become: true
  38. loop:
  39. - "container_device_config_file: /etc/yunion/host_container_device.yml"