Просмотр исходного кода

[mopidy] Update role and add snapcast role

Colin Powell 3 лет назад
Родитель
Сommit
8643d39c10

+ 7 - 0
ansible/roles/mopidy/files/immortal.yml

@@ -0,0 +1,7 @@
+cmd: /usr/local/bin/mopidy --config /usr/local/etc/mopidy.conf
+log:
+  file: /var/log/mopidy.log
+  age: 86400 # log 1 day
+  num: 7 # keep 7 files
+  size: 1 # size of file 1MB
+wait: 1

+ 43 - 23
ansible/roles/mopidy/tasks/main.yml

@@ -1,46 +1,66 @@
 ---
-- name: Early dependencies installed
-  apt:
-    name: gnupg2,python3-pip
+- name: Dependencies installed
+  community.general.pkgng:
+    name: py38-pip py38-sqlite3 py38-gstreamer1 avahi-daemon
     state: latest
 
-- name: Mopidy apt gpg key installed
-  shell: "wget -q -O - https://apt.mopidy.com/mopidy.gpg | sudo apt-key add -"
-
-- name: Mopidy apt repo added
-  shell: "wget -q -O /etc/apt/sources.list.d/mopidy.list https://apt.mopidy.com/buster.list"
-
-- name: Package cache updated
-  shell: apt update
-
 - name: Dependencies installed
   apt:
     name: mopidy,mopidy-spotify,mopidy-soundcloud,mopidy-mpd,mopidy-podcast,mopidy-tunein,mopidy-local
     state: latest
 
-- name: Playlist folder exists
+- name: mDNS disabled
+  shell: sysrc mdns_enable="NO"
+
+- name: mDNS stopped
+  service:
+    name: mdns
+    state: stopped
+
+- name: Avahi enabled
+  shell: sysrc avahi_daemon_enable="YES"
+
+- name: Avahi started
+  service:
+    name: avahi-daemon
+    state: started
+
+- name: Media folder exists
   file:
-    path: /var/lib/mopidy/playlists
+    path: /var/lib/mopidy/media
     owner: mopidy
-    group: audio
-    mode: 0755
+    mode: 0775
     state: directory
 
-- name: Media folder exists
+- name: Music folder exists
   file:
-    path: /var/lib/mopidy/media
+    path: /var/lib/mopidy/media/music
     owner: mopidy
-    group: audio
-    mode: 0755
+    mode: 0775
+    state: directory
+
+- name: Music folder exists
+  file:
+    path: /var/lib/mopidy/media/podcasts
+    owner: mopidy
+    mode: 0775
     state: directory
 
 - name: Mopidy dependencies up-to-date
-  shell: "pip3 install mopidy-iris mopidy-muse mopidy-musicbox-webclient mopidy-mowecl mopidy-mobile mopidy-party"
+  shell: "pip3 install mopidy-iris mopidy-muse mopidy-musicbox-webclient mopidy-mowecl mopidy-mobile mopidy-party mopidy-tidal mopidy-mpd mopidy-tunein mopidy-jellyfin mopidy-bookmarks mopidy-local"
 
 - name: Mopidy settings installed
   template:
     src: mopidy.conf.j2
-    dest: /etc/mopidy/mopidy.conf
+    dest: /usr/local/etc/mopidy/mopidy.conf
     owner: root
     mode: 0664
-  notify: Mopidy restarted
+  notify: Immortal restarted
+
+- name: Mopidy immortal file installed
+  copy:
+    src: immortal.yml
+    dest: /usr/local/etc/immortal/mopidy.yml
+    owner: root
+    mode: 0600
+  notify: Immortal restarted

+ 7 - 0
ansible/roles/snapcast/files/immortal.yml

@@ -0,0 +1,7 @@
+cmd: /usr/local/bin/snapserver -c /usr/local/etc/snapserver.conf
+log:
+  file: /var/log/snapserver.log
+  age: 86400 # log 1 day
+  num: 7 # keep 7 files
+  size: 1 # size of file 1MB
+wait: 1

+ 13 - 0
ansible/roles/snapcast/tasks/main.yml

@@ -0,0 +1,13 @@
+---
+- name: Dependencies installed
+  community.general.pkgng:
+    name: "snapcast py38-gstreamer1 gstreamer1-plugins-lame gstreamer1-plugins-good gstreamer1-plugins-bad gstreamer1-plugins-mpg123 gstreamer1-plugins-mpg123 gstreamer1-plugins-shout2 gstreamer1-plugins-flac gstreamer1-plugins-inspect gstreamer1-plugins-soup"
+    state: latest
+
+- name: Snapserver immortal file installed
+  copy:
+    src: immortal.yml
+    dest: /usr/local/etc/immortal/snapserver.yml
+    owner: root
+    mode: 0600
+  notify: Immortal restarted

+ 7 - 0
ansible/roles/snapcast/templates/immortal.yml.j2

@@ -0,0 +1,7 @@
+cmd: /usr/local/bin/snapserver -c /usr/local/etc/snapserver.conf
+log:
+    file: /var/log/snapserver.log
+    age: 86400 # log 1 day
+    num: 7     # keep 7 files
+    size: 1    # size of file 1MB
+wait: 1