简体   繁体   中英

Plex using Ansible and Docker

I've been using Plex on my home server for a while and I have bought a few upgrades for my NAS so decided to try to automate a docker setup. I am completely new to Ansible and only quite simple exposure to Docker. Most things seem to have worked except for the actual Plex deployment.

I tried adjusting the become paramter in-case this could help, initially I used it for all commands, but I really wasn't sure what I am doing so I have come here.

The error I am getting is;

Error: Unable to set up server: sqlite3_statement_backend::loadOne: database   is locked
Starting Plex Media Server.
6 3000 /config/Library/Application Support
8192

I have checked the file itself on the NAS drive and has the following properties, where Support is the ssh user;

208 -rwxr-xr-x 1 support root 209920 Apr 30 12:21 com.plexapp.plugins.library.db

And the Playbook I have created is as follows;

---
# Install Docker
- hosts: mediaservers
  remote_user: support
  roles:
    - { role: angstwad.docker_ubuntu, sudo: yes }

# Mount NAS and create folders
- hosts: mediaservers
  remote_user: support
  become: no
  tasks:
    - name: Install required package
      apt: pkg={{item}} state=installed update-cache=yes
      become: yes
      with_items:
        - cifs-utils
    - name: Upload credentials file
      copy: src=env/.smbcredentials dest=/root/ mode=0700
      become: yes
    - name: Create mount directory
      file: state=directory path=/mnt/NAS/universe-01
    - name: mount NAS to fstab
      mount: fstype=cifs name=/mnt/NAS/universe-01 src=//192.168.1.73/universe-01 opts="credentials=/root/.smbcredentials,uid=1000" state=mounted
      become: yes

    # Directories to store media files
    - name: Creates tvshow directory
      file: state=directory path=/mnt/NAS/universe-01/media/tvshows
    - name: Creates movies directory
      file: state=directory path=/mnt/NAS/universe-01/media/movies
    - name: Creates music directory
      file: state=directory path=/mnt/NAS/universe-01/media/music
    - name: Creates photos directory
      file: state=directory path=/mnt/NAS/universe-01/media/photos

    # Directories to store docker data/config
    - name: Creates plex configuration directory
      file: state=directory path=/mnt/NAS/universe-01/data/docker/plex/config

# Deploy docker images
- hosts: mediaservers
  remote_user: support
  become: no
  tasks:
    - name: Create Plex docker image
      become: yes
      docker:
        name: plex
        hostname: plex
        image: linuxserver/plex
        pull: missing
        state: started
        restart_policy: always
        ports:
        - "32400:32400"
        - "32400:32400/udp"
        - "32469:32469"
        - "32469:32469/udp"
        - "5353:5353/udp"
        - "1900:1900/udp"
        volumes: [
          '/mnt/NAS/universe-01/data/docker/plex/config:/config',
          '/mnt/NAS/universe-01/media/tvshows:/data/tvshows',
          '/mnt/NAS/universe-01/media/movies:/data/movies',
          '/mnt/NAS/universe-01/media/music:/data/music',
          '/mnt/NAS/universe-01/media/photos:/data/photos'
        ]
        env:
          VERSION: latest
          PGID: 999
          PUID: 1000

I had similar errors when using Docker on Windows . For me the problem was that I was assigning wrong PUID and PGID to the plex container I was using. Once I assigned the proper id, the server ran without any errors.

Not exactly your problem, but I hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM