Coder Social home page Coder Social logo

smartgic / ansible-playbooks-mycroft Goto Github PK

View Code? Open in Web Editor NEW
11.0 2.0 1.0 158 KB

Ansible playbooks to deploy and configure Mycroft on a Raspberry Pi 4.

Home Page: https://smartgic.io

License: Apache License 2.0

mycroft mycroftai raspberry-pi raspberrypi raspberry-pi-4 voice-assistant overclock raspberrypios

ansible-playbooks-mycroft's Introduction

Ansible Galaxy Discord

Ansible playbooks for Mycroft AI Voice Assistant

Introduction

These Ansible playbooks will help you to install and configure Mycroft AI Voice Assistant on a Raspberry Pi 4B (and later) board with Raspberry Pi OS distribution.

Two types of playbook:

  • Interactive: asking questions to configure the roles used by the playbook
  • Non-interactive: using the default values from the roles or extra variables which override the default values

The playbooks could call different roles such as prepi and mycroft, these roles are available on Ansible Galaxy too.

Before running the playbooks, please have a look to the README of both of roles listed above.

The following image is the result of the install playbook execution:

Installation success

What does Ansible prepi role?

Using the prepi Ansible role will ensure your Raspberry Pi to be properly configured for the best of Mycroft experience.

The role will perform the following tasks (depending your wish):

  • Update Raspberry Pi OS to the latest version
  • Add Debian backports repository (customizable)
  • Update firmware using the next branch which provide kernel 5.10 (customizable)
  • Update EEPROM using the beta version (customizable)
  • Setup initial_turbo to speedup the boot process
  • Overclock the Raspberry Pi to 2Ghz (customizable)
  • Mount /tmp on a RAMDisk for Mycroft TTS cache files
  • Optimize / partition mount options to improve SDcard read/write
  • Enable I2C, SPI & UART interfaces (customizable)
  • Set CPU governor to performance to avoid context switching between the idle* kernel functions (customizable)
  • Install and configure PulseAudio (non-system wide) (customizable)

What does Ansible mycroft role?

The role will perform the following tasks:

  • Install and configure Mycroft AI Voice Assistant
  • Myroft services integrated with systemd
  • Extra skills installation
  • boto3, py_mplayer and pyopenssl Python librairies installation
  • RAMDisk support for IPC
  • Configure Mycroft with custom user profile
  • Optimize PulseAudio for Mycroft
  • Protect Mycroft message bus service port 8181

Requirements

This repository provides a requirements.yml file which allows you to retrieve the roles from Ansible Galaxy Smart'Gic namespace.

$ cd ansible-playbooks-mycroft
$ ansible-galaxy install -r requirements.yml

Example Playbooks

Inventory file with rpi group which has one host named rpi4b01 with the IP address 192.168.1.97.

[rpi]
rpi4b01 ansible_host=192.168.1.97 ansible_user=pi

Basic playbook running on rpi group using the pi user to connect via SSH (based on the inventory) with some custom variables.

Interactive playbook

Using the interactive (asking questions) playbook to install and configure Mycroft.

$ cd ansible-playbook-mycroft
$ ansible-playbook -i inventory install-interactive.yml

Interactive installation

Playbook with default values

Prepare Raspberry Pi, install and configure Mycroft with the default values from the roles.

---
# file: install-default.yml
- hosts: rpi
  gather_facts: yes
  become: yes

  pre_tasks:
    - name: Install Python 3.x Ansible requirement
      raw: apt-get install -y python3
      changed_when: no
      tags:
        - always

  tasks:
    - import_role:
        name: smartgic.prepi

    - import_role:
        name: smartgic.mycroft

Run the playbook

$ cd ansible-playbooks-mycroft
$ ansible-playbook -i inventory install-default.yml

Playbook with custom values

Prepare Raspberry Pi, install and configure Mycroft with some custom values from the roles.

---
# file: install-custom.yml
- hosts: rpi
  gather_facts: yes
  become: yes

  pre_tasks:
    - name: Install Python 3.x Ansible requirement
      raw: apt-get install -y python3
      changed_when: no
      tags:
        - always

  vars:
    # PREPI
    prepi_pi_user: pi
    prepi_hostname: mylovelypi
    prepi_firmware_update: no
    prepi_overclock: yes
    prepi_cpu_freq: 1750

    # MYCROFT
    mycroft_branch: dev
    mycroft_user: "{{ prepi_pi_user }}"
    mycroft_skills_update_interval: 2.0
    mycroft_recording_timeout_with_silence: 3.0
    mycroft_log_level: DEBUG
    mycroft_name: picroft
    mycroft_extra_skills:
      - https://github.com/MycroftAI/skill-homeassistant.git

  tasks:
    - import_role:
        name: smartgic.prepi

    - import_role:
        name: smartgic.mycroft

Run the playbook

$ cd ansible-playbooks-mycroft
$ ansible-playbook -i inventory install-custom.yml

Playbook with prepi role only

Install and configure Mycroft with some custom values from the roles.

---
# file: prepi-only.yml
- hosts: rpi
  gather_facts: yes
  become: yes

  pre_tasks:
    - name: Install Python 3.x Ansible requirement
      raw: apt-get install -y python3
      changed_when: no
      tags:
        - always

  vars:
    # PREPI
    prepi_pi_user: pi
    prepi_hostname: mylovelypi
    prepi_firmware_update: no
    prepi_overclock: yes
    prepi_cpu_freq: 1750

  tasks:
    - import_role:
        name: smartgic.prepi

Run the playbook

$ cd ansible-playbooks-mycroft
$ ansible-playbook -i inventory prepi-only.yml

Playbook with mycroft role only

Install and configure Mycroft with some custom values from the roles.

---
# file: mycroft-only.yml
- hosts: rpi
  gather_facts: no
  become: yes

  pre_tasks:
    - name: Install Python 3.x Ansible requirement
      raw: apt-get install -y python3
      changed_when: no
      tags:
        - always

  vars:
    mycroft_branch: dev
    mycroft_user: pi
    mycroft_skills_update_interval: 2.0
    mycroft_recording_timeout_with_silence: 3.0
    mycroft_log_level: DEBUG
    mycroft_name: picroft
    mycroft_extra_skills:
      - https://github.com/MycroftAI/skill-homeassistant.git

    - import_role:
        name: smartgic.mycroft

Run the playbook

$ cd ansible-playbooks-mycroft
$ ansible-playbook -i inventory mycroft-only.yml

Playbook to uninstall Mycroft

Uninstall Mycroft with extra variable passed on the command line.

---
# file: uninstall.yml
---
- hosts: rpi
  gather_facts: no
  become: yes

  tasks:
    - meta: end_play
      when: mycroft_uninstall is undefined or mycroft_uninstall | bool == false

    - import_role:
        name: smartgic.mycroft
        tasks_from: uninstall
      when: mycroft_uninstall is defined and mycroft_uninstall | bool

Run the playbook

$ cd ansible-playbooks-mycroft
$ ansible-playbook -i inventory uninstall.yml -e mycroft_uninstall=yes

License

MIT

Author Information

I'm Gaëtan Trellu (goldyfruit), let's discuss :) - 2020

ansible-playbooks-mycroft's People

Contributors

goldyfruit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

atpal

ansible-playbooks-mycroft's Issues

Error at TASK [smartgic.mycroft : Install Python packages]

Heyho,

I run into an error when trying to run the playbook:

TASK [smartgic.mycroft : Install Python packages] ******************************************************************************************************************************************************************************************
fatal: [rpi4b01]: FAILED! => {"changed": false, "msg": "'/usr/bin/apt-mark manual python3-pip python3-venv python3-dev python3-wheel' failed: E: Could not create temporary file for /var/lib/apt/extended_states - mkstemp (13: Permission denied)\nE: Failed to write temporary StateFile /var/lib/apt/extended_states\n", "rc": 100, "stderr": "E: Could not create temporary file for /var/lib/apt/extended_states - mkstemp (13: Permission denied)\nE: Failed to write temporary StateFile /var/lib/apt/extended_states\n", "stderr_lines": ["E: Could not create temporary file for /var/lib/apt/extended_states - mkstemp (13: Permission denied)", "E: Failed to write temporary StateFile /var/lib/apt/extended_states"], "stdout": "python3-pip was already set to manually installed.\n", "stdout_lines": ["python3-pip was already set to manually installed."]}
 PLAY RECAP *********************************************************************************************************************************************************************************************************************************
> rpi4b01                    : ok=57   changed=36   unreachable=0    failed=1    skipped=2    rescued=0    ignored=0

I have a freshly installed rpi4 with Raspberry Pi OS 64-Bit and I'm using Ansible 2.10.8
The install-custom.yml is from your guide and I only changed the prepi_hostname. I tried it with the one in the guide as well though.

I'm not sure what the error messsage is trying to tell me and sadly I'm a noob with Ansible, so I don't know where the error is coming from.

Do you have an idea, what the problem could be?

prepi role can't retrieve rootfs?

Hi there.

When I try to run the interactive install playbook with my rpi 4B, I hit the following error:


TASK [smartgic.prepi : Add pi user gpio, video, audio and render groups] *****************************************************************
ok: [rpi4b01]

TASK [smartgic.prepi : Retrieve rootfs partition UUID] ***********************************************************************************
fatal: [rpi4b01]: FAILED! => {"changed": false, "cmd": ["blkid", "-s", "PARTUUID", "-o", "value", "-t", "LABEL=rootfs"], "delta": "0:00:00.058045", "end": "2022-05-20 14:10:24.507218", "msg": "non-zero return code", "rc": 2, "start": "2022-05-20 14:10:24.449173", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}

PLAY RECAP *******************************************************************************************************************************
rpi4b01                    : ok=10   changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   

I am not really sure what causes this, but maybe the issue has to do with the way my pi is partitioned? I am using NOOBS, but I only have rasbian 64bit installed.

Calling blkid straight from the terminal does find my root partition.

I tried figuring out what happens in the call in tasks/common.yml, but I am a complete ansible newb, so I did not get very far..

I will skip the prepi configuration for now.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.