From 0bf158ef1f37693e7eb5df8ee1f77b6bc360c177 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Sat, 4 May 2019 17:47:38 +0200 Subject: [PATCH] add task to exclude serial devices from ModemManager --- defaults/main.yml | 7 +++++++ tasks/install.yml | 6 ++++++ templates/etc/udev/rules.d/99-mm-disable.rules.j2 | 5 +++++ 3 files changed, 18 insertions(+) create mode 100644 templates/etc/udev/rules.d/99-mm-disable.rules.j2 diff --git a/defaults/main.yml b/defaults/main.yml index 07f9e10..d6c91c0 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -38,6 +38,13 @@ homeassistant_open_ports: # be careful! wrong config can make your system unusable! # homeassistant_cmdline_content: "console=tty1 root=/dev/mmcblk0p3 rootfstype=ext4 elevator=deadline rootwait" +# to prevent ModemManger from binding serial devices like CC2531 +# devices can be skipped by an udev rule +homeassistant_exclude_modemmanager: False +homeassistant_serial_device: + - vendor_id: "0000" + product_id: "xxxx" + homeassistant_nginx_vhost_enabled: False homeassistant_nginx_server: localhost homeassistant_nginx_vhost_dir: /etc/nginx/sites-available diff --git a/tasks/install.yml b/tasks/install.yml index 77af2f1..ebbc3c4 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -41,6 +41,12 @@ dest: /boot/cmdline.txt when: homeassistant_cmdline_content is defined + - name: Exclude serial devices from ModemManager + template: + src: "etc/udev/rules.d/99-mm-disable.rules.j2" + dest: "/etc/udev/rules.d/99-mm-disable.rules" + when: homeassistant_exclude_modemmanager + - name: Copy systemd unit file template: src: "etc/systemd/system/homeassistant.service.j2" diff --git a/templates/etc/udev/rules.d/99-mm-disable.rules.j2 b/templates/etc/udev/rules.d/99-mm-disable.rules.j2 new file mode 100644 index 0000000..785ac5e --- /dev/null +++ b/templates/etc/udev/rules.d/99-mm-disable.rules.j2 @@ -0,0 +1,5 @@ +#jinja2: lstrip_blocks: True +# {{ ansible_managed }} +{% for item in homeassistant_serial_device %} +ATTRS{idVendor}=="{{ item.vendor_id }}" ATTRS{idProduct}=="{{ item.product_id }}", ENV{ID_MM_DEVICE_IGNORE}="1" +{% endfor %}