2022-03-17 14:12:56 +00:00
|
|
|
---
|
2024-10-07 17:42:11 +00:00
|
|
|
- name: Check if state is valid
|
|
|
|
ansible.builtin.fail:
|
|
|
|
msg: >-2
|
|
|
|
Unsupported state '{{ jellyfin_state }}'. Supported
|
|
|
|
states are {{ jellyfin_states | join(', ') }}.
|
|
|
|
when: jellyfin_state not in jellyfin_states
|
2022-03-17 14:12:56 +00:00
|
|
|
|
2024-10-07 17:42:11 +00:00
|
|
|
- name: Ensure jellyfin user '{{ jellyfin_user }}' is {{ jellyfin_state }}
|
2024-10-03 20:25:46 +00:00
|
|
|
ansible.builtin.user:
|
2022-03-17 14:12:56 +00:00
|
|
|
name: "{{ jellyfin_user }}"
|
2024-10-07 17:42:11 +00:00
|
|
|
state: "{{ jellyfin_state }}"
|
|
|
|
system: "{{ jellyfin_user_system | default(true, true) }}"
|
2022-03-17 14:12:56 +00:00
|
|
|
register: jellyfin_user_info
|
|
|
|
|
2024-10-07 17:42:11 +00:00
|
|
|
- name: Ensure host directories for jellyfin are {{ jellyfin_state }}
|
|
|
|
ansible.builtin.file:
|
2022-03-17 14:12:56 +00:00
|
|
|
path: "{{ item.path }}"
|
2024-10-07 17:42:11 +00:00
|
|
|
state: >-2
|
|
|
|
{{ (jellyfin_state == 'present') | ternary('directory', 'absent') }}
|
2022-03-17 14:12:56 +00:00
|
|
|
owner: "{{ item.owner | default(jellyfin_uid) }}"
|
|
|
|
group: "{{ item.group | default(jellyfin_gid) }}"
|
|
|
|
mode: "{{ item.mode }}"
|
|
|
|
loop: "{{ jellyfin_host_directories }}"
|
|
|
|
|
2024-10-07 17:42:11 +00:00
|
|
|
- name: Ensure container image '{{ jellyfin_container_image_ref }}' is {{ jellyfin_state }}
|
2024-10-03 20:25:46 +00:00
|
|
|
community.docker.docker_image:
|
2022-03-17 14:12:56 +00:00
|
|
|
name: "{{ jellyfin_container_image_ref }}"
|
2024-10-07 17:42:11 +00:00
|
|
|
state: "{{ jellyfin_state }}"
|
|
|
|
source: "{{ jellyfin_container_image_source }}"
|
2022-07-17 13:59:19 +00:00
|
|
|
force_source: "{{ jellyfin_container_image_tag | default(false, true) }}"
|
|
|
|
register: jellyfin_container_image_pull_result
|
|
|
|
until: jellyfin_container_image_pull_result is succeeded
|
|
|
|
retries: 5
|
|
|
|
delay: 3
|
2022-03-17 14:12:56 +00:00
|
|
|
|
2024-10-07 17:42:11 +00:00
|
|
|
- name: Ensure container '{{ jellyfin_container_name }}' is {{ jellyfin_container_state }}
|
2024-10-03 20:25:46 +00:00
|
|
|
community.docker.docker_container:
|
2022-03-17 14:12:56 +00:00
|
|
|
name: "{{ jellyfin_container_name }}"
|
|
|
|
image: "{{ jellyfin_container_image_ref }}"
|
|
|
|
user: "{{ jellyfin_uid }}:{{ jellyfin_gid }}"
|
2022-07-17 13:59:19 +00:00
|
|
|
labels: "{{ jellyfin_container_labels }}"
|
2022-03-17 14:12:56 +00:00
|
|
|
volumes: "{{ jellyfin_container_volumes }}"
|
|
|
|
networks: "{{ jellyfin_container_networks | default(omit, True) }}"
|
|
|
|
network_mode: "{{ jellyfin_container_network_mode }}"
|
|
|
|
restart_policy: "{{ jellyfin_container_restart_policy }}"
|
2024-10-07 17:42:11 +00:00
|
|
|
state: "{{ jellyfin_container_state }}"
|