Improved ansible play for bluetooth configuration

This commit is contained in:
Michele Cereda
2022-05-10 22:03:59 +02:00
parent ef8c862436
commit c13e774b9b
2 changed files with 49 additions and 29 deletions

View File

@@ -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

View File

@@ -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