From c8ed357319d0f597aca9fa50c5176d0e19205e7d Mon Sep 17 00:00:00 2001 From: Luke Hoersten Date: Sat, 10 Sep 2022 14:52:58 -0500 Subject: Initial octoprint role. --- octoprint/files/octoprint.service | 14 ++++++++++++++ octoprint/handlers/main.yaml | 5 +++++ octoprint/tasks/main.yaml | 21 +++++++++++++++++++++ octoprint/vars/main.yaml | 6 ++++++ 4 files changed, 46 insertions(+) create mode 100644 octoprint/files/octoprint.service create mode 100644 octoprint/handlers/main.yaml create mode 100644 octoprint/tasks/main.yaml create mode 100644 octoprint/vars/main.yaml 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" -- cgit v1.2.3