diff --git a/deployment/hives/inventory/static.example.yml b/deployment/hives/inventory/static.example.yml index 6f8a2d8..d4f0894 100644 --- a/deployment/hives/inventory/static.example.yml +++ b/deployment/hives/inventory/static.example.yml @@ -18,8 +18,11 @@ hives: hive_name: hivename hive_streaming_enabled: "true" hive_environment_enabled: "true" + # Microphone type: + # - "usb", "i2s", or "none" + hive_mic_type: "i2s" # `hive_alsa_device` is auto-detected if not set - # Must have a USB sound card with capture capability + # Must have a sound card with capture capability # plugged in to the Pi # hive_alsa_device: hw:1,0 hive_audio_channels: "1" diff --git a/deployment/hives/playbooks/hive.yml b/deployment/hives/playbooks/hive.yml index 1baf584..e4e31b0 100644 --- a/deployment/hives/playbooks/hive.yml +++ b/deployment/hives/playbooks/hive.yml @@ -1,6 +1,8 @@ --- - name: Configure Raspberry Pis for hive usage import_playbook: pi_configuration.yml +- name: Set up software for i2s microphones + import_playbook: i2s_mic_setup.yml - name: Set up Docker on Raspberry Pis import_playbook: docker_setup.yml - name: Checkout the latest bee_iot codebase diff --git a/deployment/hives/playbooks/i2s_mic_setup.yml b/deployment/hives/playbooks/i2s_mic_setup.yml new file mode 100644 index 0000000..8d5cb5c --- /dev/null +++ b/deployment/hives/playbooks/i2s_mic_setup.yml @@ -0,0 +1,60 @@ +--- +- name: i2s microphone setup + hosts: hives + remote_user: pi + + tasks: + + - name: Package installs for i2s microphone setup + become: true + ansible.builtin.apt: + name: + - python3 + - python3-pip + state: present + + # Adafruit Python shell + - name: Install Adafruit Python shell + ansible.builtin.pip: + name: + - adafruit-python-shell + executable: pip3 + state: present + + # i2s mic setup scripts + - name: Check if script is installed + ansible.builtin.stat: + path: /home/pi/i2smic.py + register: i2smic_stat + - name: Get i2smic install script + when: not i2smic_stat.stat.exists + ansible.builtin.get_url: + url: https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/i2smic.py + dest: /home/pi/i2smic.py + + - name: Alert to required re-run + ansible.builtin.debug: + verbosity: 0 + msg: + - "" + - "" + - "!!! ATTENTION !!!" + - "" + - "*** i2s microphone install script is about to run! ***" + - "" + - "The script will reboot the Pi: the next task may fail because of this" + - "" + - "Re-run the playbook to continue" + - "" + - "It may take a few minutes for the Pi to come online" + - "" + - "Keep retrying the playbook until the Pi is back" + - "" + - "" + + - name: Run the i2s microphone install script + when: not i2smic_stat.stat.exists + become: true + ansible.builtin.command: + cmd: yes | python3 i2smic.py + chdir: /home/pi diff --git a/deployment/hives/playbooks/pi_configuration.yml b/deployment/hives/playbooks/pi_configuration.yml index ec4b227..dad3bda 100644 --- a/deployment/hives/playbooks/pi_configuration.yml +++ b/deployment/hives/playbooks/pi_configuration.yml @@ -60,13 +60,25 @@ # buster-backports libseccomp2 for Alpine Docker images # https://blog.samcater.com/fix-workaround-rpi4-docker-libseccomp2-docker-20/ + # + # TODO: See if avoidable long term: not ideal + # See: https://www.raspberrypi.org/forums/viewtopic.php?t=310387#p1856516 - name: Add an apt key for buster-backports, needed for libseccomp2 for Alpine Docker images + become: true + ansible.builtin.apt_key: + keyserver: keyserver.ubuntu.com + id: 648ACFD622F3D138 + state: present + + - name: Add an apt key for buster-backports, needed for libseccomp2 for Alpine Docker images + become: true ansible.builtin.apt_key: keyserver: keyserver.ubuntu.com - id: 04EE7237B7D453EC648ACFD622F3D138 + id: 04EE7237B7D453EC state: present - - name: Add specified repository into sources list + - name: Add buster-backports into sources list + become: true ansible.builtin.apt_repository: repo: deb http://httpredir.debian.org/debian buster-backports main contrib non-free state: present