From c13e774b9b9a74f290b62e3e741d0cb3eac25ce1 Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Tue, 10 May 2022 22:03:59 +0200 Subject: [PATCH] Improved ansible play for bluetooth configuration --- ansible/bluetooth.configure.yml | 49 +++++++++++++++++++++++++++++++++ ansible/bluetooth.tune.yml | 29 ------------------- 2 files changed, 49 insertions(+), 29 deletions(-) create mode 100644 ansible/bluetooth.configure.yml delete mode 100644 ansible/bluetooth.tune.yml diff --git a/ansible/bluetooth.configure.yml b/ansible/bluetooth.configure.yml new file mode 100644 index 0000000..ed92ae0 --- /dev/null +++ b/ansible/bluetooth.configure.yml @@ -0,0 +1,49 @@ +--- + +- name: Configure the Bluetooth service + tags: + - bluetooth + - config + - configuration + - configure + - daemon + - daemons + - service + - services + - tune + - tuning + hosts: all + vars: + auto_enable: true + fast_connectable: true + handlers: + - name: Restart Bluez + ansible.builtin.service: + name: bluetooth.service + state: restarted + tasks: + - when: ansible_system == 'Linux' + tags: linux + block: + - name: Configure faster Bluetooth connection to devices + become: true + notify: Restart Bluez + ansible.builtin.lineinfile: + path: "/etc/bluetooth/main.conf" + line: "FastConnectable = {{ fast_connectable|string|lower }}" + regexp: '^.*FastConnectable\s*=\s*.*$' + insertafter: '^[General]$' + mode: '0644' + create: true + backup: true + - name: Enable all Bluetooth devices as soon as they are found + become: true + notify: Restart Bluez + ansible.builtin.lineinfile: + path: "/etc/bluetooth/main.conf" + line: "AutoEnable = {{ auto_enable|string|lower }}" + regexp: '^.*AutoEnable\s*=\s*.*$' + insertafter: '^[Policy]$' + mode: '0644' + create: true + backup: true diff --git a/ansible/bluetooth.tune.yml b/ansible/bluetooth.tune.yml deleted file mode 100644 index a1d82c5..0000000 --- a/ansible/bluetooth.tune.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- -- name: Tune the Bluetooth daemon - tags: - - bluetooth - - configure - hosts: all - tasks: - - name: Enable faster Bluetooth connection to devices - when: ansible_system == 'Linux' - become: true - ansible.builtin.lineinfile: - path: "/etc/bluetooth/main.conf" - line: "FastConnectable = true" - regexp: '^.*FastConnectable\s*=\s*.*$' - insertafter: '^[General]$' - mode: '0644' - create: true - backup: true - - name: Enable all Bluetooth devices as soon as they are found - when: ansible_system == 'Linux' - become: true - ansible.builtin.lineinfile: - path: "/etc/bluetooth/main.conf" - line: "AutoEnable = true" - regexp: '^.*AutoEnable\s*=\s*.*$' - insertafter: '^[Policy]$' - mode: '0644' - create: true - backup: true