From e81530eeaf52985a781e12f9b36f164257da1f72 Mon Sep 17 00:00:00 2001 From: Joakim Soderlund Date: Sun, 27 Aug 2023 11:54:51 +0200 Subject: [PATCH] Replace tracker playbook with container --- operations/opentracker/defaults/main.yml | 10 ---- operations/opentracker/files/known_hosts | 1 - operations/opentracker/handlers/main.yml | 11 ----- operations/opentracker/tasks/conf.yml | 31 ------------- operations/opentracker/tasks/main.yml | 13 ------ operations/opentracker/tasks/make.yml | 42 ----------------- operations/opentracker/tasks/prep.yml | 46 ------------------- operations/opentracker/templates/config | 2 - operations/opentracker/templates/service | 14 ------ operations/tracker.yml | 10 ---- operations/tracker/Dockerfile | 14 ++++++ operations/tracker/opentracker.conf | 2 + .../files/whitelist => tracker/whitelist.txt} | 0 13 files changed, 16 insertions(+), 180 deletions(-) delete mode 100644 operations/opentracker/defaults/main.yml delete mode 100644 operations/opentracker/files/known_hosts delete mode 100644 operations/opentracker/handlers/main.yml delete mode 100644 operations/opentracker/tasks/conf.yml delete mode 100644 operations/opentracker/tasks/main.yml delete mode 100644 operations/opentracker/tasks/make.yml delete mode 100644 operations/opentracker/tasks/prep.yml delete mode 100644 operations/opentracker/templates/config delete mode 100644 operations/opentracker/templates/service delete mode 100644 operations/tracker.yml create mode 100644 operations/tracker/Dockerfile create mode 100644 operations/tracker/opentracker.conf rename operations/{opentracker/files/whitelist => tracker/whitelist.txt} (100%) diff --git a/operations/opentracker/defaults/main.yml b/operations/opentracker/defaults/main.yml deleted file mode 100644 index 8ccd0a4..0000000 --- a/operations/opentracker/defaults/main.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -# -# OpenTracker defaults. -# - -opentracker: - user: tracker - home: /var/lib/tracker - repo: /var/lib/tracker/repo - conf: /etc/opentracker diff --git a/operations/opentracker/files/known_hosts b/operations/opentracker/files/known_hosts deleted file mode 100644 index 39e0ac5..0000000 --- a/operations/opentracker/files/known_hosts +++ /dev/null @@ -1 +0,0 @@ -|1|g3eQLNbOEXgmpTukEKu+dM+7IKs=|XIQfqI0+JM9+Cr3e+6XxuzYbp2k= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAniRprCbiuO7GNUyT6quk6OrA8xFHrSI64jL95T3zw6RhqSkN0OE9CJEpwa9MV3FRk+odeU/WmUDTGNr5LZgqjmK4RtEJAoh8h9hV1/9ZN1ca6HjqQZtWQriR3pk6Qk+BVeo8u0UaTApL52mDHDwX5/G5o7csRuAm7b55/d0qyx5ozLgzAk/anTHSzXKyL8r1ZBUQ+NUBrf70xk2TVEOdKUrwoCuV1eyBf2wzdSaaTh/Zi2w2sDp6ECpmQLQnwg4VyNZk4BNtdLklbzT+j/I5n86+mGf+1NHgMxqGVx50iE+mhg/E6QK+XR3HQ8b2rbBYGI8qv84j1QKhcHhzX5eCIw== diff --git a/operations/opentracker/handlers/main.yml b/operations/opentracker/handlers/main.yml deleted file mode 100644 index 96b2b68..0000000 --- a/operations/opentracker/handlers/main.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -# -# OpenTracker handlers. -# - -- name: Restart OpenTracker - systemd: - name: opentracker - enabled: yes - daemon_reload: yes - state: restarted diff --git a/operations/opentracker/tasks/conf.yml b/operations/opentracker/tasks/conf.yml deleted file mode 100644 index d181a0e..0000000 --- a/operations/opentracker/tasks/conf.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- -# -# Configures OpenTracker. -# - -- name: Create config directory - file: - path: "{{ opentracker.conf }}" - state: directory - mode: 0755 - -- name: Copy config file - template: - src: config - dest: "{{ opentracker.conf }}/config" - mode: 0644 - notify: Restart OpenTracker - -- name: Copy whitelist file - copy: - src: whitelist - dest: "{{ opentracker.conf }}/whitelist" - mode: 0644 - notify: Restart OpenTracker - -- name: Install service - template: - src: service - dest: /etc/systemd/system/opentracker.service - mode: 0644 - notify: Restart OpenTracker diff --git a/operations/opentracker/tasks/main.yml b/operations/opentracker/tasks/main.yml deleted file mode 100644 index b554086..0000000 --- a/operations/opentracker/tasks/main.yml +++ /dev/null @@ -1,13 +0,0 @@ ---- -# -# OpenTracker tasks. -# - -- name: Prepare system - include: prep.yml - -- name: Install OpenTracker - include: make.yml - -- name: Configure OpenTracker - include: conf.yml diff --git a/operations/opentracker/tasks/make.yml b/operations/opentracker/tasks/make.yml deleted file mode 100644 index c7f632e..0000000 --- a/operations/opentracker/tasks/make.yml +++ /dev/null @@ -1,42 +0,0 @@ ---- -# -# Builds and installs OpenTracker. -# - -- name: Clone OpenTracker - git: - repo: git://erdgeist.org/opentracker - dest: "{{ opentracker.repo }}" - force: yes - become: yes - become_user: "{{ opentracker.user }}" - register: result - -- name: Build OpenTracker - make: - chdir: "{{ opentracker.repo }}" - target: opentracker - environment: - FEATURES: "-DWANT_ACCESSLIST_WHITE" - become: yes - become_user: "{{ opentracker.user }}" - when: result is changed - -- name: Install OpenTracker - copy: - remote_src: yes - src: "{{ opentracker.repo }}/opentracker" - dest: /usr/local/bin/opentracker - mode: 0755 - owner: root - group: root - notify: Restart OpenTracker - when: result is changed - -- name: Clean OpenTracker - make: - chdir: "{{ opentracker.repo }}" - target: clean - become: yes - become_user: "{{ opentracker.user }}" - when: result is changed diff --git a/operations/opentracker/tasks/prep.yml b/operations/opentracker/tasks/prep.yml deleted file mode 100644 index 80e6b20..0000000 --- a/operations/opentracker/tasks/prep.yml +++ /dev/null @@ -1,46 +0,0 @@ ---- -# -# Prepares system for OpenTracker. -# - -- name: Install build dependencies - apt: - name: "{{ item }}" - state: present - with_items: - - build-essential - - git - - libowfat-dev - - zlib1g-dev - -- name: Create UNIX group - group: - name: "{{ opentracker.user }}" - system: yes - state: present - -- name: Create UNIX user - user: - name: "{{ opentracker.user }}" - group: "{{ opentracker.user }}" - home: "{{ opentracker.home }}" - createhome: yes - skeleton: yes - system: yes - state: present - -- name: Create SSH directory - file: - path: "{{ opentracker.home }}/.ssh" - owner: "{{ opentracker.user }}" - group: "{{ opentracker.user }}" - mode: 0500 - state: directory - -- name: Configure SSH hosts - copy: - src: known_hosts - dest: "{{ opentracker.home }}/.ssh/known_hosts" - owner: "{{ opentracker.user }}" - group: "{{ opentracker.user }}" - mode: 0400 diff --git a/operations/opentracker/templates/config b/operations/opentracker/templates/config deleted file mode 100644 index 858de3f..0000000 --- a/operations/opentracker/templates/config +++ /dev/null @@ -1,2 +0,0 @@ -access.whitelist {{ opentracker.conf }}/whitelist -tracker.redirect_url http://www.fimfarchive.net/ diff --git a/operations/opentracker/templates/service b/operations/opentracker/templates/service deleted file mode 100644 index 2912f90..0000000 --- a/operations/opentracker/templates/service +++ /dev/null @@ -1,14 +0,0 @@ -[Unit] -Description=OpenTracker -After=network-online.target - -[Service] -Type=simple -User={{ opentracker.user }} -Group={{ opentracker.user }} -WorkingDirectory={{ opentracker.home }} -ExecStart=/usr/local/bin/opentracker -f "{{ opentracker.conf }}/config" -Restart=on-failure - -[Install] -WantedBy=multi-user.target diff --git a/operations/tracker.yml b/operations/tracker.yml deleted file mode 100644 index 75cb315..0000000 --- a/operations/tracker.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -# -# Configures trackers. -# - -- name: Tracker - hosts: trackers - roles: - - common - - opentracker diff --git a/operations/tracker/Dockerfile b/operations/tracker/Dockerfile new file mode 100644 index 0000000..ce8dd80 --- /dev/null +++ b/operations/tracker/Dockerfile @@ -0,0 +1,14 @@ +FROM docker.io/library/debian:bookworm-slim + +RUN apt-get -y update \ + && apt-get -y full-upgrade \ + && apt-get -y install opentracker \ + && rm -r /var/lib/apt/lists/* + +COPY opentracker.conf whitelist.txt /etc/opentracker/ + +EXPOSE 6969/tcp +EXPOSE 6969/udp +USER 6969:6969 + +CMD ["/usr/bin/opentracker", "-f", "/etc/opentracker/opentracker.conf"] diff --git a/operations/tracker/opentracker.conf b/operations/tracker/opentracker.conf new file mode 100644 index 0000000..ade8e62 --- /dev/null +++ b/operations/tracker/opentracker.conf @@ -0,0 +1,2 @@ +access.whitelist /etc/opentracker/whitelist.txt +tracker.redirect_url http://www.fimfarchive.net/ diff --git a/operations/opentracker/files/whitelist b/operations/tracker/whitelist.txt similarity index 100% rename from operations/opentracker/files/whitelist rename to operations/tracker/whitelist.txt