--- - name: Install prerequisites ansible.builtin.package: name: - curl - sqlite3 state: present become: true - name: Set architecture fact ansible.builtin.set_fact: _prowlarr_arch: "{{ {'x86_64': 'x64', 'aarch64': 'arm64', 'armv7l': 'arm'}.get(ansible_architecture, 'x64') }}" - name: Get Prowlarr release info from GitHub ansible.builtin.uri: url: >- {{ 'https://api.github.com/repos/Prowlarr/Prowlarr/releases/latest' if prowlarr_version == '' else 'https://api.github.com/repos/Prowlarr/Prowlarr/releases/tags/v' + prowlarr_version }} headers: Accept: "application/vnd.github.v3+json" return_content: true register: _prowlarr_release - name: Set version and download URL facts ansible.builtin.set_fact: _prowlarr_version_tag: "{{ _prowlarr_release.json.tag_name }}" _prowlarr_download_url: >- {{ _prowlarr_release.json.assets | selectattr('name', 'search', 'linux-core-' + _prowlarr_arch) | map(attribute='browser_download_url') | first }} - name: Read installed version ansible.builtin.slurp: src: "{{ prowlarr_install_dir }}/.version" register: _prowlarr_installed_raw ignore_errors: true become: true - name: Set installed version fact ansible.builtin.set_fact: _prowlarr_installed_version: >- {{ (_prowlarr_installed_raw.content | b64decode | trim) if _prowlarr_installed_raw is not failed else '' }} - name: Install or upgrade Prowlarr when: _prowlarr_installed_version != _prowlarr_version_tag block: - name: Download Prowlarr archive ansible.builtin.get_url: url: "{{ _prowlarr_download_url }}" dest: /tmp/prowlarr.tar.gz mode: '0644' - name: Create Prowlarr installation directory ansible.builtin.file: path: "{{ prowlarr_install_dir }}" state: directory owner: "{{ prowlarr_user }}" group: "{{ prowlarr_group }}" mode: '0755' become: true - name: Extract Prowlarr archive ansible.builtin.unarchive: src: /tmp/prowlarr.tar.gz dest: "{{ prowlarr_install_dir }}" remote_src: true extra_opts: [--strip-components=1] owner: "{{ prowlarr_user }}" group: "{{ prowlarr_group }}" become: true - name: Write installed version file ansible.builtin.copy: content: "{{ _prowlarr_version_tag }}" dest: "{{ prowlarr_install_dir }}/.version" owner: "{{ prowlarr_user }}" group: "{{ prowlarr_group }}" mode: '0644' become: true - name: Remove downloaded archive ansible.builtin.file: path: /tmp/prowlarr.tar.gz state: absent - name: Create Prowlarr data directory ansible.builtin.file: path: "{{ prowlarr_data_dir }}" state: directory owner: "{{ prowlarr_user }}" group: "{{ prowlarr_group }}" mode: '0750' become: true - name: Create Prowlarr systemd service ansible.builtin.copy: content: | [Unit] Description=Prowlarr After=syslog.target network.target [Service] SyslogIdentifier=prowlarr ExecStart={{ prowlarr_install_dir }}/Prowlarr -nobrowser -data={{ prowlarr_data_dir }} TimeoutStopSec=20 KillMode=process Restart=on-failure User={{ prowlarr_user }} Group={{ prowlarr_group }} UMask=0002 [Install] WantedBy=multi-user.target dest: /etc/systemd/system/prowlarr.service mode: '0644' become: true - name: Enable and start Prowlarr service ansible.builtin.systemd: name: prowlarr enabled: "{{ prowlarr_service_enabled }}" state: "{{ prowlarr_service_state }}" daemon_reload: true become: true