--- - name: 'setup | Ensure required vars are set' ansible.builtin.assert: that: - item | mandatory loop: - '{{ torrents_nas_mount_path }}' - '{{ torrents_rpc_username }}' - '{{ torrents_rpc_password }}' no_log: true - name: 'setup | Install required pkgs' ansible.builtin.package: name: - 'nfs-common' - 'transmission-daemon' - name: 'setup | Stop the transmission-daemon service' ansible.builtin.service: name: 'transmission-daemon' state: 'stopped' - name: 'setup | Create the mount dir' ansible.builtin.file: path: '/mnt/data' state: 'directory' mode: '755' - name: 'setup | Setup the NFS mount' ansible.posix.mount: src: '{{ torrents_nas_mount_path }}' path: '/mnt/data' state: 'mounted' fstype: 'nfs' - name: 'setup | Create new user for transmission' ansible.builtin.user: name: 'transmission-user' uid: 1001 groups: 'users' create_home: true - name: 'setup | Fix the service file to use our user' ansible.builtin.lineinfile: path: '/lib/systemd/system/transmission-daemon.service' regexp: '^User=' line: 'User=transmission-user' - name: 'setup | Reload systemd daemon' ansible.builtin.systemd: daemon_reload: true # THis is kind of a hack to force the generation of # /home/transmission-user/.config/transmission-daemon dirs # so that we can place our config file there. - name: 'setup | Start the service' ansible.builtin.service: name: 'transmission-daemon' state: 'started' # We still need to stop it to place the config file or else it will get overwritten - name: 'setup | Stop the service' ansible.builtin.service: name: 'transmission-daemon' state: 'stopped' - name: 'setup | Copy the transmission config' ansible.builtin.template: src: 'settings.json.j2' dest: '/home/transmission-user/.config/transmission-daemon/settings.json' owner: 'transmission-user' mode: '644' - name: 'setup | Start the service' ansible.builtin.service: name: 'transmission-daemon' state: 'started' enabled: true