diff --git a/installer/install/tpot.service b/installer/install/tpot.service new file mode 100644 index 00000000..08968d76 --- /dev/null +++ b/installer/install/tpot.service @@ -0,0 +1,17 @@ +[Unit] +Description=T-Pot +Wants=docker.service network-online.target +After=docker.service network-online.target + +[Service] +Restart=always +RestartSec=5 +Type=simple +TimeoutSec=infinity +ExecStartPre=-/usr/bin/docker compose -f /home/{{ ansible_user_id }}/tpotce/docker-compose.yml down -v +ExecStart=/usr/bin/docker compose -f /home/{{ ansible_user_id }}/tpotce/docker-compose.yml up +ExecStop=/usr/bin/docker compose -f /home/{{ ansible_user_id }}/tpotce/docker-compose.yml down -v +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target diff --git a/installer/install/tpot.yml b/installer/install/tpot.yml index e9b2523a..0f66d1b6 100644 --- a/installer/install/tpot.yml +++ b/installer/install/tpot.yml @@ -672,3 +672,42 @@ msg: "Detected user: '{{ ansible_user_id }}'" when: ansible_distribution in ["AlmaLinux", "Debian", "Fedora", "openSUSE Tumbleweed", "Raspbian", "Rocky", "Ubuntu"] failed_when: ansible_user_id == "root" + +########################### +# T-Pot - Install service # +########################### + +- name: T-Pot - Install service + hosts: all + gather_facts: true + become: false + tags: + - "AlmaLinux" + - "Debian" + - "Fedora" + - "openSUSE Tumbleweed" + - "Raspbian" + - "Rocky" + - "Ubuntu" + + tasks: + - name: Install systemd service (All) + become: true + ansible.builtin.template: + src: '/home/{{ ansible_user_id }}/tpotce/installer/install/tpot.service' + dest: '/etc/systemd/system/tpot.service' + owner: root + group: root + mode: '0755' + notify: Reload systemd and enable service + when: ansible_distribution in ["AlmaLinux", "Debian", "Fedora", "openSUSE Tumbleweed", "Raspbian", "Rocky", "Ubuntu"] + + handlers: + - name: Reload systemd and enable service + become: true + ansible.builtin.systemd: + name: tpot.service + daemon_reload: yes + state: stopped + enabled: yes + when: ansible_distribution in ["AlmaLinux", "Debian", "Fedora", "openSUSE Tumbleweed", "Raspbian", "Rocky", "Ubuntu"]