Hi,
I’ve been trying to use the @goldyfruit Ansible playbooks. I went to:
Deploy Mycroft AI voice assistant on Raspberry Pi using Ansible | Opensource.com
And try to follow the instructions. I am able to clone the git repo, but then I try the first command:
pi@ubuntu:~/ansible-playbooks-mycroft$ ansible-galaxy install -r requirements.yml
Command 'ansible-galaxy' not found, but can be installed with:
sudo apt install ansible
pi@ubuntu:~/ansible-playbooks-mycroft$ locate ansible-galaxy
Where should the ansible-galaxy command be found?
Thanks.
-Mike M
Oh, whoops, nevermind, I installed ansible … continuing …
1 Like
I would love some feedback 
The next step could say, instead of “The second step is to edit the Ansible inventory”, Edit the file named inventory.
# vi inventory
...
Then I see: “Now the tricky part: what value do you want for each option? It’s up to you, but here’s my go-to configuration:”
But which file am I to edit? I’m assuming install.yml, but the example shows # file: install-custom.yml
So should I copy install.yml to install-custom.yml?
Thanks.
-Mike M
1 Like
You could name the file as you want, you just need to pass it at the ansible-playbook
command.
@goldyfruit OK, thanks for the quick reply.
Now I edit the install-custom.yml
file, and try to run ansible, but it fails, also when adding the ‘./’ prefix:
pi@ubuntu:~/ansible-playbooks-mycroft$ ansible-playbook -i inventory install-custom.yml -k
ERROR! the playbook: install-custom.yml could not be found
pi@ubuntu:~/ansible-playbooks-mycroft$ ansible-playbook -i inventory ./install-custom.yml -k
ERROR! the playbook: ./install-custom.yml could not be found
Here are the permissions on the file:
pi@ubuntu:~/ansible-playbooks-mycroft$ ls -l install.custom.yml
-rw-rw-r-- 1 pi pi 938 Dec 21 18:51 install.custom.yml
Any ideas?
-Mike M
Whoops again. I had a dash instead of a dot. Now I try again, but it fails a bit further:
pi@ubuntu:~/ansible-playbooks-mycroft$ ansible-playbook -k -i inventory install.custom.yml
SSH password:
PLAY [rpi] *************************************************************************************************************************************
TASK [Gathering Facts] *************************************************************************************************************************
fatal: [rpi4b01]: FAILED! => {"msg": "to use the 'ssh' connection type with passwords, you must install the sshpass program"}
PLAY RECAP *************************************************************************************************************************************
rpi4b01 : ok=0 changed=0 unreachable=0 failed=1 skipped=0
Whoops again, getting dinged by the robot that I’m replying to my own posts. Still I will proceed…
I first ran the command sudo apt install sshpass
then got a bit further. Now I see the error:
ansible-playbook -k -i inventory install.custom.yml
SSH password:
PLAY [rpi] *************************************************************************************************************************************
TASK [Gathering Facts] *************************************************************************************************************************
ok: [rpi4b01]
TASK [Install Python 3.x Ansible requirement] **************************************************************************************************
ok: [rpi4b01]
TASK [smartgic.prepi : Add backports preferences] **********************************************************************************************
changed: [rpi4b01]
TASK [smartgic.prepi : Add backports repository] ***********************************************************************************************
fatal: [rpi4b01]: FAILED! => {"changed": false, "msg": "apt cache update failed"}
PLAY RECAP *************************************************************************************************************************************
rpi4b01 : ok=3 changed=1 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
-Mike M
Which Raspberry Pi OS version are you running?
You can add -vvv
at the end of your command to get verbosity.
I am running Ubuntu server:
$ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.3 LTS (Focal Fossa)"
...
I added -vvv to the call. Here is the output of the section that failed:
TASK [smartgic.prepi : Add backports repository] ***********************************************************************************************
task path: /home/pi/.ansible/roles/smartgic.prepi/tasks/backports.yml:8
Using module file /usr/lib/python3/dist-packages/ansible/modules/packaging/os/apt_repository.py
Pipelining is enabled.
<192.168.1.229> ESTABLISH SSH CONNECTION FOR USER: pi
<192.168.1.229> SSH: EXEC sshpass -d11 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'User="pi"' -o ConnectTimeout=10 -o ControlPath=/home/pi/.ansible/cp/aab97db76e 192.168.1.229 '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-qrwrkhsgplcjhsmlnwdpshxhoogbxysb ; /usr/bin/python3'"'"'"'"'"'"'"'"' && sleep 0'"'"''
Escalation succeeded
<192.168.1.229> (1, b'\n{"msg": "apt cache update failed", "failed": true, "exception": " File \\"/tmp/ansible_apt_repository_payload_y5irtm60/ansible_apt_repository_payload.zip/ansible/modules/packaging/os/apt_repository.py\\", line 548, in main\\n File \\"/usr/lib/python3/dist-packages/apt/cache.py\\", line 591, in update\\n raise FetchFailedException(e)\\n", "invocation": {"module_args": {"repo": "deb http://deb.debian.org/debian focal-backports main non-free contrib", "filename": "backports.list", "mode": 420, "state": "present", "update_cache": true, "install_python_apt": true, "validate_certs": true, "codename": null}}}\n', b'')
<192.168.1.229> Failed to connect to the host via ssh:
The full traceback is:
File "/tmp/ansible_apt_repository_payload_y5irtm60/ansible_apt_repository_payload.zip/ansible/modules/packaging/os/apt_repository.py", line 548, in main
File "/usr/lib/python3/dist-packages/apt/cache.py", line 591, in update
raise FetchFailedException(e)
fatal: [rpi4b01]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"codename": null,
"filename": "backports.list",
"install_python_apt": true,
"mode": 420,
"repo": "deb http://deb.debian.org/debian focal-backports main non-free contrib",
"state": "present",
"update_cache": true,
"validate_certs": true
}
},
"msg": "apt cache update failed"
}
-Mike M
@mike99mac This playbook requires Raspberry Pi OS as mentioned on the post and on the ansible-role-prepi
GitHub page.
The ansible-role-prepi
leverages rpi-eeprom-update
, rpi-update
commands to updates firmware and kernel which are not available on Ubuntu.
The ansible-role-mycroft
should work on Ubuntu without any trouble.
The error is because, the role tries to add a backport that doesn’t exists to Ubuntu.
@goldyfruit Thanks for the reply.
So now I tried this command - note that I had to add the --ask-pass flag:
pi@ubuntu:~/ansible-playbooks-mycroft$ ansible-playbook --ask-pass -i inventory install.yml -t mycroft-config
SSH password:
PLAY [rpi] *************************************************************************************************************************************
TASK [Gathering Facts] *************************************************************************************************************************
ok: [rpi4b01]
TASK [Install Python 3.x Ansible requirement] **************************************************************************************************
ok: [rpi4b01]
TASK [smartgic.mycroft : Raspberry Pi OS detection] ********************************************************************************************
ok: [rpi4b01]
TASK [smartgic.mycroft : Ensure tsched=0 is set for module-udev-detect] ************************************************************************
changed: [rpi4b01]
TASK [smartgic.mycroft : Pulseaudio default configuration] *************************************************************************************
changed: [rpi4b01]
TASK [smartgic.mycroft : Pulseaudio daemon configuration] **************************************************************************************
changed: [rpi4b01]
TASK [smartgic.mycroft : Restart PulseAudio if configuration changed] **************************************************************************
fatal: [rpi4b01]: FAILED! => {"changed": false, "msg": "Unable to restart service pulseaudio: Job for pulseaudio.service failed because the control process exited with error code.\nSee \"systemctl --user status pulseaudio.service\" and \"journalctl --user -xe\" for details.\n"}
Here’s what systemd has to say about pulseaudio:
pi@ubuntu:~/ansible-playbooks-mycroft$ systemctl --user status pulseaudio.service
● pulseaudio.service - Sound Service
Loaded: loaded (/usr/lib/systemd/user/pulseaudio.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2021-12-22 08:25:37 EST; 34s ago
TriggeredBy: ● pulseaudio.socket
Process: 13972 ExecStart=/usr/bin/pulseaudio --daemonize=no --log-target=journal (code=exited, status=1/FAILURE)
Main PID: 13972 (code=exited, status=1/FAILURE)
Dec 22 08:25:37 ubuntu systemd[2240]: pulseaudio.service: Scheduled restart job, restart counter is at 5.
Dec 22 08:25:37 ubuntu systemd[2240]: Stopped Sound Service.
Dec 22 08:25:37 ubuntu systemd[2240]: pulseaudio.service: Start request repeated too quickly.
Dec 22 08:25:37 ubuntu systemd[2240]: pulseaudio.service: Failed with result 'exit-code'.
Dec 22 08:25:37 ubuntu systemd[2240]: Failed to start Sound Service.
-Mike M
Replying to my own post again … I tried a few things to get pulseaudio running, including a reboot, then ran the same ansible command again, and it got past the Pulsaudio task. It failed a couple more times complaining of no ~pi/.mycroft nor ~pi/mycroft-core directories. I created them, then the ansible job ran to completion. However, mycroft is not running. 
If by chance there is an update, would it be possible to install Jellyfin also? It would seem either Jellyfin or Emby are critical components to a music playing stack.
Thanks. Hope this feedback has helped.
-Mike M
The pi
user is related to Raspberry Pi OS which is the reason why you had to create the directory.
Jellyfin and Emby are crucial to some people (I’m not using them for example), I’ll check if a “third” party mycroft
role will be useful.
I guess I could try to make this role compatible with Ubuntu by skipping some parts.
About Mycroft not running, you will have to check the logs.
Thanks for your feedback.
Are you using different media playing software, or are you just not listening to music with your Mycroft device?
-Mike M
I have Sonos speakers, I use different music services through them. I built a skill for this: