yavdr-ansible/roles/yavdr-xorg/tasks/detect-xorg.yml

182 lines
4.3 KiB
YAML
Raw Normal View History

2017-07-16 11:05:54 +02:00
---
# file: roles/yavdr-xorg/tasks/detect-xorg.yml
- name: "expand template for x-verbose@.service"
template:
src: "templates/systemd/system/x-verbose@.service.j2"
dest: "/etc/systemd/system/x-verbose@.service"
- name: "expand template for xorg-verbose.conf"
template:
src: "templates/xorg-verbose.conf.j2"
dest: "/etc/X11/xorg-verbose.conf"
- name: "remove intel snippet"
file:
path: /etc/X11/xorg.conf.d/20-intel.conf
state: absent
2017-07-30 14:29:38 +02:00
- name: Stop VDR
systemd:
name: vdr.service
state: stopped
enabled: yes
notify: ['Start VDR']
- name: Stop yavdr-xorg
systemd:
name: 'yavdr-xorg'
state: stopped
enabled: yes
notify: ['Start yavdr-xorg']
2017-07-30 14:29:38 +02:00
- name: Stop xlogin
systemd:
name: 'xlogin@{{ vdr.user }}.service'
2017-07-30 14:29:38 +02:00
state: stopped
2018-01-07 17:58:33 +01:00
notify: ['Start xlogin']
2017-07-30 14:29:38 +02:00
- name: Stop x
systemd:
name: x@vt7.service
state: stopped
- name: Workaround for wrong connector names on first run
block:
- name: "wait a little bit before starting x-verbose@vt7.service (needed?)"
wait_for:
timeout: 10
- name: "start x-verbose@.service"
systemd:
name: "x-verbose@vt7.service"
state: started
enabled: false
masked: false
daemon_reload: true
- name: "wait a little bit, so X has some time to start up (needed?)"
wait_for:
timeout: 3
- name: "stop x-verbose@vt7.service"
systemd:
name: "x-verbose@vt7.service"
state: stopped
enabled: false
masked: true
2018-01-07 18:45:01 +01:00
when: first_run
2017-07-16 11:05:54 +02:00
- name: "wait a little bit, so X has some time to shut down (needed?)"
wait_for:
timeout: 3
- name: "trigger udevadm reload"
command: 'udevadm trigger '
- name: "wait a little bit, so udev has some time to reapply rules (needed?)"
2017-07-16 11:05:54 +02:00
wait_for:
timeout: 3
- name: "start x-verbose@.service"
2018-01-07 14:53:19 +01:00
systemd:
name: "x-verbose@vt7.service"
state: started
enabled: false
masked: false
daemon_reload: true
- name: "wait a little bit, so X has some time to start up (needed?)"
2018-01-07 14:53:19 +01:00
wait_for:
timeout: 3
2017-07-16 11:05:54 +02:00
- name: "detect xorg configuration"
xrandr_facts:
preferred_refreshrates: '{{ preferred_refreshrates }}'
preferred_resolutions: '{{ preferred_resolutions }}'
preferred_outputs: '{{ preferred_outputs }}'
2017-07-16 11:05:54 +02:00
- debug:
var: xorg.primary
- debug:
var: xorg.secondary
when: xorg.secondary is defined
- debug:
var: drm
when: drm is defined
2017-07-16 11:05:54 +02:00
- name: "stop x-verbose@vt7.service"
systemd:
name: "x-verbose@vt7.service"
state: stopped
enabled: false
masked: true
2017-07-30 14:29:38 +02:00
- name: "wait a little bit, so X has some time to shut down (needed?)"
wait_for:
timeout: 3
- name: save results
block:
2018-01-16 15:01:27 +01:00
- name: ensure facts.d directory exists
file:
state: directory
path: /etc/ansible/facts.d
- name: write xorg variable as local fact
2018-01-16 15:02:13 +01:00
copy:
content: '{{ {"xorg": xorg} | to_nice_json }}'
2018-01-16 15:02:13 +01:00
dest: /etc/ansible/facts.d/xorg.fact
- name: write xrandr variable as local fact
copy:
content: '{{ {"xrandr": xrandr} | to_nice_json }}'
dest: /etc/ansible/facts.d/xrandr.fact
- name: write drm variable as local fact
copy:
content: '{{ {"drm": drm} | to_nice_json }}'
dest: /etc/ansible/facts.d/drm.fact
when:
- xrandr is defined
- xorg is defined
- drm is defined
- name: update xorg, xrandr and drm variables with values from local facts if needed
set_fact:
xorg: '{{ ansible_local.xorg.xorg }}'
xrandr: '{{ ansible_local.xrandr.xrandr }}'
drm: '{{ ansible_local.drm.drm }}'
when:
- xrandr is undefined
- xorg is undefined
- drm is undefined
2017-07-30 14:29:38 +02:00
# TODO: expand template for xorg.conf (or snippets)
# with respect for the available graphics card driver
# nvidia, noveau, intel, radeon
- 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
- name: intel xorg config snippet
template:
src: templates/20-intel.conf.j2
dest: /etc/X11/xorg.conf.d/20-intel.conf
when:
- intel_detected and not nvidia_detected
- name: server flags config snippet to disable screen blanking
template:
src: templates/10-serverflags.conf.j2
dest: /etc/X11/xorg.conf.d/10-serverflags.conf