-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplaybook.yml
135 lines (118 loc) · 3.68 KB
/
playbook.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
---
- name: Configure raspbian instance as remote speaker
hosts: all
become: true
vars:
hostname: "{{ hostvars[inventory_hostname].hostname }}"
network_interface: "{{ ansible_default_ipv4.alias }}"
network_address: "{{ ansible_default_ipv4.network }}/{{ ansible_default_ipv4.netmask }}"
allowed_networks: "{{ network_address | ansible.utils.ipaddr }}"
tasks:
# the hostname is used by shairport and PulseAudio to advertise
# themselves on your network
- name: Set hostname
ansible.builtin.hostname:
name: "{{ hostname }}"
register: set_hostname
- name: Configure ALSA
ansible.builtin.copy:
src: config/asound.conf
dest: /etc/asound.conf
owner: root
group: root
mode: "0644"
- name: Install Packages
ansible.builtin.apt:
name:
- pulseaudio
- pulseaudio-module-zeroconf
- shairport-sync
- swh-plugins
- name: Give shairport access to PulseAudio
ansible.builtin.user:
name: shairport-sync
groups: pulse-access
append: true
- name: Disable per-user PulseAudio
ansible.builtin.systemd:
name: pulseaudio
enabled: false
scope: global
- name: Configure PulseAudio
ansible.builtin.template:
src: templates/system.pa.j2
dest: /etc/pulse/system.pa
owner: root
group: root
mode: "0644"
register: pulseconf
- name: Configure PulseAudio unit
ansible.builtin.copy:
src: config/pulseaudio-system.service
dest: /etc/systemd/system/pulseaudio-system.service
owner: root
group: root
mode: "0644"
- name: Make sure PulseAudio is running
ansible.builtin.systemd:
state: "{{ set_hostname.changed or pulseconf.changed | ternary('restarted', 'started') }}"
enabled: true
name: pulseaudio-system
daemon_reload: true
- name: Configure shairport-sync
ansible.builtin.copy:
src: config/shairport-sync.conf
dest: /etc/shairport-sync.conf
owner: root
group: root
mode: "0644"
notify: Restart shairport-sync
- name: Shairportsync systemd override for PulseAudio
ansible.builtin.copy:
src: config/shairport-override.conf
dest: /etc/systemd/system/shairport-sync.service.d/override.conf
owner: root
group: root
mode: "0644"
notify: Restart shairport-sync
- name: Make sure shairport-sync is running
ansible.builtin.systemd:
state: started
enabled: true
name: shairport-sync
daemon_reload: true
- name: Disable WiFi Powermanagement
ansible.builtin.template:
src: templates/off-power-manager.j2
dest: /etc/network/if-up.d/off-power-manager
owner: root
group: root
mode: "0755"
register: powerman
notify: Restart networking
- name: Normalize audio at night
ansible.builtin.cron:
name: Normalize audio at night
minute: "0"
hour: 21-23,0-8
job: /usr/bin/pactl set-default-sink 1
user: pi
- name: Use unfiltered ALSA output during the day
ansible.builtin.cron:
name: Use unfiltered ALSA output during the day
minute: "0"
hour: 9-20
job: /usr/bin/pactl set-default-sink 0
user: pi
handlers:
- name: Restart shairport-sync
ansible.builtin.systemd:
state: restarted
enabled: true
daemon_reload: true
name: shairport-sync
- name: Restart networking
ansible.builtin.systemd:
state: restarted
enabled: true
name: networking