diff --git a/main.yml b/main.yml index 5bb7d86..3702643 100644 --- a/main.yml +++ b/main.yml @@ -2,3 +2,7 @@ - hosts: server roles: - ssh + +- hosts: prusa.lan + roles: + - octoprint diff --git a/octoprint/octoprint.yml b/octoprint/octoprint.yml deleted file mode 100644 index f126190..0000000 --- a/octoprint/octoprint.yml +++ /dev/null @@ -1,52 +0,0 @@ ---- -- name: install octoprint - hosts: prusa.lan - become_method: sudo - become_user: root - become: yes - - tasks: - - name: install needed tools - apt: - update_cache: yes - pkg: - - python-pip - - python-dev - - python-setuptools - - python-virtualenv - - git - - libyaml-dev - - build-essential - - name: create octoprint account - user: - name: octoprint - comment: Octoprint account - groups: tty,dialout - system: yes - password_lock: yes - home: /home/octoprint - - name: install octoprint software - become_user: octoprint - shell: - chdir: /home/octoprint - cmd: | - virtualenv –system-site-packages . - source bin/activate - pip install pip --upgrade - pip install octoprint - args: - executable: /bin/bash - - name: copy systemd service config - copy: - src: octoprint.service - dest: /lib/systemd/system/octoprint.service - - name: enable systemd service - systemd: - name: octoprint - enabled: yes - state: started - - name: enable octoprint to restart itself - copy: - src: sudoers.conf - dest: /etc/sudoers.d/octoprint - mode: 0440 \ No newline at end of file diff --git a/octoprint/octoprint.service b/roles/octoprint/files/octoprint.service similarity index 100% rename from octoprint/octoprint.service rename to roles/octoprint/files/octoprint.service diff --git a/octoprint/sudoers.conf b/roles/octoprint/files/sudoers.conf similarity index 100% rename from octoprint/sudoers.conf rename to roles/octoprint/files/sudoers.conf diff --git a/roles/octoprint/tasks/account.yml b/roles/octoprint/tasks/account.yml new file mode 100644 index 0000000..1cb7995 --- /dev/null +++ b/roles/octoprint/tasks/account.yml @@ -0,0 +1,10 @@ +--- +- name: create octoprint account + become: yes + user: + name: octoprint + comment: Octoprint account + groups: tty,dialout + system: yes + password_lock: yes + home: /home/octoprint diff --git a/roles/octoprint/tasks/install.yml b/roles/octoprint/tasks/install.yml new file mode 100644 index 0000000..e2bd922 --- /dev/null +++ b/roles/octoprint/tasks/install.yml @@ -0,0 +1,26 @@ +--- +- name: install needed tools + become: yes + apt: + update_cache: yes + pkg: + - python-pip + - python-dev + - python-setuptools + - python-virtualenv + - git + - libyaml-dev + - build-essential + +- name: install octoprint software + become: yes + become_user: octoprint + shell: + chdir: /home/octoprint + cmd: | + virtualenv –system-site-packages . + source bin/activate + pip install pip --upgrade + pip install octoprint + args: + executable: /bin/bash diff --git a/roles/octoprint/tasks/main.yml b/roles/octoprint/tasks/main.yml new file mode 100644 index 0000000..98fa87a --- /dev/null +++ b/roles/octoprint/tasks/main.yml @@ -0,0 +1,7 @@ +--- +- import_tasks: account.yml + +- import_tasks: install.yml + +- import_tasks: service.yml + diff --git a/roles/octoprint/tasks/service.yml b/roles/octoprint/tasks/service.yml new file mode 100644 index 0000000..bb27a9d --- /dev/null +++ b/roles/octoprint/tasks/service.yml @@ -0,0 +1,20 @@ +--- +- name: copy systemd service config + become: yes + copy: + src: octoprint.service + dest: /lib/systemd/system/octoprint.service + +- name: enable systemd service + become: yes + systemd: + name: octoprint + enabled: yes + state: started + +- name: enable octoprint to restart itself + become: yes + copy: + src: sudoers.conf + dest: /etc/sudoers.d/octoprint + mode: 0440