114 lines
3.1 KiB
YAML
114 lines
3.1 KiB
YAML
---
|
||
- name: "Seedbox setup"
|
||
hosts: "localhost"
|
||
connection: "local"
|
||
tasks:
|
||
- name: Get seedbox user info
|
||
getent:
|
||
database: passwd
|
||
key: "{{ seedbox_user }}"
|
||
|
||
- name: Fetch exporter repo
|
||
git:
|
||
repo: https://github.com/mdlayher/rtorrent_exporter
|
||
dest: "{{ exporter_path }}"
|
||
become: yes
|
||
become_user: "{{ seedbox_user }}"
|
||
|
||
- name: Ensure ownership by the seedbox user
|
||
file:
|
||
path: "{{ item }}"
|
||
owner: "{{ seedbox_user }}"
|
||
group: "{{ seedbox_user }}"
|
||
state: directory
|
||
recurse: yes
|
||
loop:
|
||
- "{{ seedbox_path }}"
|
||
- "{{ exporter_path }}"
|
||
|
||
- name: Build rtorrent image
|
||
containers.podman.podman_image:
|
||
name: rtorrent
|
||
force: yes
|
||
path: "{{ seedbox_path }}/rtorrent"
|
||
build:
|
||
extra_args: "--build-arg UID={{ getent_passwd[seedbox_user].2 }}"
|
||
|
||
- name: Build scgiproxy image
|
||
containers.podman.podman_image:
|
||
name: rtorrent-proxy
|
||
force: yes
|
||
path: "{{ seedbox_path }}/scgiproxy"
|
||
|
||
- name: Build exporter image
|
||
containers.podman.podman_image:
|
||
name: rtorrent-exporter
|
||
force: yes
|
||
path: "{{ exporter_path }}"
|
||
|
||
- name: Create directories
|
||
file:
|
||
path: "{{ item }}"
|
||
owner: "{{ seedbox_user }}"
|
||
group: "{{ seedbox_user }}"
|
||
state: directory
|
||
loop:
|
||
- "{{ dir_downloads }}"
|
||
- "{{ dir_sessions }}"
|
||
- "{{ dir_watch }}"
|
||
- "{{ dir_log }}"
|
||
- "{{ dir_rutorrent }}"
|
||
- "{{ dir_run }}"
|
||
|
||
- name: Create seedbox pod
|
||
containers.podman.podman_pod:
|
||
name: seedbox
|
||
state: started
|
||
recreate: yes
|
||
ports:
|
||
# Rtorrent
|
||
- 6890:6890/tcp
|
||
- 6890:6890/udp
|
||
# Rtorrent DHT
|
||
- 6889:6889/udp
|
||
# SCGI proxy
|
||
- 6880:80/tcp
|
||
# Exporter
|
||
- 9135:9135/tcp
|
||
|
||
- name: Add rtorrent container
|
||
containers.podman.podman_container:
|
||
name: rtorrent
|
||
image: rtorrent
|
||
state: started
|
||
pod: seedbox
|
||
volumes:
|
||
- "{{ dir_downloads }}:/data/downloads"
|
||
- "{{ seedbox_path }}/rtorrent/rtorrent.rc:/seedbox/.rtorrent.rc"
|
||
- "{{ dir_sessions }}:/var/lib/seedbox/sessions"
|
||
- "{{ dir_watch }}:/seedbox/watch/load"
|
||
- "{{ dir_log }}:/seedbox/log"
|
||
- "{{ dir_rutorrent }}:/srv/www/tortuga.ppsfleet.navy"
|
||
- "{{ dir_run }}:/var/run/seedbox"
|
||
ulimit:
|
||
- nofile=122880:122880
|
||
restart_policy: always
|
||
|
||
- name: Add proxy container
|
||
containers.podman.podman_container:
|
||
name: rtorrent-proxy
|
||
image: rtorrent-proxy
|
||
state: started
|
||
pod: seedbox
|
||
volumes:
|
||
- "{{ dir_run }}:/var/run/seedbox"
|
||
restart_policy: always
|
||
|
||
- name: Add exporter container
|
||
containers.podman.podman_container:
|
||
name: rtorrent-exporter
|
||
image: rtorrent-exporter
|
||
state: started
|
||
pod: seedbox
|
||
command: -rtorrent.addr http://127.0.0.1/RPC2
|