update octoprint role

Signed-off-by: Thomas Schmid <tom@lfence.de>
This commit is contained in:
Thomas 2022-01-20 20:39:36 +01:00
parent dc55147030
commit 2adfd65c79
18 changed files with 313 additions and 234 deletions

View File

@ -0,0 +1,61 @@
mainsail_domain: cannelloni.binary.kitchen
octoprint_groups:
- klipper
- tty
octoprint_config_display_name: Voron 2.4
octoprint_domain: cannelloni.binary.kitchen
octoprint_config_default_profile: _voron_2_4
octoprint_has_webcam: false
octoprint_additional_plugins:
- "https://github.com/thelastWallE/OctoprintKlipperPlugin/archive/master.zip"
octoprint_config:
plugins:
klipper:
configuration:
config_path: /etc/klipper/
confirm_reload: false
serial:
disconnectOnErrors: false
port: /home/klipper/printer
additionalPorts:
- /home/klipper/printer
octoprint_printer_profiles:
- axes:
e:
inverted: false
speed: 300
x:
inverted: false
speed: 6000
y:
inverted: false
speed: 6000
z:
inverted: false
speed: 200
color: default
extruder:
count: 1
nozzleDiameter: 0.4
offsets:
- - 0.0
- 0.0
sharedNozzle: false
heatedBed: true
heatedChamber: false
id: _voron_2_4
model: Voron 2.4
name: Voron 2.4
volume:
custom_box: false
depth: 350.0
formFactor: rectangular
height: 320.0
origin: lowerleft
width: 350.0

View File

@ -1,45 +0,0 @@
octoprint_display_name: Prusa Mini
octoprint_domain: canneloni.binary.kitchen
octoprint_config_default_profile: _mini
octoprint_printer_profiles:
- axes:
e:
inverted: false
speed: 300
x:
inverted: false
speed: 6000
y:
inverted: false
speed: 6000
z:
inverted: false
speed: 200
color: default
extruder:
count: 1
nozzleDiameter: 0.4
offsets:
- - 0.0
- 0.0
sharedNozzle: false
heatedBed: true
heatedChamber: false
id: _mini
model: Prusa Mini
name: Pursa Mini
volume:
custom_box:
x_min: 0
x_max: 180
y_min: -3
y_max: 180
z_min: 0
z_max: 180
depth: 180.0
formFactor: rectangular
height: 180.0
origin: lowerleft
width: 180

View File

@ -1,7 +1,16 @@
octoprint_display_name: Voron 2.4
octoprint_config_display_name: Prusa Mini
octoprint_domain: maccaroni.binary.kitchen
octoprint_config_default_profile: _mini
octoprint_config_default_profile: _voron_2_4
octoprint_has_webcam: true
octoprint_ustreamer_args: "-r 1280x720"
octoprint_config:
webcam:
ffmpeg: "/usr/bin/ffmpeg"
snapshot: "http://{{ octoprint_domain }}/webcam/snapshot"
stream: "http://{{ octoprint_domain }}/webcam/stream"
watermark: false
octoprint_printer_profiles:
- axes:
@ -27,13 +36,19 @@ octoprint_printer_profiles:
sharedNozzle: false
heatedBed: true
heatedChamber: false
id: _voron_2_4
model: Voron 2.4
name: Voron 2.4
id: _mini
model: Prusa Mini
name: Pursa Mini
volume:
custom_box: false
depth: 350.0
custom_box:
x_min: 0
x_max: 180
y_min: -3
y_max: 180
z_min: 0
z_max: 180
depth: 180.0
formFactor: rectangular
height: 320.0
height: 180.0
origin: lowerleft
width: 350.0
width: 180

View File

@ -0,0 +1 @@
noodlehub_domain: noodlehub.binary.kitchen

View File

@ -1,70 +0,0 @@
octoprint_domain: raspberrypi.fritz.box
octoprint_config_default_profile: _mk3_single
octoprint_printer_profiles:
- axes:
e:
inverted: false
speed: 300
x:
inverted: false
speed: 6000
y:
inverted: false
speed: 6000
z:
inverted: false
speed: 200
color: default
extruder:
count: 1
nozzleDiameter: 0.4
offsets:
- - 0.0
- 0.0
sharedNozzle: false
heatedBed: true
heatedChamber: false
id: _mk3_single
model: Prusa i3 Mk3s
name: Prusa i3 Mk3s
volume:
custom_box: false
depth: 200.0
formFactor: rectangular
height: 200.0
origin: lowerleft
width: 200.0
- axes:
e:
inverted: false
speed: 300
x:
inverted: false
speed: 6000
y:
inverted: false
speed: 6000
z:
inverted: false
speed: 200
color: default
extruder:
count: 5
nozzleDiameter: 0.4
offsets:
- - 0.0
- 0.0
sharedNozzle: true
heatedBed: true
heatedChamber: false
id: _mk3_mmu
model: Prusa i3 Mk3s
name: Pursa i3 Mk3s with MMU
volume:
custom_box: false
depth: 200.0
formFactor: rectangular
height: 200.0
origin: lowerleft
width: 200.0

View File

@ -1,7 +1,16 @@
octoprint_display_name: Prusa MK3s
octoprint_config_display_name: Prusa MK3s
octoprint_domain: spaghetti.binary.kitchen
octoprint_config_default_profile: _mk3_single
octoprint_has_webcam: true
octoprint_ustreamer_args: "-r 1280x720"
octoprint_config:
webcam:
ffmpeg: "/usr/bin/ffmpeg"
snapshot: "http://{{ octoprint_domain }}/webcam/snapshot"
stream: "http://{{ octoprint_domain }}/webcam/stream"
watermark: false
octoprint_printer_profiles:
- axes:

11
hosts
View File

@ -1,8 +1,13 @@
[3D_Printers_test]
raspberrypi
noodlehub.binary.kitchen
[3D_Printers]
spaghetti.binary.kitchen
maccaroni.binary.kitchen
#canneloni.binary.kitchen
[Octoprint_hosts]
spaghetti.binary.kitchen
maccaroni.binary.kitchen
canneloni.binary.kitchen
cannelloni.binary.kitchen

View File

@ -21,7 +21,7 @@ http {
types_hash_max_size 2048;
server_tokens off;
# server_names_hash_bucket_size 64;
server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;

View File

@ -1,7 +1,12 @@
octoprint_user: octoprint
octoprint_group: octoprint
octoprint_dir: "/opt/octoprint"
octoprint_conf_dir: "/home/{{ octoprint_user }}"
octoprint_ssl: false
octoprint_has_webcam: false
octoprint_default_plugins:
- "https://github.com/OctoPrint/OctoPrint-MQTT/archive/master.zip"
octoprint_config_salt: "{{ octoprint_salt }}"
octoprint_config_api_key: "{{ octoprint_api_key}}"

View File

@ -1,33 +0,0 @@
axes:
e:
inverted: false
speed: 300
x:
inverted: false
speed: 6000
y:
inverted: false
speed: 6000
z:
inverted: false
speed: 200
color: default
extruder:
count: 1
nozzleDiameter: 0.4
offsets:
- - 0.0
- 0.0
sharedNozzle: false
heatedBed: true
heatedChamber: false
id: _default
model: Generic RepRap Printer
name: Default
volume:
custom_box: false
depth: 200.0
formFactor: rectangular
height: 200.0
origin: lowerleft
width: 200.0

View File

@ -1,12 +0,0 @@
binarykitchen:
active: true
apikey: null
groups:
- users
- admins
password: fb5adb1fbecb856f2f37da607ea17faf4887cb353b0d28459b12fb814b59d325825b7856d604efddf30b7b0a08e95af0b5a78d6912830bac171d84fe0d8d2a33
permissions: []
roles:
- user
- admin
settings: {}

View File

@ -5,4 +5,7 @@
service: name=octoprint state=restarted
- name: Restart nginx
service: name=nginx state=restarted
service: name=nginx state=restarted
- name: Restart ustreamer
service: name=ustreamer state=restarted

View File

@ -12,6 +12,14 @@
append: yes
groups:
- video
- dialout
- name: Add octoprint user to additional groups
user:
name: "{{ octoprint_user }}"
append: yes
groups: "{{ octoprint_groups }}"
when: octoprint_groups is defined
- name: Install requirements
apt:
@ -19,10 +27,38 @@
- python3-pip
- python3-virtualenv
- name: Create octoprint directory
file:
path: "{{ octoprint_dir }}"
state: directory
owner: "{{ octoprint_user }}"
group: "{{ octoprint_group }}"
- name: Create virtual env and install python dependencies
pip:
name: octoprint
virtualenv: "{{ octoprint_dir }}"
become: true
become_user: "{{ octoprint_user }}"
- name: Install default octoprint plugins
pip:
name: "{{ item }}"
virtualenv: "{{ octoprint_dir }}"
become: true
become_user: "{{ octoprint_user }}"
with_items: "{{ octoprint_default_plugins }}"
notify: Restart octoprint
- name: Install additional octoprint plugins
pip:
name: "{{ item }}"
virtualenv: "{{ octoprint_dir }}"
become: true
become_user: "{{ octoprint_user }}"
with_items: "{{ octoprint_additional_plugins }}"
when: octoprint_additional_plugins is defined
notify: Restart octoprint
- name: Create configuration directories
file:
@ -34,6 +70,8 @@
with_items:
- .octoprint
- .octoprint/printerProfiles
- .octoprint/data
- .octoprint/data/appkeys
- name: Install systemd unit
template: src=octoprint.service.j2 dest=/lib/systemd/system/octoprint.service
@ -59,28 +97,39 @@
octoprint_config_combined: "{{ octoprint_default_config | combine(octoprint_config, recursive=True)}}"
when: octoprint_config is defined
- name: Initial configuration of octoprint
copy:
content: "{{ octoprint_config_combined | to_nice_yaml }}"
dest: "/home/{{ octoprint_user }}/.octoprint/config.yaml"
when: not octoprint_register_config_stat.stat.exists
- name: Apply user config
set_fact:
octoprint_config_combined: "{{ octoprint_default_config }}"
when: octoprint_config is not defined
- name: Update existing Octoprint configuration
- name: Configure Octoprint
block:
- name: Read Octoprint config file
slurp:
src: "/home/{{ octoprint_user }}/.octoprint/config.yaml"
register: octoprint_register_config
- name: Parse Octoprint config file
set_fact:
current_octoprint_config: "{{ octoprint_register_config['content'] | b64decode | from_yaml}}"
- name: Write updated octoprint configuration
- name: Initial configuration of octoprint
copy:
content: "{{ current_octoprint_config | combine(octoprint_config_combined, recursive=True) | to_nice_yaml}}"
dest: "/home/{{octoprint_user}}/.octoprint/config.yaml"
notify: Restart octoprint
content: "{{ octoprint_config_combined | to_nice_yaml }}"
dest: "/home/{{ octoprint_user }}/.octoprint/config.yaml"
when: not octoprint_register_config_stat.stat.exists
- name: Update existing Octoprint configuration
block:
- name: Read Octoprint config file
slurp:
src: "/home/{{ octoprint_user }}/.octoprint/config.yaml"
register: octoprint_register_config
- name: Parse Octoprint config file
set_fact:
current_octoprint_config: "{{ octoprint_register_config['content'] | b64decode | from_yaml}}"
- name: Write updated octoprint configuration
copy:
content: "{{ current_octoprint_config | combine(octoprint_config_combined, recursive=True) | to_nice_yaml}}"
dest: "/home/{{octoprint_user}}/.octoprint/config.yaml"
notify: Restart octoprint
when: octoprint_register_config_stat.stat.exists
become: true
become_user: "{{ octoprint_user }}"
################################################################################
# Octoprint printer configuration
@ -91,48 +140,110 @@
content: "{{ item | to_nice_yaml}}"
dest: "/home/{{ octoprint_user }}/.octoprint/printerProfiles/{{item.id}}.profile"
loop: "{{ octoprint_printer_profiles }}"
become: true
become_user: "{{ octoprint_user }}"
################################################################################
# Octoprint Users
################################################################################
when: octoprint_register_config_stat.stat.exists
- name: Register if user databse already exists on target host
stat:
path: "/home/{{ octoprint_user }}/.octoprint.users.yaml"
register: octoprint_register_users
- name: Read default octoprint users
set_fact:
octoprint_defaut_users: "{{ lookup('file', 'users.yaml') | from_yaml }}"
- name: Copy default users
copy:
src: users.yaml
dest: "/home/{{ octoprint_user }}/.octoprint/users.yaml"
when: not octoprint_register_users.stat.exists
- name: Merge users database with default users
- name: Setup octoprint users
block:
- name: Read Octoprint users file
slurp:
src: "/home/{{ octoprint_user }}/.octoprint/users.yaml"
register: octoprint_register_users_file
- name: Register if user databse already exists on target host
stat:
path: "/home/{{ octoprint_user }}/.octoprint.users.yaml"
register: octoprint_register_users
- name: Parse Octoprint users file
set_fact:
current_octoprint_users: "{{ octoprint_register_users_file['content'] | b64decode | from_yaml }}"
- name: Merge current users with default users
set_fact:
octoprint_users_db: "{{ current_octoprint_users | combine(octoprint_default_users)}}"
- name: Copy new users file
- name: Copy default users
copy:
content: "{{ octoprint_users_db | to_nice_yaml }}"
dest: "/home/{{ octoprint_user }}/.octoprint.users.yaml"
when: octoprint_register_users.stat.exists
content: "{{ octoprint_users_list | to_nice_yaml }}"
dest: "/home/{{ octoprint_user }}/.octoprint/users.yaml"
when: not octoprint_register_users.stat.exists
- name: Merge users database with default users
block:
- name: Read Octoprint users file
slurp:
src: "/home/{{ octoprint_user }}/.octoprint/users.yaml"
register: octoprint_register_users_file
- name: Parse Octoprint users file
set_fact:
current_octoprint_users: "{{ octoprint_register_users_file['content'] | b64decode | from_yaml }}"
- name: Merge current users with default users
set_fact:
octoprint_users_db: "{{ current_octoprint_users | combine(octoprint_users_list)}}"
- name: Copy new users file
copy:
content: "{{ octoprint_users_db | to_nice_yaml }}"
dest: "/home/{{ octoprint_user }}/.octoprint/users.yaml"
when: octoprint_register_users.stat.exists
when: octoprint_users_list is defined
become: true
become_user: "{{ octoprint_user }}"
################################################################################
# Octoprint app keys
################################################################################
- name: Install application keys
block:
- name: Register existing app keys
stat:
path: /home/{{ octoprint_user }}/.octoprint/data/appkeys/keys.yaml
register: app_keys_file
- name: Read existing app keys
slurp:
src: /home/{{ octoprint_user }}/.octoprint/data/appkeys/keys.yaml
register: existing_app_keys_content
when: app_keys_file.stat.exists
- name: Combine local and remote app keys
set_fact:
app_keys_combined: "{{ existing_app_keys_content['content'] | b64decode | from_yaml | combine(octoprint_app_keys ,recursive=True) }}"
when: app_keys_file.stat.exists
- name: Copy default app keys
copy:
content: "{{ app_keys_combined | to_nice_yaml }}"
dest: /home/{{ octoprint_user }}/.octoprint/data/appkeys/keys.yaml
when: app_keys_file.stat.exists
- name: Copy default app keys
copy:
content: "{{ octoprint_app_keys | to_nice_yaml }}"
dest: /home/{{ octoprint_user }}/.octoprint/data/appkeys/keys.yaml
when: not app_keys_file.stat.exists
when: octoprint_app_keys is defined
notify: Restart octoprint
################################################################################
# Webcam
################################################################################
- name: Setup webcam
block:
- name: Install dependencies
apt:
name:
- ffmpeg
- ustreamer
- name: Install systemd unit
template: src=ustreamer.service.j2 dest=/lib/systemd/system/ustreamer.service
notify:
- Reload systemd
- Restart ustreamer
- name: Enable and start ustreamer
service:
name: ustreamer
state: started
enabled: yes
when: octoprint_has_webcam
################################################################################
# Reverse proxy
@ -161,6 +272,7 @@
- name: Enable octoprint
service:
name: octoprint
state: started
enabled: yes

View File

@ -6,6 +6,9 @@ appearance:
accessControl:
salt: "{{ octoprint_config_salt }}"
autologinAs: binarykitchen
localNetworks:
- 127.0.0.0/8
- 172.23.0.0/16
api:
key: "{{ octoprint_config_api_key }}"

View File

@ -5,6 +5,13 @@ server {
server_name {{ octoprint_domain }};
location /webcam/ {
postpone_output 0;
proxy_buffering off;
proxy_ignore_headers X-Accel-Buffering;
proxy_pass http://localhost:8080/;
}
location / {
client_max_body_size 1024M;
proxy_set_header X-Real-IP $remote_addr;
@ -13,7 +20,6 @@ server {
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Script-Name /octoprint;
proxy_http_version 1.1;
proxy_pass http://localhost:5000;
}

View File

@ -7,7 +7,6 @@ After=network.target
RestartSec=2s
Type=simple
User={{ octoprint_user }}
Group={{ octoprint_user }}
WorkingDirectory={{ octoprint_dir }}
ExecStart={{ octoprint_dir }}/bin/octoprint serve
Restart=always

View File

@ -0,0 +1,19 @@
[Unit]
Description=Ustreamer
After=syslog.target
After=network.target
[Service]
RestartSec=2s
Type=simple
User={{ octoprint_user }}
Group={{ octoprint_user }}
{% if octoprint_ustreamer_args is defined %}
ExecStart=/usr/bin/ustreamer {{octoprint_ustreamer_args}}
{% else %}
ExecStart=/usr/bin/ustreamer
{% endif %}
Restart=always
[Install]
WantedBy=multi-user.target

View File

@ -1,5 +1,5 @@
- name: Setup common rules
hosts: [3D_Printers]
hosts: [3D-Printers]
roles:
- common
- root_keys
@ -7,4 +7,5 @@
- name: Setup octoprint
hosts: [Octoprint_hosts]
roles:
- octoprint
- octoprint
tags: octoprint