Created
March 12, 2016 12:26
-
-
Save rdmarsh/41f535f94a89d0842350 to your computer and use it in GitHub Desktop.
Set CHIP up as an airplay server using ansible playbook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# Set CHIP up as an airplay server. | |
# Based on https://www.hackster.io/11798/c-h-i-p-play-speakers-7cebb9 | |
# Note; you will still have to edit shairport-sync.conf to set the name | |
- name: configure chips for iot shairport use | |
hosts: shairport-chips | |
become_user: root | |
become_method: sudo | |
tasks: | |
- name: remove unwanted files | |
file: path={{ ansible_user_dir }}/.bash_logout state=absent | |
- name: run headless | |
become: true | |
command: systemctl set-default multi-user.target | |
- name: run update if the last one is more than 3600 seconds ago | |
become: true | |
apt: update_cache=yes cache_valid_time=3600 | |
- name: update all packages to the latest version | |
become: true | |
apt: upgrade=dist | |
- name: install needed packages | |
become: true | |
apt: name={{ item }} state=latest | |
with_items: | |
- autoconf | |
- git | |
- libasound2-dev | |
- libavahi-client-dev | |
- libconfig-dev | |
- libdaemon-dev | |
- libpopt-dev | |
- libsoxr-dev | |
- libssl-dev | |
- libtool | |
- make | |
- name: clone shairport-sync | |
git: repo=https://github.com/mikebrady/shairport-sync dest={{ ansible_user_dir }}/shairport-sync update=yes | |
ignore_errors: yes | |
- name: autoreconf shairport-sync | |
command: autoreconf -i -f | |
args: | |
chdir: shairport-sync | |
- name: configure shairport-sync | |
command: ./configure --with-alsa --with-avahi --with-ssl=openssl --with-metadata --with-soxr --with-systemd | |
args: | |
chdir: shairport-sync | |
- name: make shairport-sync | |
command: make | |
args: | |
chdir: shairport-sync | |
- name: create shairport-sync system group | |
become: true | |
group: name=shairport-sync state=present system=yes | |
- name: create shairport-sync user | |
become: true | |
user: name={{ ansible_hostname }} state=present system=yes createhome=no group=shairport-sync shell=/usr/bin/nologin | |
- name: make install shairport-sync | |
become: true | |
command: make install | |
args: | |
chdir: shairport-sync | |
- name: configure shairport-sync | |
become: true | |
lineinfile: | |
dest=/etc/shairport-sync.conf | |
regexp='{{ item.regexp }}' | |
line='{{ item.line }}' | |
state=present | |
insertafter='{{ item.after }}' | |
create=yes | |
backup=no | |
owner=root | |
group=root | |
mode=0644 | |
with_items: | |
- { regexp: '^(\s*)interpolation(\s*)=(\s*)', line: '\tinterpolation = "soxr";', after: '//(\s*)interpolation = "basic";' } | |
- { regexp: '^(\s*)output_device(\s*)=(\s*)', line: '\toutput_device = "hw:0";', after: '//(\s*)output_device = "default";' } | |
- name: start shairport-sync on boot | |
become: true | |
lineinfile: | |
dest=/etc/rc.local | |
regexp='^shairport-sync' | |
line='shairport-sync' | |
state=present | |
insertbefore='^exit 0' | |
create=yes | |
backup=no | |
owner=root | |
group=root | |
mode=0755 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment