ansible-infra/playbooks/roles/bluetooth_audio_sink/tasks/main.yaml

183 lines
4.7 KiB
YAML
Raw Normal View History

2022-12-18 04:36:53 +01:00
---
- name: Ensure acl is installed
become: true
2022-12-18 04:36:53 +01:00
ansible.builtin.apt:
name: acl
2022-12-18 04:36:53 +01:00
- name: Ensure machine-info file is deployed
become: true
2022-12-18 04:36:53 +01:00
ansible.builtin.template:
src: machine-info.j2
dest: /etc/machine-info
mode: "644"
2022-12-18 04:36:53 +01:00
owner: root
group: root
notify: Restart bluetooth service
2022-12-18 04:36:53 +01:00
- name: Ensure bluetooth config is deployed
become: true
2022-12-18 04:36:53 +01:00
ansible.builtin.template:
src: main.conf.j2
dest: /etc/bluetooth/main.conf
mode: "644"
2022-12-18 04:36:53 +01:00
owner: root
group: root
notify: Restart bluetooth service
2022-12-18 04:36:53 +01:00
- name: Ensure bluetooth service is enabled and started
become: true
2022-12-18 04:36:53 +01:00
ansible.builtin.systemd:
service: bluetooth.service
state: started
enabled: true
2022-12-18 04:36:53 +01:00
- name: Ensure audiosink user exists
become: true
2022-12-18 04:36:53 +01:00
ansible.builtin.user:
name: audiosink
groups:
- audio
2022-12-18 04:36:53 +01:00
- name: Ensure user services are started without needing to login
become: true
2022-12-18 04:36:53 +01:00
ansible.builtin.command:
cmd: loginctl enable-linger audiosink
changed_when: false
2022-12-18 04:36:53 +01:00
- name: Detect if on Raspberry Pi # noqa ignore-errors
ansible.builtin.include_role:
name: raspberry_pi_check
ignore_errors: true
2022-12-18 04:36:53 +01:00
- name: Ensure debian archive keyring is installed # noqa no-handler
become: true
2022-12-18 04:36:53 +01:00
when: raspberry_pi_check__cpuinfo.found
ansible.builtin.apt:
2023-07-30 01:04:25 +02:00
deb: https://ftp.debian.org/debian/pool/main/d/debian-archive-keyring/debian-archive-keyring_2021.1.1+deb11u1_all.deb
2022-12-18 04:36:53 +01:00
- name: Ensure debian backports repository is enabled
ansible.builtin.include_role:
name: add_apt_repository
vars:
add_apt_repository__https_repo: false
add_apt_repository__repo: "deb http://deb.debian.org/debian {{ ansible_facts.lsb.codename }}-backports main contrib non-free"
add_apt_repository__filename: "{{ ansible_facts.lsb.codename }}-backports.list"
2022-12-18 04:36:53 +01:00
- name: Ensure pipewire, wireplumber and libspa-0.2-bluetooth are installed
become: true
2022-12-18 04:36:53 +01:00
ansible.builtin.apt:
name:
- pipewire
- wireplumber
- libspa-0.2-bluetooth
default_release: "{{ ansible_facts.lsb.codename }}-backports"
2022-12-18 04:36:53 +01:00
- name: Ensure pipewire user service is enabled and started
become: true
2022-12-18 04:36:53 +01:00
become_user: audiosink
ansible.builtin.systemd:
name: pipewire.service
state: started
enabled: true
scope: user
2022-12-18 04:36:53 +01:00
- name: Ensure pipewire-pulse user service is enabled and started
become: true
2022-12-18 04:36:53 +01:00
become_user: audiosink
ansible.builtin.systemd:
name: pipewire-pulse.service
state: started
enabled: true
scope: user
2022-12-18 20:17:53 +01:00
- name: Ensure wireplumber user service is enabled
become: true
2022-12-18 04:36:53 +01:00
become_user: audiosink
ansible.builtin.systemd:
name: wireplumber.service
enabled: true
scope: user
2022-12-18 04:36:53 +01:00
- name: Ensure speaker-agent dependencies are installed
become: true
2022-12-18 04:36:53 +01:00
ansible.builtin.apt:
name:
- git
- python3-dbus
2022-12-18 04:36:53 +01:00
- name: Ensure speaker-agent repository is cloned
become: true
2022-12-18 04:36:53 +01:00
ansible.builtin.git:
repo: https://github.com/fdanis-oss/pw_wp_bluetooth_rpi_speaker.git
dest: /opt/speaker-agent
version: 9a939a23865ea020816017e06fd2290f301c35f9
2022-12-18 04:36:53 +01:00
- name: Ensure .config directory exists
become: true
2022-12-18 04:36:53 +01:00
become_user: audiosink
ansible.builtin.file:
path: /home/audiosink/.config
state: directory
mode: "700"
2022-12-18 04:36:53 +01:00
owner: audiosink
group: audiosink
2022-12-18 04:36:53 +01:00
- name: Ensure .config/systemd directory exists
become: true
2022-12-18 04:36:53 +01:00
become_user: audiosink
ansible.builtin.file:
path: /home/audiosink/.config/systemd
state: directory
mode: "755"
2022-12-18 04:36:53 +01:00
owner: audiosink
group: audiosink
2022-12-18 04:36:53 +01:00
- name: Ensure .config/systemd/user directory exists
become: true
2022-12-18 04:36:53 +01:00
become_user: audiosink
ansible.builtin.file:
path: /home/audiosink/.config/systemd/user
state: directory
mode: "755"
2022-12-18 04:36:53 +01:00
owner: audiosink
group: audiosink
2022-12-18 04:36:53 +01:00
- name: Ensure speaker-agent service file is deployed
become: true
2022-12-18 04:36:53 +01:00
become_user: audiosink
ansible.builtin.copy:
src: speaker-agent.service
dest: /home/audiosink/.config/systemd/user/speaker-agent.service
mode: "644"
2022-12-18 04:36:53 +01:00
owner: audiosink
group: audiosink
notify: Restart speaker-agent service
2022-12-18 04:36:53 +01:00
- name: Ensure speaker-agent service is enabled and started
become: true
2022-12-18 04:36:53 +01:00
become_user: audiosink
ansible.builtin.systemd:
name: speaker-agent.service
state: started
enabled: true
scope: user
2022-12-18 04:36:53 +01:00
# This part is janky, but I don't know how to make the bluetooth service, wireplumber and pipewire
# work with each other without being logged in.
- name: Ensure getty@tty1 override file is deployed
become: true
2022-12-18 04:36:53 +01:00
ansible.builtin.copy:
src: override.conf
dest: /etc/systemd/system/getty@tty1.service.d/override.conf
mode: "644"
2022-12-18 04:36:53 +01:00
owner: root
group: root
notify: Reboot host
2022-12-18 04:36:53 +01:00
- name: Ensure autologin for audiosink user is enabled
become: true
2022-12-18 04:36:53 +01:00
ansible.builtin.systemd:
service: getty@tty1.service
enabled: true
notify: Reboot host