diff --git a/roles/domain/tasks/audio.yml b/roles/domain/tasks/audio.yml index 824e4dd..e41b008 100644 --- a/roles/domain/tasks/audio.yml +++ b/roles/domain/tasks/audio.yml @@ -1,11 +1,13 @@ --- # Manages reactivation of pulseaudio as system daemon -- name: "Allowing pulseaudio to run at startup" - replace: - regexp: '^#start on runlevel.*$' - replace: 'start on runlevel [2345]' +- name: "Changing pulseaudio upstart script" + template: + src: pulseaudio.conf dest: /etc/init/pulseaudio.conf + owner: root + group: root + mode: 0644 - name: "Checking if pulseaudio is started" shell: /sbin/status pulseaudio @@ -27,9 +29,9 @@ - name: Disabling pulseaudio startup on lightdm shell: chmod -x /usr/bin/start-pulseaudio-x11 -- name: Adding pulseaudio fixing script at reboot. - lineinfile: - line: '@reboot root curl -sSL http://{{ ansible_local.domain.serverfqdn }}/ks/preseed/pulseaudio-perms.sh | bash >/dev/null 2>&1' - dest: /etc/cron.d/pulseaudio-perms - create: yes - state: present +#- name: Adding pulseaudio fixing script at reboot. +# lineinfile: +# line: '@reboot root curl -sSL http://{{ ansible_local.domain.serverfqdn }}/ks/preseed/pulseaudio-perms.sh | bash >/dev/null 2>&1' +# dest: /etc/cron.d/pulseaudio-perms +# create: yes +# state: present diff --git a/roles/domain/templates/pulseaudio.conf b/roles/domain/templates/pulseaudio.conf new file mode 100644 index 0000000..f1b751d --- /dev/null +++ b/roles/domain/templates/pulseaudio.conf @@ -0,0 +1,50 @@ +# System PulseAudio service + +description "System PulseAudio sound server" +author "Pali Rohár " + +# uncomment the 'start on' to start pulseaudio in system mode +# (enables the pulseaudio init script - requires that users be in the +# pulse-access group) +# System mode is not the recommended way to run PulseAudio as it has some +# limitations (such as no shared memory access) and could potentially allow +# users to disconnect or redirect each others' audio streams. The +# recommended way to run PulseAudio is as a per-session daemon. For GNOME/KDE/ +# Xfce sessions in Ubuntu Lucid/10.04, /etc/xdg/autostart/pulseaudio.desktop +# handles this function of automatically starting PulseAudio on login, and for +# it to work correctly your user must *not* have "autospawn = no" set in +# ~/.pulse/client.conf (or in /etc/pulse/client.conf). By default, autospawn +# is enabled. For other sessions, you can simply start PulseAudio with +# "pulseaudio --daemonize". + +start on (started winbind) +stop on runlevel [016] + +expect daemon +respawn + +# Prevent users from dynamically loading modules into the PulseAudio sound +# server. Dynamic module loading enhances the flexibility of the PulseAudio +# system, but may pose a security risk. +# 0 = no, 1 = yes +env DISALLOW_MODULE_LOADING=1 + +# extra arguments to pass to the daemon +env PULSEAUDIO_ARGS= + +pre-start exec install -d -m755 -o pulse -g pulse /run/pulse + +exec /usr/bin/pulseaudio --system --daemonize --high-priority --log-target=syslog --disallow-exit --disallow-module-loading=$DISALLOW_MODULE_LOADING $PULSEAUDIO_ARGS + +post-start script + if [ -e /var/run/pulse/.esd_auth ]; then + chown pulse:pulse-access /var/run/pulse/.esd_auth + chmod 640 /var/run/pulse/.esd_auth + fi + if [ -e /var/run/pulse/.pulse-cookie ]; then + chown pulse:pulse-access /var/run/pulse/.pulse-cookie + chmod 640 /var/run/pulse/.pulse-cookie + fi + # Run script to fix permissions on the pulseaudio stack + /usr/bin/curl -sSL http://{{ ansible_local.domain.serverfqdn }}/ks/preseed/pulseaudio-perms.sh >/dev/null | /bin/bash & +end script