add tpot.service

This commit is contained in:
t3chn0m4g3 2024-03-19 13:56:35 +01:00
parent 234fb16394
commit abe03436d4
2 changed files with 56 additions and 0 deletions

View file

@ -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

View file

@ -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"]