GithubHelp home page GithubHelp logo

kenael / ansible_octoprint Goto Github PK

View Code? Open in Web Editor NEW

This project forked from it-praktyk/ansible_octoprint

0.0 1.0 0.0 38 KB

Ansible role for Octoprint and Mjpg_Streamer on Raspbian

License: BSD 2-Clause "Simplified" License

Shell 63.32% Jinja 36.68%

ansible_octoprint's Introduction

Role Name

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.

Current Status

Release Release Date Last Commit Contributors Open Issues

Requirements

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.

Role Variables

  • 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.

Dependencies

To install under Python2 (strongly deprecated):

  • Python >=2.7.9<3

To install under Python3:

  • Python >=3.7

Example Playbook

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

Troubleshooting

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:

  1. Ensure that the certifi package is at the latest version: python3 -m pip install --upgrade certifi.
  2. 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.
  3. (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').

License

BSD

Author Information

[email protected]

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.