aboutsummaryrefslogtreecommitdiff
path: root/ansible/roles/plex/tasks/setup.yaml
blob: de0eb69786baebc933b61738d849c91a51901a35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
---

- name: 'setup | Ensure required vars are set'
  ansible.builtin.assert:
    that:
      - item | mandatory
  loop:
    - '{{ plex_nas_mount_path }}'
  no_log: true

- name: 'setup | Install required pkgs'
  ansible.builtin.package:
    name:
      - 'nfs-common'
      - 'curl'
      - 'gnupg'

- 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: '{{ plex_nas_mount_path }}'
    path: '/mnt/data'
    state: 'mounted'
    fstype: 'nfs'

- name: 'setup | Get the Plex signed keys'
  ansible.builtin.shell:
    # noqa: risky-shell-pipe command-instead-of-module
    cmd: >
      curl -sS https://downloads.plex.tv/plex-keys/PlexSign.key | gpg --dearmor | tee /usr/share/keyrings/plex.gpg > /dev/null
    creates: '/usr/share/keyrings/plex.gpg'

- name: 'setup | Set the Plex sources'
  ansible.builtin.copy:
    dest: '/etc/apt/sources.list.d/plexmediaserver.list'
    content: |
      deb [signed-by=/usr/share/keyrings/plex.gpg] https://downloads.plex.tv/repo/deb public main
    mode: '644'

- name: 'setup | Install the package'
  ansible.builtin.apt:
    name: 'plexmediaserver'
    state: 'present'
    update_cache: true

- name: 'setup | Start the service'
  ansible.builtin.service:
    name: 'plexmediaserver'
    state: 'stopped'
    enabled: true