diff --git a/operations/opentracker/defaults/main.yml b/operations/opentracker/defaults/main.yml new file mode 100644 index 0000000..8ccd0a4 --- /dev/null +++ b/operations/opentracker/defaults/main.yml @@ -0,0 +1,10 @@ +--- +# +# 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 new file mode 100644 index 0000000..39e0ac5 --- /dev/null +++ b/operations/opentracker/files/known_hosts @@ -0,0 +1 @@ +|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/files/whitelist b/operations/opentracker/files/whitelist new file mode 100644 index 0000000..63d3a29 --- /dev/null +++ b/operations/opentracker/files/whitelist @@ -0,0 +1,26 @@ +0f551b756aca80513dc6e7cad16436ff3b672c89 +25c7ede4f78672f627a697b14e0c34c3f77cbecb +2f8055a042556f5dd71eb2d7b168e25429da5c89 +4fcdc8d87d8cad6f0e3d9e34d273f672bdbbf791 +5220e682c8b8e2c1de5de1618121f86a897b3897 +558ab9ad2acb5b5c808737eea548e3e04256d5a6 +5638b744a69a8181489d48464e2deac16339fb81 +698a6c7ace63ea126039127a868e8066a77b173b +71875b5d4cb7fd3d6849b7eff922178147f62de9 +7b3b7c967596b443a45ab13432e92fd3e35bb440 +7eebe9c650bc9c57664849ba65f8056e0cd69661 +81dc470986a2776b70ebf2c92f4812bbfa202a40 +82557e5e1dea61b470d9a65e94ffbe53cecd9f43 +834620626e594a3268f7708afae0ef51ba368752 +9a2da0808262d130556ede7e45904e614b124d73 +a21b5051ec22ed64fb180d3abb5b4a4cb9ece3de +aac951bc59cbfbea3cb557a7c8585a82c367529a +b7d75c6dfea294ac1e8521701b36bb87f3314066 +bbac0709dbe0e31fb7c2f63913240debce495fc0 +bbcf64ca21534a74fe4d4118c2efab13eb834e26 +c283bf37bc1284214cab01d8e84fc211143d7a25 +d3af40550af57d9a151aa138fa513942b195232a +d684d814af85c3eae13a083e8c92b97b6f86e03d +e877d26b8853bbb308529c4f1fd6c76e7e2099f7 +f3fc9ad2270605042ff6a598e8bd9b75d8690d35 +fd4ab37e04bf28b889132e72927d6620b53a3866 diff --git a/operations/opentracker/handlers/main.yml b/operations/opentracker/handlers/main.yml new file mode 100644 index 0000000..2aed893 --- /dev/null +++ b/operations/opentracker/handlers/main.yml @@ -0,0 +1,10 @@ +--- +# +# OpenTracker handlers. +# + +- name: Restart OpenTracker + service: + name: opentracker + enabled: yes + state: restarted diff --git a/operations/opentracker/tasks/conf.yml b/operations/opentracker/tasks/conf.yml new file mode 100644 index 0000000..d181a0e --- /dev/null +++ b/operations/opentracker/tasks/conf.yml @@ -0,0 +1,31 @@ +--- +# +# 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 new file mode 100644 index 0000000..b554086 --- /dev/null +++ b/operations/opentracker/tasks/main.yml @@ -0,0 +1,13 @@ +--- +# +# 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 new file mode 100644 index 0000000..a07f4bb --- /dev/null +++ b/operations/opentracker/tasks/make.yml @@ -0,0 +1,42 @@ +--- +# +# 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 | 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 | changed + +- name: Clean OpenTracker + make: + chdir: "{{ opentracker.repo }}" + target: clean + become: yes + become_user: "{{ opentracker.user }}" + when: result | changed diff --git a/operations/opentracker/tasks/prep.yml b/operations/opentracker/tasks/prep.yml new file mode 100644 index 0000000..80e6b20 --- /dev/null +++ b/operations/opentracker/tasks/prep.yml @@ -0,0 +1,46 @@ +--- +# +# 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 new file mode 100644 index 0000000..858de3f --- /dev/null +++ b/operations/opentracker/templates/config @@ -0,0 +1,2 @@ +access.whitelist {{ opentracker.conf }}/whitelist +tracker.redirect_url http://www.fimfarchive.net/ diff --git a/operations/opentracker/templates/service b/operations/opentracker/templates/service new file mode 100644 index 0000000..8df2831 --- /dev/null +++ b/operations/opentracker/templates/service @@ -0,0 +1,13 @@ +[Unit] +Description=OpenTracker +After=network.target + +[Service] +Type=simple +User={{ opentracker.user }} +WorkingDirectory={{ opentracker.conf }} +ExecStart=/usr/local/bin/opentracker -f "{{ opentracker.conf }}/config" +Restart=on-abort + +[Install] +WantedBy=multi-user.target diff --git a/operations/tracker.yml b/operations/tracker.yml index b979773..75cb315 100644 --- a/operations/tracker.yml +++ b/operations/tracker.yml @@ -7,3 +7,4 @@ hosts: trackers roles: - common + - opentracker