src.nth.io/

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--octoprint/files/octoprint.service14
-rw-r--r--octoprint/handlers/main.yaml5
-rw-r--r--octoprint/tasks/main.yaml21
-rw-r--r--octoprint/vars/main.yaml6
4 files changed, 46 insertions, 0 deletions
diff --git a/octoprint/files/octoprint.service b/octoprint/files/octoprint.service
new file mode 100644
index 0000000..0aab27f
--- /dev/null
+++ b/octoprint/files/octoprint.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Octoprint
+After=network.target
+
+[Service]
+Environment="LC_ALL=C.UTF-8"
+Environment="LANG=C.UTF-8"
+User=octoprint
+Group=octoprint
+WorkingDirectory=/opt/octoprint/
+ExecStart=/usr/local/bin/octoprint
+
+[Install]
+WantedBy=multi-user.target
diff --git a/octoprint/handlers/main.yaml b/octoprint/handlers/main.yaml
new file mode 100644
index 0000000..0c2665e
--- /dev/null
+++ b/octoprint/handlers/main.yaml
@@ -0,0 +1,5 @@
+---
+
+- name: restart octoprint
+ become: yes
+ systemd: name="octoprint.service" state="restarted" daemon_reload="yes"
diff --git a/octoprint/tasks/main.yaml b/octoprint/tasks/main.yaml
new file mode 100644
index 0000000..debed3c
--- /dev/null
+++ b/octoprint/tasks/main.yaml
@@ -0,0 +1,21 @@
+---
+
+- name: add octoprint user
+ become: yes
+ user: name="octoprint" groups="{{octoprint_groups}}" home="/opt/octoprint" system="yes"
+
+- name: pip install octoprint
+ become: yes
+ pip: name="octoprint" executable="pip3"
+ notify: restart octoprint
+
+- name: install octoprint systemd service
+ become: yes
+ copy:
+ src: "octoprint.service"
+ dest: "/lib/systemd/system/octoprint.service"
+ notify: restart octoprint
+
+- name: ensure octoprint service is started
+ become: yes
+ systemd: name="octoprint.service" enabled="yes"
diff --git a/octoprint/vars/main.yaml b/octoprint/vars/main.yaml
new file mode 100644
index 0000000..7fd4267
--- /dev/null
+++ b/octoprint/vars/main.yaml
@@ -0,0 +1,6 @@
+---
+
+octoprint_groups:
+ - "tty"
+ - "dialout"
+ - "video"