playbook: Fix sensor installation for Debian 11
Previously it only worked with Debian 10. This commit reflects the removal of the apt package 'python-pip' in Debian 11 and the change of the i2c bus number.
- name: Install apt package dependencies | - name: Install apt package dependencies | ||
apt: | apt: | ||
pkg: | pkg: | ||
- python | - python3 | ||
- python-pip | - python3-pip | ||
- i2c-tools | - i2c-tools | ||
- python-smbus | - python3-smbus | ||
state: present | state: present | ||
- name: Install setuptools | - name: Install setuptools | ||
pip: | pip: | ||
name: setuptools | name: setuptools | ||
executable: pip2 | executable: pip3 | ||
- name: Install bme280 | - name: Install bme280 | ||
pip: | pip: | ||
name: bme280 | name: bme280 | ||
executable: pip2 | executable: pip3 | ||
# We need to set a different bus number depending | |||
# on the debian version. For Debian 12 we may | |||
# need another number again. | |||
- name: Set bus number for debian bullseye | |||
set_fact: | |||
i2c_bus_number: 3 | |||
when: ansible_distribution == 'Debian' and ansible_distribution_release == 'Buster' | |||
|
|||
- name: Set bus number for debian bullseye | |||
set_fact: | |||
i2c_bus_number: 2 | |||
when: ansible_distribution == 'Debian' and ansible_distribution_release == 'bullseye' | |||
- name: Solve python template to read sensor | - name: Solve python template to read sensor | ||
template: | template: | ||
... | @@ -27,8 +41,8 @@ | ... | @@ -27,8 +41,8 @@ |
set_olimex_sensor_permission_path: /usr/bin/olimex-sensor-set-sensor-permission | set_olimex_sensor_permission_path: /usr/bin/olimex-sensor-set-sensor-permission | ||
- name: Move script to grant access to sensor to file path | - name: Move script to grant access to sensor to file path | ||
copy: | template: | ||
src: olimex-sensor-set-sensor-permission.sh | src: olimex-sensor-set-sensor-permission.j2 | ||
dest: "{{ set_olimex_sensor_permission_path }}" | dest: "{{ set_olimex_sensor_permission_path }}" | ||
mode: 755 | mode: 755 | ||
... | ... |