2019-09-27 05:25:59 +00:00
---
# - hosts: vm-host-plex.net.enp.one
# #gather_facts: false
# tasks:
# - name: Query plex API (shhh) to load latest releases
# get_url:
# url: https://plex.tv/api/downloads/5.json
# dest: "{{ plex_releases_file | default('/tmp/plexreleases.json') }}"
2020-02-12 04:17:43 +00:00
- hosts : plex
2019-09-27 05:25:59 +00:00
name : Update Plex Media Server to latest version
vars :
plex_releases : "{{ lookup('url', 'https://plex.tv/api/downloads/5.json') | from_json }}"
tasks :
- name : Identifiy the proper release file
when : (ansible_os_family | lower == item["distro"]) and (ansible_distribution | lower in item["label"] | lower) and (ansible_userspace_bits in item["label"])
set_fact :
plex_release_url : "{{ item.url }}"
plex_release_checksum : "{{ item.checksum }}"
loop : "{{ plex_releases['computer']['Linux']['releases'] }}"
- name : Download package
get_url :
url : "{{ plex_release_url }}"
checksum : sha1:{{ plex_release_checksum }}
dest : /tmp/plexmediaserver-{{ plex_release_checksum }}.{{ plex_release_url.split(".")[-1] }}
- name : Stop the PMS service
become : true
systemd :
name : "{{ plex_service | default('plexmediaserver') }}"
state : stopped
- name : Install update package
become : true
block :
- name : Install update package using DNF
when : ansible_distribution == "Fedora"
dnf :
name : /tmp/plexmediaserver-{{ plex_release_checksum }}.rpm
state : latest
- name : Install update package using YUM
when : ansible_distribution == "CentOS"
yum :
name : /tmp/plexmediaserver-{{ plex_release_checksum }}.rpm
state : latest
- name : Install update package using APT
when : ansible_distribution == "Ubuntu" or ansible_distribution == "Debian"
apt :
name : /tmp/plexmediaserver-{{ plex_release_checksum }}.deb
state : latest
- name : Start the PMS service
become : true
systemd :
name : "{{ plex_service | default('plexmediaserver') }}"
state : started