X Tutup
Skip to content
This repository was archived by the owner on Mar 7, 2025. It is now read-only.

Commit 6217bfb

Browse files
committed
Plex: Recreate Preferences.xml file when it is malformed.
- Plex will not replace a corrupted one. Need to remove it first.
1 parent eff176b commit 6217bfb

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

roles/plex/tasks/main.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,19 @@
5858
content: attribute
5959
attribute: PlexOnlineToken
6060
register: preferences_xml_resp
61+
ignore_errors: yes
6162

62-
- name: Set 'claimed_plex_server' variable
63+
- name: "Remove 'Preferences.xml' file when malformed"
64+
file:
65+
path: "/opt/plex/Library/Application Support/Plex Media Server/Preferences.xml"
66+
state: absent
67+
when: (preferences_xml_resp is failed)
68+
69+
- name: Set 'plex_server_claimed' variable
6370
set_fact:
64-
claimed_plex_server: "{{ (preferences_xml_resp.matches[0].Preferences.PlexOnlineToken is defined)
65-
and (preferences_xml_resp.matches[0].Preferences.PlexOnlineToken | trim | length > 0) }}"
71+
plex_server_claimed: "{{ (preferences_xml_resp is succeeded) and
72+
(preferences_xml_resp.matches[0].Preferences.PlexOnlineToken is defined) and
73+
(preferences_xml_resp.matches[0].Preferences.PlexOnlineToken | trim | length > 0) }}"
6674

6775
when:
6876
- (not continuous_integration)
@@ -72,7 +80,7 @@
7280
import_tasks: subtasks/claim_server.yml
7381
when:
7482
- (not continuous_integration)
75-
- (not preferences_xml.stat.exists) or (preferences_xml.stat.exists and not claimed_plex_server)
83+
- (not preferences_xml.stat.exists) or (preferences_xml.stat.exists and not plex_server_claimed)
7684

7785
- name: "Grab lazyman IP address"
7886
set_fact:

0 commit comments

Comments
 (0)
X Tutup