2020-03-15 11:24:02 +00:00
|
|
|
- name: "Install pi-bluetooth package on Ubuntu"
|
|
|
|
package:
|
|
|
|
name:
|
|
|
|
- pi-bluetooth
|
|
|
|
state: present
|
|
|
|
when: is_ubuntu and not (rpi_model == "none")
|
|
|
|
|
2019-09-14 22:00:27 +00:00
|
|
|
- name: "Install bluetooth packages"
|
|
|
|
package:
|
|
|
|
name:
|
|
|
|
- bluetooth
|
|
|
|
- bluez
|
|
|
|
- bluez-tools
|
|
|
|
state: present
|
|
|
|
|
|
|
|
- name: Create bluetooth services
|
|
|
|
template:
|
|
|
|
backup: no
|
|
|
|
src: "{{ item.src }}"
|
|
|
|
dest: "{{ item.dest }}"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
|
|
|
with_items:
|
|
|
|
- { src: 'bt-agent.service.j2', dest: '/etc/systemd/system/bt-agent.service' }
|
|
|
|
- { src: 'bt-pan.service.j2', dest: '/etc/systemd/system/bt-pan.service' }
|
|
|
|
- { src: 'bt-term.service.j2', dest: '/etc/systemd/system/bt-term.service' }
|
|
|
|
- { src: 'network.conf.j2', dest: '/etc/bluetooth/network.conf' }
|
|
|
|
|
|
|
|
- name: Create bluetooth utility scripts
|
|
|
|
template:
|
|
|
|
backup: no
|
|
|
|
src: "{{ item.src }}"
|
|
|
|
dest: "{{ item.dest }}"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0755
|
|
|
|
with_items:
|
|
|
|
- { src: 'iiab-bt-pan-on.j2', dest: '/usr/bin/iiab-bt-pan-on' }
|
|
|
|
- { src: 'iiab-bt-pan-off.j2', dest: '/usr/bin/iiab-bt-pan-off' }
|
|
|
|
- { src: 'iiab-bt-pan-discoverable-on.j2', dest: '/usr/bin/iiab-bt-pan-discoverable-on' }
|
|
|
|
- { src: 'iiab-bt-term-on.j2', dest: '/usr/bin/iiab-bt-term-on' }
|
|
|
|
- { src: 'iiab-bt-term-off.j2', dest: '/usr/bin/iiab-bt-term-off' }
|
|
|
|
|
|
|
|
# Bluetooth service needs /usr/lib/bluetooth/bluetoothd -C --noplugin=sap
|
|
|
|
# Copy and patch it
|
|
|
|
|
|
|
|
- name: Copy the bluetooth service
|
|
|
|
template:
|
|
|
|
dest: /etc/systemd/system/bluetooth.service
|
|
|
|
src: /lib/systemd/system/bluetooth.service
|
|
|
|
|
|
|
|
- name: Add -C --noplugin=sap to execStart of bluetooth service
|
|
|
|
lineinfile:
|
|
|
|
path: /etc/systemd/system/bluetooth.service
|
|
|
|
regexp: '^ExecStart=/usr/lib/bluetooth/bluetoothd'
|
|
|
|
line: 'ExecStart=/usr/lib/bluetooth/bluetoothd -C --noplugin=sap'
|
|
|
|
|
|
|
|
- name: Set discoverable not to timeout
|
|
|
|
lineinfile:
|
|
|
|
path: /etc/bluetooth/main.conf
|
|
|
|
regexp: '^#DiscoverableTimeout'
|
|
|
|
line: 'DiscoverableTimeout = 0'
|
|
|
|
|
2020-01-30 09:00:00 +00:00
|
|
|
|
|
|
|
# RECORD Bluetooth AS INSTALLED
|
|
|
|
|
|
|
|
- name: "Set 'bluetooth_installed: True'"
|
|
|
|
set_fact:
|
|
|
|
bluetooth_installed: True
|
|
|
|
|
2020-01-12 23:15:33 +00:00
|
|
|
- name: "Add 'bluetooth_installed: True' to {{ iiab_state_file }}"
|
2019-09-14 22:00:27 +00:00
|
|
|
lineinfile:
|
2020-02-04 00:54:04 +00:00
|
|
|
path: "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
|
2019-10-25 01:05:47 +00:00
|
|
|
regexp: '^bluetooth_installed'
|
|
|
|
line: 'bluetooth_installed: True'
|