From 6c3cc84c601af3a01984d974d9eea30fbecada6f Mon Sep 17 00:00:00 2001 From: Alexander Grothe Date: Sun, 16 Jul 2017 11:05:54 +0200 Subject: [PATCH] Rearrange tasks in yavdr-xorg --- Manual.org | 83 ++++++------ roles/yavdr-xorg/tasks/desktop-session.yml | 72 ++++++++++ roles/yavdr-xorg/tasks/detect-xorg.yml | 41 ++++++ roles/yavdr-xorg/tasks/main.yml | 145 +++------------------ 4 files changed, 177 insertions(+), 164 deletions(-) create mode 100644 roles/yavdr-xorg/tasks/desktop-session.yml create mode 100644 roles/yavdr-xorg/tasks/detect-xorg.yml diff --git a/Manual.org b/Manual.org index ef7b1c9..f03cbdb 100644 --- a/Manual.org +++ b/Manual.org @@ -1392,7 +1392,7 @@ b'\xde\xad\xbe\xef' --- # file: roles/yavdr-xorg/tasks/main.yml -# TODO: use hooks or requirements instead +# IDEA: use hooks or requirements instead - name: Stop VDR systemd: name: vdr.service @@ -1405,11 +1405,25 @@ b'\xde\xad\xbe\xef' dest: /etc/systemd/system/vdr.service.d/ state: directory -- name: add environment file for vdr.service +- name: add dependency to X-server for vdr.service using a drop-in + template: + src: templates/vdr-xorg.conf + dest: /etc/systemd/system/vdr.service.d/vdr-xorg.conf + +- name: load environment file for vdr.service template: src: templates/systemd/vdr-environ.j2 dest: /etc/systemd/system/vdr.service.d/load-environ.conf +- name: set a login shell for the user vdr + user: + name: '{{ vdr.user }}' + shell: '/bin/bash' + state: present + uid: '{{ vdr.uid }}' + groups: '{{ vdr.group }}' + append: yes + - name: install packages for xorg apt: name: '{{ item }}' @@ -1437,6 +1451,32 @@ b'\xde\xad\xbe\xef' name: x@vt7.service state: stopped +- include: detect-xorg.yml + +# TODO: expand template for xorg.conf (or snippets) +# with respect for the available graphics card driver +# nvidia, noveau, intel, radeon + +- name: create xorg.conf (for nvidia driver) + template: + src: templates/xorg.conf.j2 + dest: /etc/X11/xorg.conf + backup: yes + +- include: desktop-session.yml + +- name: enable and start xlogin for the user vdr + systemd: + daemon_reload: yes + name: 'xlogin@{{ vdr.user }}' + enabled: yes + state: started +#+END_SRC + +#+BEGIN_SRC yaml :tangle roles/yavdr-xorg/tasks/detect-xorg.yml :mkdirp yes :padline no +--- +# file: roles/yavdr-xorg/tasks/detect-xorg.yml + - name: "expand template for x-verbose@.service" template: src: "templates/systemd/system/x-verbose@.service.j2" @@ -1475,16 +1515,11 @@ b'\xde\xad\xbe\xef' state: stopped enabled: false masked: true +#+END_SRC -# TODO: expand template for xorg.conf (or snippets) -# with respect for the available graphics card driver -# nvidia, noveau, intel, radeon - -- name: create xorg.conf (for nvidia driver) - template: - src: templates/xorg.conf.j2 - dest: /etc/X11/xorg.conf - backup: yes +#+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 session file: @@ -1497,17 +1532,6 @@ b'\xde\xad\xbe\xef' - '{{ vdr.home }}/.config/systemd/user' - '{{ vdr.home }}/.config/openbox/' -- name: create folder for customizations of vdr.service - file: - state: directory - dest: /etc/systemd/system/vdr.service.d - mode: '0775' - -- name: add dependency to X-server for vdr.service using a drop-in - template: - src: templates/vdr-xorg.conf - dest: /etc/systemd/system/vdr.service.d/ - - name: create folders for user configuration files file: state: directory @@ -1561,26 +1585,11 @@ b'\xde\xad\xbe\xef' owner: '{{ vdr.user }}' group: '{{ vdr.group }}' -- name: set a login shell for the user vdr - user: - name: '{{ vdr.user }}' - shell: '/bin/bash' - state: present - uid: '{{ vdr.uid }}' - groups: '{{ vdr.group }}' - append: yes - 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: enable and start xlogin for the user vdr - systemd: - daemon_reload: yes - name: 'xlogin@{{ vdr.user }}' - enabled: yes - state: started #+END_SRC *** templates **** xorg diff --git a/roles/yavdr-xorg/tasks/desktop-session.yml b/roles/yavdr-xorg/tasks/desktop-session.yml new file mode 100644 index 0000000..ad272eb --- /dev/null +++ b/roles/yavdr-xorg/tasks/desktop-session.yml @@ -0,0 +1,72 @@ +--- +# file: roles/yavdr-xorg/tasks/desktop-session.yml + +- name: create folders for user session + file: + state: directory + dest: '{{ item }}' + mode: '0775' + owner: '{{ vdr.user }}' + group: '{{ vdr.group }}' + with_items: + - '{{ vdr.home }}/.config/systemd/user' + - '{{ vdr.home }}/.config/openbox/' + +- 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: + src: 'templates/.xinitrc.j2' + dest: '{{ vdr.home }}/.xinitrc' + 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: 0755 + 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: 0755 + 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' diff --git a/roles/yavdr-xorg/tasks/detect-xorg.yml b/roles/yavdr-xorg/tasks/detect-xorg.yml new file mode 100644 index 0000000..5aa6661 --- /dev/null +++ b/roles/yavdr-xorg/tasks/detect-xorg.yml @@ -0,0 +1,41 @@ +--- +# 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: "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" + action: xrandr_facts + +- 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 diff --git a/roles/yavdr-xorg/tasks/main.yml b/roles/yavdr-xorg/tasks/main.yml index 166421a..3efa34f 100644 --- a/roles/yavdr-xorg/tasks/main.yml +++ b/roles/yavdr-xorg/tasks/main.yml @@ -1,7 +1,7 @@ --- # file: roles/yavdr-xorg/tasks/main.yml -# TODO: use hooks or requirements instead +# IDEA: use hooks or requirements instead - name: Stop VDR systemd: name: vdr.service @@ -14,6 +14,21 @@ dest: /etc/systemd/system/vdr.service.d/ state: directory +- name: add dependency to X-server for vdr.service using a drop-in + template: + src: templates/vdr-xorg.conf + dest: /etc/systemd/system/vdr.service.d/vdr-xorg.conf + +- name: set a login shell for the user vdr + user: + name: '{{ vdr.user }}' + shell: '/bin/bash' + state: present + uid: '{{ vdr.uid }}' + groups: '{{ vdr.group }}' + append: yes + + - name: add environment file for vdr.service template: src: templates/systemd/vdr-environ.j2 @@ -46,44 +61,7 @@ name: x@vt7.service state: stopped -- 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: "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" - action: xrandr_facts - -- 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 +- include: detect-xorg.yml # TODO: expand template for xorg.conf (or snippets) # with respect for the available graphics card driver @@ -95,94 +73,7 @@ dest: /etc/X11/xorg.conf backup: yes -- name: create folders for user session - file: - state: directory - dest: '{{ item }}' - mode: '0775' - owner: '{{ vdr.user }}' - group: '{{ vdr.group }}' - with_items: - - '{{ vdr.home }}/.config/systemd/user' - - '{{ vdr.home }}/.config/openbox/' - -- name: create folder for customizations of vdr.service - file: - state: directory - dest: /etc/systemd/system/vdr.service.d - mode: '0775' - -- name: add dependency to X-server for vdr.service using a drop-in - template: - src: templates/vdr-xorg.conf - dest: /etc/systemd/system/vdr.service.d/ - -- 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: - src: 'templates/.xinitrc.j2' - dest: '{{ vdr.home }}/.xinitrc' - 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: 0755 - 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: 0755 - 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: set a login shell for the user vdr - user: - name: '{{ vdr.user }}' - shell: '/bin/bash' - state: present - uid: '{{ vdr.uid }}' - groups: '{{ vdr.group }}' - append: yes - -- 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' +- include: desktop-session.yml - name: enable and start xlogin for the user vdr systemd: