yavdr-ansible/roles/yavdr-xorg/tasks/detect-xorg.yml
Alexander Grothe 65dc2b4fd7 Allow overriding preferred refresh rate, resolution and connection
for xrandr_facts module. You can set own preferences e.g. in a
host_vars/localhost.yml using the variables preferred_refreshrates,
preferred_resolutions and preferred_outputs (see
roles/yavdr-xorg/default/main.yml for default values).
2018-05-10 22:04:45 +02:00

153 lines
3.6 KiB
YAML

---
# 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: 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']
- name: Stop xlogin
systemd:
name: 'xlogin@{{ vdr.user }}.service'
state: stopped
notify: ['Start xlogin']
- 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
when: first_run
- 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?)"
wait_for:
timeout: 3
- 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: "detect xorg configuration"
xrandr_facts:
preferred_refreshrates: '{{ preferred_refreshrates }}'
preferred_resolutions: '{{ preferred_resolutions }}'
preferred_outputs: '{{ preferred_outputs }}'
- debug:
var: xorg.primary
- debug:
var: xorg.secondary
when: xorg.secondary is defined
- name: "stop x-verbose@vt7.service"
systemd:
name: "x-verbose@vt7.service"
state: stopped
enabled: false
masked: true
- name: "wait a little bit, so X has some time to shut down (needed?)"
wait_for:
timeout: 3
- name: save results
block:
- name: ensure facts.d directory exists
file:
state: directory
path: /etc/ansible/facts.d
- name: write xorg variable as local fact
copy:
content: '{{ {"xorg": xorg} | to_nice_json }}'
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
when:
- xrandr is defined
- xorg is defined
- name: update xorg and xrandr variable with values from local facts if needed
set_fact:
xorg: '{{ ansible_local.xorg }}'
xrandr: '{{ ansible_local.xrandr }}'
when:
- xrandr is undefined
- xorg is undefined
# 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