improve syntax, add new variables for detected gpus

This commit is contained in:
Alexander Grothe 2017-11-21 11:30:03 +01:00
parent d9eb820ea0
commit 75cd1eb560
6 changed files with 638 additions and 444 deletions

File diff suppressed because it is too large Load Diff

View File

@ -558,6 +558,18 @@ APT::Install-Suggests "0";
gpus: True gpus: True
acpi_power_modes: True acpi_power_modes: True
- name: set variable nvidia_detected
set_fact:
nvidia_detected: 'true if {{ gpus | selectattr("VendorName", "nvidia") | list }}' else false
- name: set variable intel_detected
set_fact:
intel_detected: 'true if {{ gpus | selectattr("VendorName", "intel") | list }}' else false
- name: set variable amd_detected
set_fact:
amd_detected: 'true if {{ gpus | selectattr("VendorName", "amd") | list }}' else false
- debug: - debug:
var: '{{ item }}' var: '{{ item }}'
verbosity: 1 verbosity: 1
@ -567,6 +579,9 @@ APT::Install-Suggests "0";
- gpus - gpus
- modules - modules
- acpi_power_modes - acpi_power_modes
- nvidia_detected
- intel_detected
- amd_detected
#+END_SRC #+END_SRC
** vdr ** vdr
*** tasks *** tasks
@ -1051,7 +1066,10 @@ In order to achive a clean shutdown of the session, ~x@t7.service~ is set as a d
*** TODO automatic X-server configuration :noexport: *** TODO automatic X-server configuration :noexport:
- [X] detect connected display - [X] detect connected display
- [X] read EDID from displays - [X] read EDID from displays
- [ ] create a xorg.conf for nvidia/intel/amd gpus create a xorg.conf for
- [X] nvidia
- [ ] intel
- [ ] amd gpus
**** HOLD Nvidia-GPUs:read EDID: **** HOLD Nvidia-GPUs:read EDID:
@ -1448,31 +1466,31 @@ b'\xde\xad\xbe\xef'
dest: '{{ item }}' dest: '{{ item }}'
state: directory state: directory
with_items: with_items:
- /etc/systemd/system/x@.service.d/ - "/etc/systemd/system/x@.service.d/"
- /etc/systemd/system/vdr.service.d/ - "/etc/systemd/system/vdr.service.d/"
- '/etc/systemd/system/user@{{ vdr.uid }}.service.d/' - "/etc/systemd/system/user@{{ vdr.uid }}.service.d/"
- name: add dependency to X-server for vdr.service using a drop-in - name: systemd-drop-in: add dependency to X-server for vdr.service
template: template:
src: templates/vdr-xorg.conf src: templates/vdr-xorg.conf
dest: /etc/systemd/system/vdr.service.d/vdr-xorg.conf dest: /etc/systemd/system/vdr.service.d/vdr-xorg.conf
- name: start x@.service before xlogin@.service - name: systemd-drop-in: start x@.service before xlogin@.service
template: template:
src: templates/x@service.d/xlogin.conf.j2 src: templates/x@service.d/xlogin.conf.j2
dest: /etc/systemd/system/x@.service.d/xlogin.conf dest: /etc/systemd/system/x@.service.d/xlogin.conf
- name: load environment file for vdr.service - name: systemd-drop-in: load environment file for vdr.service
template: template:
src: templates/systemd/vdr-environ.j2 src: templates/systemd/vdr-environ.j2
dest: /etc/systemd/system/vdr.service.d/load-environ.conf dest: /etc/systemd/system/vdr.service.d/load-environ.conf
- name: user@{{ vdr.uid }}.service depends on x@vt7.service - name: systemd-drop-in: user@{{ vdr.uid }}.service depends on x@vt7.service
template: template:
src: templates/user@666.service.d/x-dependency.conf.j2 src: templates/user@666.service.d/x-dependency.conf.j2
dest: '/etc/systemd/system/user@{{ vdr.uid }}.service.d/x-dependency.conf' dest: '/etc/systemd/system/user@{{ vdr.uid }}.service.d/x-dependency.conf'
- name: start softhddevice detached and set audio to pulseaudio - name: vdr-config: start softhddevice detached and set audio to pulseaudio
lineinfile: lineinfile:
path: /etc/vdr/conf.avail/softhddevice.conf path: /etc/vdr/conf.avail/softhddevice.conf
line: '{{ item }}' line: '{{ item }}'
@ -1480,7 +1498,7 @@ b'\xde\xad\xbe\xef'
- '-D' - '-D'
# - '-a pulse' # do we need this with our existing asound.conf? # - '-a pulse' # do we need this with our existing asound.conf?
- name: set a login shell for the user vdr - name: add a login shell for the user vdr
user: user:
name: '{{ vdr.user }}' name: '{{ vdr.user }}'
shell: '/bin/bash' shell: '/bin/bash'
@ -1547,6 +1565,10 @@ b'\xde\xad\xbe\xef'
name: x@vt7.service name: x@vt7.service
state: stopped state: stopped
- name: "wait a little bit before starting x-verbose@vt7.service (needed?)"
wait_for:
timeout: 3
- name: "start x-verbose@.service" - name: "start x-verbose@.service"
systemd: systemd:
name: "x-verbose@vt7.service" name: "x-verbose@vt7.service"
@ -1576,17 +1598,26 @@ b'\xde\xad\xbe\xef'
enabled: false enabled: false
masked: true masked: true
- name: "wait a little bit, so X has some time to shut down (needed?)"
wait_for:
timeout: 3
# TODO: expand template for xorg.conf (or snippets) # TODO: expand template for xorg.conf (or snippets)
# with respect for the available graphics card driver # with respect for the available graphics card driver
# nvidia, noveau, intel, radeon # nvidia, noveau, intel, radeon
- name: create xorg.conf (for nvidia driver)
template:
src: templates/xorg.conf.j2
dest: /etc/X11/xorg.conf
backup: yes
#+END_SRC
#+BEGIN_SRC yaml :tangle roles/yavdr-xorg/tasks/desktop-session.yml :mkdirp yes :padline no - name: nvidia related config
block:
- name: create xorg.conf (for nvidia driver)
template:
src: templates/xorg.conf.j2
dest: /etc/X11/xorg.conf
backup: yes
when:
- nvidia_detected
- #+END_SRC
,#+BEGIN_SRC yaml :tangle roles/yavdr-xorg/tasks/desktop-session.yml :mkdirp yes :padline no
--- ---
# file: roles/yavdr-xorg/tasks/desktop-session.yml # file: roles/yavdr-xorg/tasks/desktop-session.yml
@ -3726,11 +3757,11 @@ EXAMPLES = '''
acpi_power_modes: True acpi_power_modes: True
- debug: - debug:
var: usb var: usb
- debug - debug:
var: pci var: pci
- debug - debug:
var: modules var: modules
- debug - debug:
var: gpus var: gpus
''' '''

View File

@ -52,11 +52,11 @@ EXAMPLES = '''
acpi_power_modes: True acpi_power_modes: True
- debug: - debug:
var: usb var: usb
- debug - debug:
var: pci var: pci
- debug - debug:
var: modules var: modules
- debug - debug:
var: gpus var: gpus
''' '''

View File

@ -6,6 +6,18 @@
gpus: True gpus: True
acpi_power_modes: True acpi_power_modes: True
- name: set variable nvidia_detected
set_fact:
nvidia_detected: 'true if {{ gpus | selectattr("VendorName", "nvidia") | list }}' else false
- name: set variable intel_detected
set_fact:
intel_detected: 'true if {{ gpus | selectattr("VendorName", "intel") | list }}' else false
- name: set variable amd_detected
set_fact:
amd_detected: 'true if {{ gpus | selectattr("VendorName", "amd") | list }}' else false
- debug: - debug:
var: '{{ item }}' var: '{{ item }}'
verbosity: 1 verbosity: 1
@ -15,3 +27,6 @@
- gpus - gpus
- modules - modules
- acpi_power_modes - acpi_power_modes
- nvidia_detected
- intel_detected
- amd_detected

View File

@ -28,6 +28,10 @@
name: x@vt7.service name: x@vt7.service
state: stopped state: stopped
- name: "wait a little bit before starting x-verbose@vt7.service (needed?)"
wait_for:
timeout: 3
- name: "start x-verbose@.service" - name: "start x-verbose@.service"
systemd: systemd:
name: "x-verbose@vt7.service" name: "x-verbose@vt7.service"
@ -57,11 +61,116 @@
enabled: false enabled: false
masked: true masked: true
- name: "wait a little bit, so X has some time to shut down (needed?)"
wait_for:
timeout: 3
# TODO: expand template for xorg.conf (or snippets) # TODO: expand template for xorg.conf (or snippets)
# with respect for the available graphics card driver # with respect for the available graphics card driver
# nvidia, noveau, intel, radeon # nvidia, noveau, intel, radeon
- name: create xorg.conf (for nvidia driver)
- name: nvidia related config
block:
- name: create xorg.conf (for nvidia driver)
template:
src: templates/xorg.conf.j2
dest: /etc/X11/xorg.conf
backup: yes
when:
- nvidia_detected
- #+END_SRC
#+BEGIN_SRC yaml :tangle roles/yavdr-xorg/tasks/desktop-session.yml :mkdirp yes :padline no
---
# file: roles/yavdr-xorg/tasks/desktop-session.yml
- name: create folders for user configuration files
file:
state: directory
dest: '{{ item }}'
mode: '0775'
owner: '{{ vdr.user }}'
group: '{{ vdr.group }}'
with_items:
- '{{ vdr.home }}/.config/systemd/user'
- '{{ vdr.home }}/.config/openbox'
- '{{ vdr.home }}/.config/pulse'
- name: expand template for .xinitrc for vdr user
template: template:
src: templates/xorg.conf.j2 src: 'templates/.xinitrc.j2'
dest: /etc/X11/xorg.conf dest: '{{ vdr.home }}/.xinitrc'
backup: yes mode: 0755
owner: '{{ vdr.user }}'
group: '{{ vdr.group }}'
- name: expand template for openbox autostart
template:
src: 'templates/openbox/autostart.j2'
dest: '{{ vdr.home }}/.config/openbox/autostart'
mode: 0755
owner: '{{ vdr.user }}'
group: '{{ vdr.group }}'
- name: expand rc.xml for openbox
template:
src: 'templates/openbox/rc.xml.j2'
dest: '{{ vdr.home }}/.config/openbox/rc.xml'
mode: 0644
owner: '{{ vdr.user }}'
group: '{{ vdr.group }}'
- name: create yavdr-desktop.target for the user session
template:
src: 'templates/systemd/user/yavdr-desktop.target.j2'
dest: '{{ vdr.home }}/.config/systemd/user/yavdr-desktop.target'
mode: 0644
owner: '{{ vdr.user }}'
group: '{{ vdr.group }}'
- name: disable pulseaudio autospawning
lineinfile:
path: '{{ vdr.home }}/.config/pulse/client.conf'
line: 'autospawn = no'
create: yes
state: present
owner: '{{ vdr.user }}'
group: '{{ vdr.group }}'
- name: create tmux.service for the session
template:
src: roles/yavdr-xorg/templates/systemd/user/tmux.service.j2
dest: '{{ vdr.home }}/.config/systemd/user/tmux.service'
- name: create wm-exit.service for the session
template:
src: roles/yavdr-xorg/templates/systemd/user/wm-exit.service.j2
dest: '{{ vdr.home }}/.config/systemd/user/wm-exit.service'
- name: create detect-second-display.service for the session
template:
src: templates/systemd/user/detect-second-display.service.j2
dest: '{{ vdr.home }}/.config/systemd/user/detect-second-display.service'
- name: create openbox-second.service for the session
template:
src: templates/systemd/user/openbox-second.service.j2
dest: '{{ vdr.home }}/.config/systemd/user/openbox-second.service'
- name: create osd2web.service for the session
template:
src: templates/systemd/user/osd2web.service.j2
dest: '{{ vdr.home }}/.config/systemd/user/osd2web.service'
- name: link /usr/bin/start-desktop to /var/lib/vdr/plugins/desktop/starter
file:
src: /usr/bin/start-desktop
dest: /var/lib/vdr/plugins/desktop/starter
state: link
- name: enable and start xlogin for the vdr user
systemd:
daemon_reload: yes
name: 'xlogin@{{ vdr.user }}'
enabled: yes
state: started

View File

@ -5,31 +5,31 @@
dest: '{{ item }}' dest: '{{ item }}'
state: directory state: directory
with_items: with_items:
- /etc/systemd/system/x@.service.d/ - "/etc/systemd/system/x@.service.d/"
- /etc/systemd/system/vdr.service.d/ - "/etc/systemd/system/vdr.service.d/"
- '/etc/systemd/system/user@{{ vdr.uid }}.service.d/' - "/etc/systemd/system/user@{{ vdr.uid }}.service.d/"
- name: add dependency to X-server for vdr.service using a drop-in - name: systemd-drop-in: add dependency to X-server for vdr.service
template: template:
src: templates/vdr-xorg.conf src: templates/vdr-xorg.conf
dest: /etc/systemd/system/vdr.service.d/vdr-xorg.conf dest: /etc/systemd/system/vdr.service.d/vdr-xorg.conf
- name: start x@.service before xlogin@.service - name: systemd-drop-in: start x@.service before xlogin@.service
template: template:
src: templates/x@service.d/xlogin.conf.j2 src: templates/x@service.d/xlogin.conf.j2
dest: /etc/systemd/system/x@.service.d/xlogin.conf dest: /etc/systemd/system/x@.service.d/xlogin.conf
- name: load environment file for vdr.service - name: systemd-drop-in: load environment file for vdr.service
template: template:
src: templates/systemd/vdr-environ.j2 src: templates/systemd/vdr-environ.j2
dest: /etc/systemd/system/vdr.service.d/load-environ.conf dest: /etc/systemd/system/vdr.service.d/load-environ.conf
- name: user@{{ vdr.uid }}.service depends on x@vt7.service - name: systemd-drop-in: user@{{ vdr.uid }}.service depends on x@vt7.service
template: template:
src: templates/user@666.service.d/x-dependency.conf.j2 src: templates/user@666.service.d/x-dependency.conf.j2
dest: '/etc/systemd/system/user@{{ vdr.uid }}.service.d/x-dependency.conf' dest: '/etc/systemd/system/user@{{ vdr.uid }}.service.d/x-dependency.conf'
- name: start softhddevice detached and set audio to pulseaudio - name: vdr-config: start softhddevice detached and set audio to pulseaudio
lineinfile: lineinfile:
path: /etc/vdr/conf.avail/softhddevice.conf path: /etc/vdr/conf.avail/softhddevice.conf
line: '{{ item }}' line: '{{ item }}'
@ -37,7 +37,7 @@
- '-D' - '-D'
# - '-a pulse' # do we need this with our existing asound.conf? # - '-a pulse' # do we need this with our existing asound.conf?
- name: set a login shell for the user vdr - name: add a login shell for the user vdr
user: user:
name: '{{ vdr.user }}' name: '{{ vdr.user }}'
shell: '/bin/bash' shell: '/bin/bash'