semuadmin.octoprint
Ansible role to deploy Octoprint and/or mjpg_streamer as systemd services on Raspberry Pi running stock Raspberry Pi OS 32-bit Lite or Full (Lite is recommended). Should also work on other Debian distributions though webcam support may depend on the specific hardware.
By default:
- Octoprint service will be available on: http://host_ip:5000.
- mjpg_streamer service will be available on: http://host_ip:8080/?action=stream.
(mjpg_streamer can be installed independently of Octoprint if required)
The user will be prompted to go through the Setup Wizard on accessing the service for the first time, but a pre-configured config.yaml template is included with standard configuration items already set up. These can be amended via the Octoprint admin console.
Based on instructions here: https://community.octoprint.org/t/setting-up-octoprint-on-a-raspberry-pi-running-raspbian/2337
Support for Python3 (>= 3.7) has been added since Octoprint 1.4, but note that a few
Octoprint plugins still only work with Python2 (or require additional installation procedures).
The easiest way to install under Python3 is to add a directive in your Ansible inventory
(hosts) file to point to the Python3 executable on your target host(s). For Raspberry Pi
OS this is normally /usr/bin/python3
.
Constructive feedback very welcome.
Raspberry Pi model 3 or 4 with SSH enabled. If installing on a fresh 'headless' Raspberry Pi server (e.g. Raspberry Pi OS Lite), add an empty file named 'ssh' to the boot directory of the SD card to enable remote SSH access. You may also want to set up SSH key-based authentication.
-
install_octoprint
: true -
install_mjpg_streamer
: true -
uninstall_services
: false -
uninstall_dependencies
: false -
octoprint_user
: pi (this is the linux user under which the service runs) -
install_dir
: "/home/{{ octoprint_user }}" -
reset_config
: true (set to false to retain existing config.yaml) -
octoprint_port
: 5000 -
webcam_user
: mjpg_streamer -
webcam_dir
: "{{ install_dir}}/mjpg-streamer/mjpg-streamer-experimental" -
webcam_port
: 8080 -
webcam_type
: "usb" (options are 'usb', 'raspi' or 'custom') -
webcam_width
: 640 -
webcam_height
: 480 -
webcam_fps
: 10 (frames per second) -
custom_input
: "input_uvc.so" (input parameters to be used with 'custom' webcam type)
See https://community.octoprint.org/t/available-mjpg-streamer-configuration-options/1106 for available custom options.
To install under Python2 (strongly deprecated):
- Python >=2.7.9<3
To install under Python3:
- Python >=3.7
At time of writing, Ansible will use the Python2 interpreter on Raspberry Pi OS by default. To install under Python3, add the following entry to the octoprint group in your ansible hosts file, e.g:
[your_octoprint_hostname:vars]
ansible_python_interpreter=/usr/bin/python3
See https://docs.ansible.com/ansible/latest/reference_appendices/python_3_support.html for more details.
To install Octoprint and mjpg_streamer with Raspberry Pi camera:
- name: Provision Octoprint and mjpg_streamer on Raspberry Pi OS
hosts: your_octoprint_hostname
remote_user: pi
become: true
vars:
webcam_type: raspi
roles:
- semuadmin.octoprint
To update Octoprint, keeping existing configuration and access credentials:
- name: Update Octoprint with existing configuration
hosts: your_octoprint_hostname
remote_user: pi
become: true
vars:
install_octoprint: true
install_mjpg_streamer: false
reset_config: false
roles:
- semuadmin.octoprint
To install just mjpg_streamer with a custom uvc camera configuration:
- name: Provision mjpg_streamer on Raspberry Pi OS
hosts: your_octoprint_hostname
remote_user: pi
become: true
vars:
install_octoprint: false
install_mjpg_streamer: true
webcam_type: custom
custom_input: "input_uvc.so -d /dev/video12 -r 1920x1080 -f 15 -q 50"
roles:
- semuadmin.octoprint
To uninstall Octoprint, mjpg_streamer and all package dependencies:
- name: Uninstall Octoprint on Raspberry Pi OS
hosts: your_octoprint_hostname
remote_user: pi
become: true
vars:
uninstall_services: true
uninstall_dependencies: true
roles:
- semuadmin.octoprint
If you get an [SSL: CERTIFICATE_VERIFY_FAILED]
error when attempting to install this
role on MacOS, this is probably due to changes in the way SSL certificates are packaged
with Python version >=3.6. Try the following:
- Ensure that the certifi package is at the latest version:
python3 -m pip install --upgrade certifi
. - Update the installed certificates using the following command
(where * is the minor version of Python installed e.g. 3.9):
/Applications/Python\ 3.*/Install\ Certificates.command
. - (last resort) Use the -c flag to override certificate validation:
ansible-galaxy install semuadmin.octoprint -c
.
See https://www.python.org/downloads/release/python-360/ for further details (particularly bullet point 6 under 'Notes on this release').
BSD