From a94fbc62682af0b6ff6fdf1228f5e1ac39949df4 Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Tue, 10 May 2022 23:49:27 +0200 Subject: [PATCH] Improved bluetooth's ansible play --- ansible/bluetooth.configure.yml | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/ansible/bluetooth.configure.yml b/ansible/bluetooth.configure.yml index ed92ae0..d9861a7 100644 --- a/ansible/bluetooth.configure.yml +++ b/ansible/bluetooth.configure.yml @@ -25,7 +25,22 @@ - when: ansible_system == 'Linux' tags: linux block: + - name: Configure how long to stay in discoverable mode before going back to non-discoverable + tags: discoverable_timeout + when: discoverable_timeout is defined + become: true + notify: Restart Bluez + ansible.builtin.lineinfile: + path: "/etc/bluetooth/main.conf" + line: "DiscoverableTimeout = {{ discoverable_timeout|string|lower }}" + regexp: '^.*DiscoverableTimeout\s*=\s*.*$' + insertafter: '^[General]$' + mode: '0644' + create: true + backup: true - name: Configure faster Bluetooth connection to devices + tags: fast_connectable + when: fast_connectable is defined become: true notify: Restart Bluez ansible.builtin.lineinfile: @@ -36,7 +51,22 @@ mode: '0644' create: true backup: true - - name: Enable all Bluetooth devices as soon as they are found + - name: Configure the default adapter's name + tags: name + when: name is defined + become: true + notify: Restart Bluez + ansible.builtin.lineinfile: + path: "/etc/bluetooth/main.conf" + line: "Name = {{ name|string|lower }}" + regexp: '^.*Name\s*=\s*.*$' + insertafter: '^[General]$' + mode: '0644' + create: true + backup: true + - name: Enable Bluetooth adapters as soon as they are found + tags: auto_enable + when: auto_enable is defined become: true notify: Restart Bluez ansible.builtin.lineinfile: