Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Admin9705 committed Aug 17, 2019
1 parent c6e7350 commit 7e96eb5
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 76 deletions.
76 changes: 4 additions & 72 deletions programs/plex/app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,9 @@
register: claim
when: servertype.stdout == "remote"

- name: Register Extension Type - Local
shell: 'cat /pg/var/image.select'
register: imageselectlocal

- name: Register Extension Type - Remote
shell: 'cat /pg/var/image.select'
register: imageselectremote

- name: 'Plex Image Names'
set_fact:
imageremote: 'plex'
imageremote: 'plex'
register: imageselect

# CORE (MANDATORY) ############################################################
- name: 'Mandatory Core Role'
Expand All @@ -81,68 +72,9 @@
- '/etc/localtime:/etc/localtime:ro'
- '/pg/unity:/unionfs'

- name: Check Preferences.xml exists
stat:
path: '/pg/data/plex/database/Library/Application Support/Plex Media Server/Preferences.xml'
register: plex_prefs

############### This is needed because on a fresh installaions the value is missing and is defaulted to 1 Security perfered
- name: Add secureConnections if missing
xml:
path: '/pg/data/plex/database/Library/Application Support/Plex Media Server/Preferences.xml'
xpath: /Preferences
attribute: secureConnections
value: '1'
when:
- plex_prefs.stat.exists
- secure_hits.count == 0

- name: Read Preferences.xml
xml:
path: '/pg/data/plex/database/Library/Application Support/Plex Media Server/Preferences.xml'
xpath: /Preferences
content: attribute
register: plex_pref_content
when: plex_prefs.stat.exists

- name: Add https to default_label if secureConnection != 2
set_fact:
default_labels: "{{default_labels | combine( {'traefik.protocol': 'https'} )}}"
when:
- plex_prefs.stat.exists
- plex_pref_content.matches[0]['Preferences']['secureConnections']

- name: Read customConnections
set_fact:
customConnections: "{{plex_pref_content.matches[0]['Preferences']['customConnections']}}"
when:
- plex_prefs.stat.exists
- plex_pref_content.matches[0]['Preferences']['customConnections'] is defined

- name: customConnections missing
set_fact:
customConnections: 'http://{{ipaddress.stdout}}:32400, http://plex.{{domain}}:32400'
when:
- plex_prefs.stat.exists == False

- name: 'Get Plex Custom URL'
shell: 'echo https://plex.{{domain}}:443,http://plex.{{domain}}:80'
register: plex_url
when: servertype.stdout == "remote"

- debug: msg="Your plex_url is {{ plex_url.stdout }}"
when: servertype.stdout == "remote"

- set_fact:
plex_advert_ip: 'http://{{ipaddress.stdout}}:32400'
when: servertype.stdout == "remote"

- set_fact:
plex_advert_ip: '{{plex_url.stdout}}'
when: servertype.stdout == "remote"

- debug: msg="plex_advert_ip is {{plex_advert_ip}}"
when: servertype.stdout == "remote"
########################################## Secure Connections
- name: 'Secure Connections'
include_tasks: '/pg/apps/programs/plex/secure.yml'

########################################## Other
- name: Check /dev/dri exists
Expand Down
4 changes: 2 additions & 2 deletions programs/plex/local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# FACTS #######################################################################
- name: 'Deploying {{pgrole}}'
docker_container:
name: '{{imagelocal}}'
image: '{{imageselectlocal.stdout}}'
name: '{{pgrole}}'
image: '{{imageselect.stdout}}'
pull: yes
published_ports:
- '{{ext1}}:{{int1}}'
Expand Down
4 changes: 2 additions & 2 deletions programs/plex/remote.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# FACTS #######################################################################
- name: 'Deploying {{pgrole}}'
docker_container:
name: '{{imagelocal}}'
image: '{{imageselectlocal.stdout}}'
name: '{{pgrole}}'
image: '{{imageselect.stdout}}'
pull: yes
published_ports:
- '{{ext1}}:{{int1}}'
Expand Down
83 changes: 83 additions & 0 deletions programs/plex/secure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/bin/bash
#
# Title: PGBlitz (Reference Title File)
# Author(s): Admin9705
# URL: https://pgblitz.com - http://github.pgblitz.com
# GNU: General Public License v3.0
################################################################################
---
- hosts: localhost
gather_facts: false
tasks:
- name: Check Preferences.xml exists
stat:
path: '/pg/data/plex/database/Library/Application Support/Plex Media Server/Preferences.xml'
register: plex_prefs

############### This is needed because on a fresh installaions the value is missing and is defaulted to 1 Security perfered
- name: secureConnections is missing
xml:
path: '/opt/appdata/plex/database/Library/Application Support/Plex Media Server/Preferences.xml'
xpath: /Preferences/@secureConnections
count: yes
register: secure_hits
when:
- plex_prefs.stat.exists

############### This is needed because on a fresh installaions the value is missing and is defaulted to 1 Security perfered
- name: Add secureConnections if missing
xml:
path: '/pg/data/plex/database/Library/Application Support/Plex Media Server/Preferences.xml'
xpath: /Preferences
attribute: secureConnections
value: '1'
when:
- plex_prefs.stat.exists
- secure_hits.count == 0

- name: Read Preferences.xml
xml:
path: '/pg/data/plex/database/Library/Application Support/Plex Media Server/Preferences.xml'
xpath: /Preferences
content: attribute
register: plex_pref_content
when: plex_prefs.stat.exists

- name: Add https to default_label if secureConnection != 2
set_fact:
default_labels: "{{default_labels | combine( {'traefik.protocol': 'https'} )}}"
when:
- plex_prefs.stat.exists
- plex_pref_content.matches[0]['Preferences']['secureConnections']

- name: Read customConnections
set_fact:
customConnections: "{{plex_pref_content.matches[0]['Preferences']['customConnections']}}"
when:
- plex_prefs.stat.exists
- plex_pref_content.matches[0]['Preferences']['customConnections'] is defined

- name: customConnections missing
set_fact:
customConnections: 'http://{{ipaddress.stdout}}:32400, http://plex.{{domain}}:32400'
when:
- plex_prefs.stat.exists == False

- name: 'Get Plex Custom URL'
shell: 'echo https://plex.{{domain}}:443,http://plex.{{domain}}:80'
register: plex_url
when: servertype.stdout == "remote"

- debug: msg="Your plex_url is {{ plex_url.stdout }}"
when: servertype.stdout == "remote"

- set_fact:
plex_advert_ip: 'http://{{ipaddress.stdout}}:32400'
when: servertype.stdout == "remote"

- set_fact:
plex_advert_ip: '{{plex_url.stdout}}'
when: servertype.stdout == "remote"

- debug: msg="plex_advert_ip is {{plex_advert_ip}}"
when: servertype.stdout == "remote"

0 comments on commit 7e96eb5

Please sign in to comment.