From 1f71b639f629bea262c181009c45acf71dc640b0 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Fri, 1 Feb 2019 23:05:15 +0100 Subject: [PATCH] finish installation tasks --- defaults/main.yml | 30 ++++++--- tasks/install.yml | 61 +++++++++++-------- tasks/prepare.yml | 18 ------ templates/etc/logrotate.d/config.j2 | 10 +++ .../etc/systemd/system/jellyfin.service.j2 | 20 ++++++ 5 files changed, 86 insertions(+), 53 deletions(-) create mode 100644 templates/etc/logrotate.d/config.j2 create mode 100644 templates/etc/systemd/system/jellyfin.service.j2 diff --git a/defaults/main.yml b/defaults/main.yml index 4bf836c..2cae73d 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -7,14 +7,6 @@ jellyfin_group: "{{ jellyfin_user }}" # jellyfin_gid: # defaults to not set jellyfin_extra_groups: [] -jellyfin_dependencies: - - lttng-ust - - libcurl - - openssl-libs - - krb5-libs - - libicu - - zlib - # Create separate LVM storage for jellyfin jellyfin_lvm_enabled: False # This variables are only necessary if jellyfin_lvm_enabled is 'True' @@ -29,3 +21,25 @@ jellyfin_base_dir: "/opt/jellyfin" jellyfin_conf_dir: "{{ jellyfin_base_dir }}/config" jellyfin_data_dir: "{{ jellyfin_base_dir }}/data" jellyfin_log_dir: "{{ jellyfin_base_dir }}/log" + +jellyfin_logrotate_enabled: False +jellyfin_logrotate_config: + - log: "{{ jellyfin_log_dir }}/jellyfin.log" + options: + - weekly + - rotate 4 + - maxsize 250K + - compress + - shred + +# DONT CHANGE IT! +# Changing the bind ports is currently not supported +jellyfin_http_bind_port: 8096 +jellyfin_https_bind_port: 8920 + +jellyfin_iptables_enabled: False +jellyfin_open_ports: + - name: allow_jellyfin_web + rules: | + -A INPUT -m state --state NEW -p tcp --dport {{ jellyfin_http_bind_port }} -j ACCEPT + state: present diff --git a/tasks/install.yml b/tasks/install.yml index 140ee15..18ed157 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -32,35 +32,42 @@ loop: - "logging.json" # notify: __jellyfin_restart + + - name: Link v'{{ jellyfin_version }}' to latest + file: + src: "{{ jellyfin_base_dir }}/{{ jellyfin_version }}/jellyfin" + dest: "{{ jellyfin_base_dir }}/jellyfin-latest" + state: link + # notify: __jellyfin_restart become: True become_user: "{{ jellyfin_user }}" -# - block: -# - name: Copy systemd unit file -# template: -# src: "etc/systemd/system/jellyfin.service.j2" -# dest: "/etc/systemd/system/jellyfin.service" -# notify: __jellyfin_restart +- block: + - name: Copy systemd unit file + template: + src: "etc/systemd/system/jellyfin.service.j2" + dest: "/etc/systemd/system/jellyfin.service" + # notify: __jellyfin_restart -# - name: Copy logrotate config -# template: -# src: "etc/logrotate.d/config.j2" -# dest: "/etc/logrotate.d/jellyfin" -# loop: "{{ jellyfin_logrotate_config }}" -# loop_control: -# label: "{{ item.log }}" -# when: jellyfin_logrotate_enabled + - name: Copy logrotate config + template: + src: "etc/logrotate.d/config.j2" + dest: "/etc/logrotate.d/jellyfin" + loop: "{{ jellyfin_logrotate_config }}" + loop_control: + label: "{{ item.log }}" + when: jellyfin_logrotate_enabled -# - name: Open ports in iptables -# iptables_raw: -# name: "{{ item.name }}" -# rules: "{{ item.rules }}" -# state: "{{ item.state }}" -# weight: "{{ item.weight | default(omit) }}" -# table: "{{ item.table | default(omit) }}" -# loop: "{{ jellyfin_open_ports }}" -# loop_control: -# label: "{{ item.name }}" -# when: jellyfin_iptables_enabled -# become: True -# become_user: root + - name: Open ports in iptables + iptables_raw: + name: "{{ item.name }}" + rules: "{{ item.rules }}" + state: "{{ item.state }}" + weight: "{{ item.weight | default(omit) }}" + table: "{{ item.table | default(omit) }}" + loop: "{{ jellyfin_open_ports }}" + loop_control: + label: "{{ item.name }}" + when: jellyfin_iptables_enabled + become: True + become_user: root diff --git a/tasks/prepare.yml b/tasks/prepare.yml index e2b7fa9..cc49c6c 100644 --- a/tasks/prepare.yml +++ b/tasks/prepare.yml @@ -14,23 +14,5 @@ uid: "{{ jellyfin_uid | default(omit) }}" group: "{{ jellyfin_group }}" groups: "{{ jellyfin_extra_groups | join(',') }}" - - - name: Add .Net repository - yum_repository: - name: packages-microsoft-com-prod - description: RPMforge YUM repo - file: Dotnet-Dev - baseurl: "https://packages.microsoft.com/yumrepos/microsoft-rhel7.3-prod/" - enabled: yes - gpgcheck : yes - gpgkey: https://packages.microsoft.com/keys/microsoft.asc - - - name: Install dependencies - package: - name: "{{ item }}" - state: present - loop: - - "{{ jellyfin_dependencies }}" - - dotnet-sdk-2.2 become: True become_user: root diff --git a/templates/etc/logrotate.d/config.j2 b/templates/etc/logrotate.d/config.j2 new file mode 100644 index 0000000..5e0ede0 --- /dev/null +++ b/templates/etc/logrotate.d/config.j2 @@ -0,0 +1,10 @@ +#jinja2: lstrip_blocks: True +# {{ ansible_managed }} +{{ item.log }} { + {% for option in item.options %} + {{ option }} + {% endfor %} + postrotate + /usr/bin/pkill -HUP rsyslogd + endscript +} diff --git a/templates/etc/systemd/system/jellyfin.service.j2 b/templates/etc/systemd/system/jellyfin.service.j2 new file mode 100644 index 0000000..19bcece --- /dev/null +++ b/templates/etc/systemd/system/jellyfin.service.j2 @@ -0,0 +1,20 @@ +#jinja2: lstrip_blocks: True +# {{ ansible_managed }} +[Unit] +Description=Jellyfin Media Server +After=network.target + +[Service] +Type=simple +Environment=JELLYFIN_DATA_PATH={{ jellyfin_data_dir }} +Environment=JELLYFIN_CONFIG_DIR={{ jellyfin_config_dir }} +Environment=JELLYFIN_LOG_DIR={{ jellyfin_log_dir }} +Restart=on-failure +TimeoutSec=15 +User={{ jellyfin_user }} +Group={{ jellyfin_group }} +WorkingDirectory={{ jellyfin_base_dir }} +ExecStart={{ jellyfin_base_dir }}/jellyfin-latest + +[Install] +WantedBy=multi-user.target