From ebe3487e275b3e74e5f631ea5e169e5c34117111 Mon Sep 17 00:00:00 2001 From: Erin Sims Date: Fri, 9 Sep 2022 07:21:47 -0400 Subject: [PATCH] working on changes, and debugging --- playbooks/mpdb.conf.j2 | 72 +++++++++++++++++++++++----------------- playbooks/mpdb.yaml | 75 +++++++++++++++++++++++++++++++++++++----- playbooks/mpdf.conf.j2 | 7 ++-- playbooks/mpdf.yaml | 1 - 4 files changed, 112 insertions(+), 43 deletions(-) diff --git a/playbooks/mpdb.conf.j2 b/playbooks/mpdb.conf.j2 index dc0acb9..c232ace 100644 --- a/playbooks/mpdb.conf.j2 +++ b/playbooks/mpdb.conf.j2 @@ -10,13 +10,24 @@ # be disabled and audio files will only be accepted over ipc socket (using # file:// protocol) or streaming files over an accepted protocol. # +#######need to fix this one too +music_directory "/var/lib/mpd/music/" + +database { + plugin "simple" + path "/var/lib/mpd/mpd.db" + cache_directory "/var/lib/mpd/cache" +} + + +#music_directory # # This setting sets the MPD internal playlist directory. The purpose of this # directory is storage for playlists created by MPD. The server will use # playlist files not created by the server but only if they are in the MPD # format. This setting defaults to playlist saving being disabled. # -playlist_directory {{ playlist_directory }} +playlist_directory "{{ [path,playlist_directory]|join() }}" # # This setting sets the location of the MPD database. This file is used to # load the database at server start up and store the database while the @@ -24,7 +35,8 @@ playlist_directory {{ playlist_directory }} # MPD to accept files over ipc socket (using file:// protocol) or streaming # files over an accepted protocol. # -db_file {{ db_file }} +#db_file "{{ [path,db_file]|join() }}" + # # These settings are the locations for the daemon log files for the daemon. # These logs are great for troubleshooting, depending on your log_level @@ -33,27 +45,27 @@ db_file {{ db_file }} # The special value "syslog" makes MPD use the local syslog daemon. This # setting defaults to logging to syslog, otherwise logging is disabled. # -log_file {{ log_file }} +log_file "{{ [log_dir,'mpd.log']|join() }}" # # This setting sets the location of the file which stores the process ID # for use of mpd --kill and some init scripts. This setting is disabled by # default and the pid file will not be stored. # -pid_file {{ pid_file }} +pid_file "{{ [path,item,'/',pid_file]|join() }}" # # This setting sets the location of the file which contains information about # most variables to get MPD back into the same general shape it was in before # it was brought down. This setting is disabled by default and the server # state will be reset on server start up. # -state_file {{ state_file }} +state_file "{{ [path,item,'/',state_file,]|join() }}" # # The location of the sticker database. This is a database which # manages dynamic information attached to songs. # -sticker_file {{ sticker_file }} -# +sticker_file "{{ [path,item,'/',sticker_file,'.sql']|join() }}" + ############################################################################### @@ -64,7 +76,7 @@ sticker_file {{ sticker_file }} # initialization. This setting is disabled by default and MPD is run as the # current user. # -user {{ user }} +user "{{ user }}" # # This setting specifies the group that MPD will run as. If not specified @@ -73,7 +85,7 @@ user {{ user }} # have permission to use sound card. # #group "nogroup" -group {{ group }} +group "{{ group }}" # # This setting sets the address for the daemon to listen on. Careful attention # should be paid if this is assigned to anything other then the default, any. @@ -81,7 +93,7 @@ group {{ group }} # to have mpd listen on every address # # For network -bind_to_address {{ bind_to_address }} +bind_to_address "{{ bind_to_address }}" # # And for Unix Socket #bind_to_address "/var/run/mpd/socket" @@ -90,7 +102,7 @@ bind_to_address {{ bind_to_address }} # to. # #port "6600" -port {{ port }} +port "{{ mpdport + item }}" # # This setting controls the type of information which is logged. Available @@ -99,7 +111,7 @@ port {{ port }} # available resources on limited hardware storage. # #log_level "default" -log_level {{ log_level }} +log_level "{{ log_level }}" # # If you have a problem with your MP3s ending abruptly it is recommended that @@ -109,35 +121,35 @@ log_level {{ log_level }} # point gapless MP3 playback can be enabled. # #gapless_mp3_playback "yes" -gapless_mp3_playback {{ gapless_mp3_playback }} +gapless_mp3_playback "{{ gapless_mp3_playback }}" # # This setting enables MPD to create playlists in a format usable by other # music players. # #save_absolute_paths_in_playlists "no" -save_absolute_paths_in_playlists {{ save_absolute_paths_in_playlists }} +save_absolute_paths_in_playlists "{{ save_absolute_paths_in_playlists }}" # # This setting defines a list of tag types that will be extracted during the # audio file discovery process. Optionally, 'comment' can be added to this # list. # #metadata_to_use "artist,album,title,track,name,genre,date,composer,performer,disc" -metadata_to_use {{ metadata_to_use }} +metadata_to_use "{{ metadata_to_use }}" # # This setting enables automatic update of MPD's database when files in # music_directory are changed. # #auto_update "yes" -auto_update {{ auto_update }} +auto_update "{{ auto_update }}" # # Limit the depth of the directories being watched, 0 means only watch # the music directory itself. There is no limit by default. # #auto_update_depth "3" -auto_update_depth {{ auto_update_depth }} +auto_update_depth "{{ auto_update_depth }}" # ############################################################################### @@ -149,14 +161,14 @@ auto_update_depth {{ auto_update_depth }} # symbolic links outside of the configured music_directory. # #follow_outside_symlinks "yes" -follow_outside_symlinks {{ follow_outside_symlinks }} +follow_outside_symlinks "{{ follow_outside_symlinks }}" # # If this setting is set to "yes", MPD will discover audio files by following # symbolic links inside of the configured music_directory. # #follow_inside_symlinks "yes" -follow_inside_symlinks {{ follow_inside_symlinks }} +follow_inside_symlinks "{{ follow_inside_symlinks }}" # ############################################################################### @@ -168,13 +180,13 @@ follow_inside_symlinks {{ follow_inside_symlinks }} # Zeroconf / Avahi. # #zeroconf_enabled "yes" -zeroconf_enabled {{ zeroconf_enabled }} +zeroconf_enabled "{{ zeroconf_enabled }}" # # The argument to this setting will be the Zeroconf / Avahi unique name for # this MPD server on the network. # #zeroconf_name "Music Player" -zeroconf_name {{ zeroconf_name }} +zeroconf_name "{{ zeroconf_name }}" # ############################################################################### @@ -190,7 +202,7 @@ password "HelloKitty@read,add,control,admin" # This setting specifies the permissions a user has who has not yet logged in. # #default_permissions "read,add,control,admin" -default_permissions {{ default_permissions }} +default_permissions "{{ default_permissions }}" # ############################################################################### @@ -281,7 +293,7 @@ audio_output { enabled "yes" name "{{ stream }}" encoder "lame" # optional, vorbis or lame - port "{{ port }}" + port "{{ stream_port }}" bind_to_address "{{ bind_address }}" # optional, IPv4 or IPv6 quality "3.0" # do not define if bitrate is defined # bitrate "128" # do not define if quality is defined @@ -295,7 +307,7 @@ audio_output { # name "My Pulse Output" # server "remote_server" # optional # sink "remote_server_sink" # optional -} +#} # ## Example "pipe" output: # @@ -358,7 +370,7 @@ audio_output { # #mixer_type "disabled" # -mixer_type {{ mixer_type }} +mixer_type "{{ mixer_type }}" ############################################################################### @@ -370,20 +382,20 @@ mixer_type {{ mixer_type }} # details. This setting is disabled by default. # #replaygain "album" -replaygain {{ replaygain }} +replaygain "{{ replaygain }}" # # This setting sets the pre-amp used for files that have ReplayGain tags. By # default this setting is disabled. # #replaygain_preamp "0" -replaygain_preamp {{ replaygain_preamp }} +replaygain_preamp "{{ replaygain_preamp }}" # # This setting enables on-the-fly normalization volume adjustment. This will # result in the volume of all playing audio to be adjusted so the output has # equal "loudness". This setting is disabled by default. # #volume_normalization "no" -volume_normalization {{ volume_normalization }} +volume_normalization "{{ volume_normalization }}" # ############################################################################### @@ -395,14 +407,14 @@ volume_normalization {{ volume_normalization }} # are doing. # #audio_buffer_size "2048" -audio_buffer_size {{ audio_buffer_size }} +audio_buffer_size "{{ audio_buffer_size }}" # # This setting controls the percentage of the buffer which is filled before # beginning to play. Increasing this reduces the chance of audio file skipping, # at the cost of increased time prior to audio playback. # #buffer_before_play "10%" -buffer_before_play {{ buffer_before_play }} +buffer_before_play "{{ buffer_before_play }}" # ############################################################################### diff --git a/playbooks/mpdb.yaml b/playbooks/mpdb.yaml index 32f97c4..7029525 100644 --- a/playbooks/mpdb.yaml +++ b/playbooks/mpdb.yaml @@ -1,16 +1,75 @@ - hosts: all gather_facts: true vars: + path: /var/lib/mpd + playlist_directory: /playlist/ + db_file: tag_cache + log_dir: /var/log/ + log_file: mpd.log + pid_file: pid + state_file: state + sticker_file: sticker + user: mpd + group: nogroup + bind_to_address: any + bind_address: any + mpdport: 6600 + log_level: default + gapless_mp3_playback: yes + save_absolute_paths_in_playlists: yes + metadata_to_use: artist,album,title,track,name,genre,date,composer,performer,disc + auto_update: no + auto_update_depth: 3 + follow_outside_symlinks: no + follow_inside_symlinks: no + zeroconf_enabled: no + zeroconf_name: mpd + default_permissions: read,add,control,admin + stream: music + stream_port: 6700 + stream_bind_address: any + mixer_type: disabled + replaygain: album + replaygain_preamp: 0 + volume_normalization: no + audio_buffer_size: 2048 + buffer_before_play: "1%" + tasks: + - name: "mpdf backendhost" + set_fact: + backendhost: "{{ inventory_hostname |replace ('b', 'f') }}" - name: Install mpdb on hosts apt: name: mpd state: present - - name: setup config on hosts - template: - src: mpdf.conf.j2 - dest: /etc/mpd.conf - owner: root - group: root - notify: - - restart mpd + - name: setup config on hosts + template: + src: mpdf.conf.j2 + dest: "/etc/mpdf.conf" + mode: 0644 + owner: root + group: root + - name: mpdf music directory + file: + path: "/var/lib/mpd/music" + state: directory + owner: root + group: root + mode: '0755' + - name: setup service on hosts + template: + src: mpdf.service.j2 + dest: "/usr/lib/systemd/system/mpd.service" + mode: 0644 + owner: root + group: root + - name: mpd service start + systemd: + name: "mpd" + state: started + enabled: yes + masked: no + daemon_reload: yes + + diff --git a/playbooks/mpdf.conf.j2 b/playbooks/mpdf.conf.j2 index 5530553..b3ecf85 100644 --- a/playbooks/mpdf.conf.j2 +++ b/playbooks/mpdf.conf.j2 @@ -13,11 +13,10 @@ #######need to fix this one too music_directory "nfs://example.com/path/to/your/music/" -" + database { - plugin "proxy" - {{ hostvars['mpdf1']['ansible_facts']['distribution'] }} - {# host "{{ hostvars['mpdb1']['ansible_facts']['ansible_eth1']['ipv4']['address'] }}" #} + plugin "proxy" + host "{{ hostvars['mpdb1']['ansible_facts']['ansible_eth1']['ipv4']['address'] }}" # host "142.93.181.29" port "8888" password "password" diff --git a/playbooks/mpdf.yaml b/playbooks/mpdf.yaml index e8cd099..b361387 100644 --- a/playbooks/mpdf.yaml +++ b/playbooks/mpdf.yaml @@ -1,7 +1,6 @@ - hosts: all gather_facts: true vars: - #we need to loop over the /var/lib/mpd{{ count }} directory for the files/folders below. we need to loop over the stream ports as well count: 5 path: /var/lib/mpd playlist_directory: /playlist/