From f3aedfb32592d92cdf9bfc77c0f44f752ff57db3 Mon Sep 17 00:00:00 2001 From: BaReinhard Date: Fri, 29 Jun 2018 23:29:12 -0700 Subject: [PATCH 1/4] Added initial shairport-sync playbook, has yet to be tested --- .../shairport-sync-setup.retry | 2 + .../shairport-sync-setup.yaml | 39 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 playbooks/shairport-sync-setup/shairport-sync-setup.retry create mode 100644 playbooks/shairport-sync-setup/shairport-sync-setup.yaml diff --git a/playbooks/shairport-sync-setup/shairport-sync-setup.retry b/playbooks/shairport-sync-setup/shairport-sync-setup.retry new file mode 100644 index 0000000..e237717 --- /dev/null +++ b/playbooks/shairport-sync-setup/shairport-sync-setup.retry @@ -0,0 +1,2 @@ +192.168.0.10 +192.168.0.12 diff --git a/playbooks/shairport-sync-setup/shairport-sync-setup.yaml b/playbooks/shairport-sync-setup/shairport-sync-setup.yaml new file mode 100644 index 0000000..34e72cb --- /dev/null +++ b/playbooks/shairport-sync-setup/shairport-sync-setup.yaml @@ -0,0 +1,39 @@ +--- +- hosts: rpi + vars: + DEPS: [ build-essential ,git ,autoconf ,automake, libtool, libdaemon-dev, libasound2-dev ,libpopt-dev, libconfig-dev ,avahi-daemon, libavahi-client-dev ,libssl-dev ,libpolarssl-dev, libsoxr-dev] + tasks: + - name: Ensure all needed dependencies are updated + apt: + name: "{{ item }}" + state: latest + with_items: + "{{DEPS}}" + become: yes + - name: Cloning Shairport Sync Repo + git: + repo: https://github.com/mikebrady/shairport-sync.git + dest: /tmp/shairport-sync + version: master + accept_hostkey: yes + become: yes + - name: Run autoreconf on shairport + command: chdir=/tmp/shairport-sync autoreconf -i -f + - name: Configuration Shairport Sync + command: chdir=/tmp/shairport-sync ./configure --sysconfdir=/etc --with-stdout --with-pipe --with-alsa --with-avahi --with-ssl=openssl --with-metadata --with-soxr --with-systemd + - name: Run make + command: chdir=/tmp/shairport-sync make + - name: Create group for Shairport-Sync + shell: getent group shairport-sync &>/dev/null || sudo groupadd -r shairport-sync >/dev/null + become: yes + - name: Add User to Shairport-Sync Group + shell: getent passwd shairport-sync &> /dev/null || sudo useradd -r -M -g shairport-sync -s /usr/bin/nologin -G audio shairport-sync >/dev/null + become: yes + - name: Run make install + command: chdir=/tmp/shairport-sync make install + - name: Enabled Shairport Sync System Daemon + service: + name: shairport-sync + state: started + + From 3468d0369bd12b9ada81cae4dfb6f0561ec16b5d Mon Sep 17 00:00:00 2001 From: BaReinhard Date: Fri, 29 Jun 2018 23:32:54 -0700 Subject: [PATCH 2/4] Added documentation --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 8fdf593..d02216f 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,4 @@ Ansible RPI Playbooks for learning Ansible. These were playbooks I created while - [Adding Multiple Files to Remote Hosts](https://github.com/BaReinhard/ansible_rpi/tree/master/playbooks/multiple-files) - [Check the OS Release Information of each Remote Host](https://github.com/BaReinhard/ansible_rpi/tree/master/playbooks/os-release) - [Configure Multiple Remote Hosts with a WPA Supplicant File with Updating Wifi Information](https://github.com/BaReinhard/ansible_rpi/tree/master/playbooks/wpa-init) +- [Configure Multiple Remote Hosts with Shairport-Sync](https://github.com/BaReinhard/ansible_rpi/tree/master/playbooks/shairport-sync-setup) From d1b781d698301f2f1073136f2ccda01bcc0e74cb Mon Sep 17 00:00:00 2001 From: BaReinhard Date: Sat, 30 Jun 2018 08:36:23 -0700 Subject: [PATCH 3/4] Added template configuration file and step in playbook --- .../shairport-sync-setup.yaml | 8 +- .../templates/shairport-sync.conf | 94 +++++++++++++++++++ 2 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 playbooks/shairport-sync-setup/templates/shairport-sync.conf diff --git a/playbooks/shairport-sync-setup/shairport-sync-setup.yaml b/playbooks/shairport-sync-setup/shairport-sync-setup.yaml index 34e72cb..b74999e 100644 --- a/playbooks/shairport-sync-setup/shairport-sync-setup.yaml +++ b/playbooks/shairport-sync-setup/shairport-sync-setup.yaml @@ -2,6 +2,8 @@ - hosts: rpi vars: DEPS: [ build-essential ,git ,autoconf ,automake, libtool, libdaemon-dev, libasound2-dev ,libpopt-dev, libconfig-dev ,avahi-daemon, libavahi-client-dev ,libssl-dev ,libpolarssl-dev, libsoxr-dev] + OUTPUT_DEVICE: hw:0,0 + SHAIRPORT_NAME: NAME_GOES_HERE tasks: - name: Ensure all needed dependencies are updated apt: @@ -35,5 +37,9 @@ service: name: shairport-sync state: started - + - name : Copy Configuration File + template: + src: templates/shairport-sync.conf + dest: /etc/te.conf + become: yes diff --git a/playbooks/shairport-sync-setup/templates/shairport-sync.conf b/playbooks/shairport-sync-setup/templates/shairport-sync.conf new file mode 100644 index 0000000..b425a8b --- /dev/null +++ b/playbooks/shairport-sync-setup/templates/shairport-sync.conf @@ -0,0 +1,94 @@ +// Sample Configuration File for Shairport Sync +// Commented out settings are generally the defaults, except where noted. + +// General Settings +general = +{ + name = "{{ SHAIRPORT_NAME}}"; // This means "Hostname" -- see below. This is the name the service will advertise to iTunes. + interpolation = "soxr"; +// The default is "Hostname" -- i.e. the machine's hostname with the first letter capitalised (ASCII only.) +// You can use the following substitutions: +// %h for the hostname, +// %H for the Hostname (i.e. with first letter capitalised (ASCII only)), +// %v for the version number, e.g. 2.8.5 and +// %V for the full version string, e.g. 2.8.5-OpenSSL-Avahi-ALSA-soxr-metadata-sysconfdir:/etc +// Overall length can not exceed 50 characters. Example: "Shairport Sync %v on %H". +// password = "secret"; // leave this commented out if you don't want to require a password +// interpolation = "basic"; // aka "stuffing". Default is "basic", alternative is "soxr". Use "soxr" only if you have a reasonably fast processor. +// output_backend = "alsa"; // Run "shairport-sync -h" to get a list of all output_backends, e.g. "alsa", "pipe", "stdout". The default is the first one. +// mdns_backend = "avahi"; // Run "shairport-sync -h" to get a list of all mdns_backends. The default is the first one. +// port = 5000; // Listen for service requests on this port +// udp_port_base = 6001; // start allocating UDP ports from this port number when needed +// udp_port_range = 100; // look for free ports in this number of places, starting at the UDP port base (only three are needed). +// statistics = "no"; // set to "yes" to print statistics in the log +// drift = 88; // allow this number of frames of drift away from exact synchronisation before attempting to correct it +// resync_threshold = 2205; // a synchronisation error greater than this will cause resynchronisation; 0 disables it +// log_verbosity = 0; // "0" means no debug verbosity, "3" is most verbose. +// ignore_volume_control = "no"; // set this to "yes" if you want the volume to be at 100% no matter what the source's volume control is set to. +// volume_range_db = 60 ; // use this to set the range, in dB, you want between the maximum volume and the minimum volume. Range is 30 to 150 dB. Leave it commented out to use mixer's native range. +// regtype = "_raop._tcp"; // Use this advanced setting to set the service type and transport to be advertised by Zeroconf/Bonjour. Default is "_raop._tcp". +// playback_mode = "stereo"; // This can be "stereo" or "mono". Default is "stereo". +}; + +// How to deal with metadata, including artwork +metadata = +{ +// enabled = "no"; // et to yes to get Shairport Sync to solicit metadata from the source and to pass it on via a pipe +// include_cover_art = "no"; // set to "yes" to get Shairport Sync to solicit cover art from the source and pass it via the pipe. You must also set "enabled" to "yes". +// pipe_name = "/tmp/shairport-sync-metadata"; +// pipe_timeout = 5000; // wait for this number of milliseconds for a blocked pipe to unblock before giving up +// socket_address = "226.0.0.1"; // if set to a host name or IP address, UDP packets containing metadata will be sent to this address. May be a multicast address. "socket-port" must be non-zero and "enabled" must be set to yes" +// socket_port = 5555; // if socket_address is set, the port to send UDP packets to +// socket_msglength = 65000; // the maximum packet size for any UDP metadata. This will be clipped to be between 500 or 65000. The default is 500. +}; + +// Advanced parameters for controlling how a Shairport Sync runs +sessioncontrol = +{ +// Uncomment "run_this_before_play_begins" and "run_this_after_play_ends" for Audio Line Input + + run_this_before_play_begins = "/usr/local/bin/shairportstart.sh"; // make sure the application has executable permission. It it's a script, include the #!... stuff on the first line + run_this_after_play_ends = "/usr/local/bin/shairportend.sh"; // make sure the application has executable permission. It it's a script, include the #!... stuff on the first line +// wait_for_completion = "no"; // set to "yes" to get Shairport Sync to wait until the "run_this..." applications have terminated before continuing +// allow_session_interruption = "no"; // set to "yes" to allow another device to interrupt Shairport Sync while it's playing from an existing audio source +// session_timeout = 120; // wait for this number of seconds after a source disappears before terminating the session and becoming available again. +}; + +// Back End Settings + +// These are parameters for the "alsa" audio back end, the only back end that supports synchronised audio. +alsa = +{ + output_device ="{{ OUTPUT_DEVICE }}"; // the name of the alsa output device. Use "alsamixer" or "aplay" to find out the names of devices, mixers, etc. +// mixer_control_name = "PCM"; // the name of the mixer to use to adjust output volume. If not specified, volume in adjusted in software. +// mixer_device = "default"; // the mixer_device default is whatever the output_device is. Normally you wouldn't have to use this. +// audio_backend_latency_offset = 0; // Set this offset to compensate for a fixed delay in the audio back end. E.g. if the output device delays by 100 ms, set this to -4410. +// audio_backend_buffer_desired_length = 6615; // If set too small, buffer underflow occurs on low-powered machines. Too long and the response times with software mixer become annoying. +// disable_synchronization = "no"; // Set to "yes" to disable synchronization. Default is "no". +// period_size = ; // Use this optional advanced setting to set the alsa period size near to this value +// use_mmap_if_available = "yes"; // Use this optional advanced setting to control whether MMAP-based output is used to communicate with the DAC. Default is "yes" +}; + +// These are parameters for the "pipe" audio back end, a back end that directs raw CD-style audio output to a pipe. No interpolation is done. +pipe = +{ +// name = "/path/to/pipe"; // there is no default pipe name for the output +// audio_backend_latency_offset = 0; // Set this offset to compensate for a fixed delay in the audio back end. E.g. if the output device delays by 100 ms, set this to -4410. +// audio_backend_buffer_desired_length = 44100; // Having started to send audio at the right time, send all subsequent audio this many frames ahead of time, creating a buffer this size. +}; + +// These are parameters for the "stdout" audio back end, a back end that directs raw CD-style audio output to stdout. No interpolation is done. +stdout = +{ +// audio_backend_latency_offset = 0; // Set this offset to compensate for a fixed delay in the audio back end. E.g. if the output device delays by 100 ms, set this to -4410. +// audio_backend_buffer_desired_length = 44100; // Having started to send audio at the right time, send all subsequent audio this many frames ahead of time, creating a buffer this size. +}; + +// These are parameters for the "ao" audio back end. No interpolation is done. +ao = +{ +// audio_backend_latency_offset = 0; // Set this offset to compensate for a fixed delay in the audio back end. E.g. if the output device delays by 100 ms, set this to -4410. +// audio_backend_buffer_desired_length = 44100; // Having started to send audio at the right time, send all subsequent audio this many frames ahead of time, creating a buffer this size. +}; + +// Static latency settings are deprecated and the settings have been removed. From a32c478822d70bc4c8f9664f0f4db6ef4bd75786 Mon Sep 17 00:00:00 2001 From: BaReinhard Date: Sat, 30 Jun 2018 10:18:28 -0700 Subject: [PATCH 4/4] Updated a few parameters in shairport-sync and tested on a fresh raspbian install --- .../shairport-sync-setup.retry | 1 - .../shairport-sync-setup/shairport-sync-setup.yaml | 14 +++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/playbooks/shairport-sync-setup/shairport-sync-setup.retry b/playbooks/shairport-sync-setup/shairport-sync-setup.retry index e237717..4bed6d0 100644 --- a/playbooks/shairport-sync-setup/shairport-sync-setup.retry +++ b/playbooks/shairport-sync-setup/shairport-sync-setup.retry @@ -1,2 +1 @@ -192.168.0.10 192.168.0.12 diff --git a/playbooks/shairport-sync-setup/shairport-sync-setup.yaml b/playbooks/shairport-sync-setup/shairport-sync-setup.yaml index b74999e..bb6202d 100644 --- a/playbooks/shairport-sync-setup/shairport-sync-setup.yaml +++ b/playbooks/shairport-sync-setup/shairport-sync-setup.yaml @@ -3,7 +3,7 @@ vars: DEPS: [ build-essential ,git ,autoconf ,automake, libtool, libdaemon-dev, libasound2-dev ,libpopt-dev, libconfig-dev ,avahi-daemon, libavahi-client-dev ,libssl-dev ,libpolarssl-dev, libsoxr-dev] OUTPUT_DEVICE: hw:0,0 - SHAIRPORT_NAME: NAME_GOES_HERE + SHAIRPORT_NAME: Any Name You Desire tasks: - name: Ensure all needed dependencies are updated apt: @@ -21,10 +21,13 @@ become: yes - name: Run autoreconf on shairport command: chdir=/tmp/shairport-sync autoreconf -i -f + become: yes - name: Configuration Shairport Sync command: chdir=/tmp/shairport-sync ./configure --sysconfdir=/etc --with-stdout --with-pipe --with-alsa --with-avahi --with-ssl=openssl --with-metadata --with-soxr --with-systemd + become: yes - name: Run make command: chdir=/tmp/shairport-sync make + become: yes - name: Create group for Shairport-Sync shell: getent group shairport-sync &>/dev/null || sudo groupadd -r shairport-sync >/dev/null become: yes @@ -33,13 +36,18 @@ become: yes - name: Run make install command: chdir=/tmp/shairport-sync make install - - name: Enabled Shairport Sync System Daemon + become: yes + - name: Enable Shairport Sync System Daemon + shell: sudo systemctl enable shairport-sync + become: yes + - name: Ensure Shairport Sync System Daemon service: name: shairport-sync state: started + become: yes - name : Copy Configuration File template: src: templates/shairport-sync.conf - dest: /etc/te.conf + dest: /etc/shairport-sync.conf become: yes