- name: Initialize homeserver hosts: "{{ chosen_host | default('armitage') }}" remote_user: "{{ chosen_user | default('senpai') }}" vars_files: - vars/git_aliases.yml # REQUIRED - vars/sox_prox.yml # REQUIRED - vars/flexget_dls.yml # REQUIRED - vars/aria_api.yml # REQUIRED - vars/config@{{ inventory_hostname | default('homeserver') }}.yml tasks: - name: Installing requisite packages ansible.builtin.include_role: name: init-server tasks_from: userspace@install-pkgs handlers_from: userspace - name: Acquiring home of current user when: ansible_facts["system"] == "Linux" ansible.builtin.shell: cmd: "echo ~{{ ansible_user }}" register: ansible_user_home - name: Acquiring current user when: ansible_facts["system"] == "Linux" ansible.builtin.shell: cmd: "echo {{ ansible_user }}" register: current_user - name: Disabling root user shell login become: true ansible.builtin.user: name: root shell: /sbin/nologin tags: - disable_root_shell - name: Disable login for root user altogether become: true ansible.builtin.user: name: root password: "'*'" tags: - disable_root_login - name: Reorganizing userspace package groups into single list ansible.builtin.set_fact: all_userspace_pkgs: "{{ pkgs | dict2items(key_name='pkg_group', value_name='pkgs') | map(attribute='pkgs') | list | map(attribute='userspace') | list | flatten }}" - name: Reorganizing core package groups into single list ansible.builtin.set_fact: all_core_pkgs: "{{ pkgs | dict2items(key_name='pkg_group', value_name='pkgs') | map(attribute='pkgs') | list | map(attribute='core') | list | flatten }}" - name: Configuring aliases for using git when: "'git' in all_core_pkgs" community.general.git_config: name: "alias.{{ item[0] }}" scope: global value: "{{ item[1] }}" loop: "{{ git_aliases }}" - name: Checking presence of dependency for flexget when: "'uv' in all_core_pkgs" block: - name: Installing flexget become: true become_user: "{{ current_user.stdout }}" ansible.builtin.command: argv: - uv - tool - install - "flexget[locked,ftp,sftp]" - "--with" - pysocks - name: Creating requisite download paths ansible.builtin.file: path: "{{ ansible_user_home.stdout }}/downloads/flexget/vids/{{ item }}/torrents" recurse: true owner: "{{ ansible_user }}" group: "{{ ansible_user }}" state: directory mode: "755" loop: - series - name: Creating requisite download paths ansible.builtin.file: path: "{{ ansible_user_home.stdout }}/downloads/flexget/vids/torrents" recurse: true owner: "{{ ansible_user }}" group: "{{ ansible_user }}" state: directory mode: "755" - name: Creating requisite hidden download paths ansible.builtin.file: path: "{{ ansible_user_home.stdout }}/downloads/.xxx/flexget/vids/torrents" recurse: true owner: "{{ ansible_user }}" group: "{{ ansible_user }}" state: directory mode: "755" - name: Creating requisite hidden download paths ansible.builtin.file: path: "{{ ansible_user_home.stdout }}/downloads/media/vids/{{ item }}" recurse: true owner: "{{ ansible_user }}" group: "{{ ansible_user }}" state: directory mode: "755" loop: - series - features - name: Creating requisite hidden file for film torrent links ansible.builtin.file: path: "{{ ansible_user_home.stdout }}/media/vids/{{ item }}.csv" owner: "{{ ansible_user }}" group: "{{ ansible_user }}" state: touch mode: "644" loop: - features/.films - name: Creating requisite hidden download paths ansible.builtin.file: path: "{{ ansible_user_home.stdout }}/downloads/.xxx/media/vids" recurse: true owner: "{{ ansible_user }}" group: "{{ ansible_user }}" state: directory mode: "755" - name: Creating requisite hidden file for NSFW video torrent links ansible.builtin.file: path: "{{ ansible_user_home.stdout }}/.xxx/.{{ item }}.csv" owner: "{{ ansible_user }}" group: "{{ ansible_user }}" state: touch mode: "644" loop: - vids - name: Configuring flexget become: true become_user: "{{ current_user.stdout }}" ansible.builtin.template: src: user/flexget/config.yml.j2 variable_start_string: "<<" variable_end_string: ">>" dest: "{{ ansible_user_home.stdout }}/.flexget/config.yml" owner: "{{ ansible_user }}" group: "{{ ansible_user }}" force: true backup: true - name: Creating a CRON job for flexget ansible.builtin.cron: name: Run flexget minute: "*/60" hour: "4-15" weekday: "1-5" job: "{{ ansible_user_home.stdout }}/.local/bin/flexget --cron execute"