smartgic / ansible-playbooks-mycroft

Ansible playbooks to deploy and configure Mycroft on a Raspberry Pi 4.
https://smartgic.io
Apache License 2.0
11 stars 1 forks source link
mycroft mycroftai overclock raspberry-pi raspberry-pi-4 raspberrypi raspberrypios voice-assistant

Ansible Galaxy Discord

Ansible playbooks for Mycroft AI Voice Assistant

Two types of playbook:

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):

What does Ansible mycroft role?

The role will perform the following tasks:

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