Scriptable way to create users/media libraries? (for ansible deployment)


I’m using configuration management to deploy jellyfin (you can find the ansible role here xsrv/roles/jellyfin at master · nodiscc/xsrv · GitHub)

I could not find a way to create the initial/admin user and add a basic media library (which are required to start using jellyfin) using command line tools or ansible modules. The user has to manually access the jellyfin instance in a web browser and fill in first user credentials, and create a first media library. What I want to achieve is, on first run:

  • the user is able to login using credentials passed from the script/ansible variables.
  • a basic media library is created (for example a “Mixed content” library at /var/lib/jellyfin/media

These settings seem to be stored in /var/lib/jellyfin/data/jellyfin.db but I could not find a way to open the db file either.

srvadmin@demo1:~$ sqlite /var/lib/jellyfin/data/jellyfin.db
Unable to open database "/var/lib/jellyfin/data/jellyfin.db": file is encrypted or is not a database

So I would like to know if:

  • there is a way to create the required items through a scripted DB query?
  • ideally, it would be possible to create the required items from a command-line tool (see for example command line tools provided by Gitea). Eg. jellyfin create-user --username jellyfinadmin --password hunter2; jellyfin create-library --type mixed --path /var/lib/jellyfin/media

Thanks! I started using Jellyfin a few days ago, so far it is great!

To use the role to install a jellyfin server instance (replace my.CHANGEME .org with your jellyfin server hostname and media.CHANGEME .org with the jellyfin webserver FQDN):

# nano inventory.yml
    my.CHANGEME .org

# nano playbook.yml
- hosts: my.CHANGEME .org
    - nodiscc.xsrv.jellyfin

# mkdir host_vars/my.CHANGEME .org
# nano host_vars/my.CHANGEME .org/my.CHANGEME .org.yml
jellyfin_fqdn: media.CHANGEME .org
$ ssh-copy-id myremoteuser@my.CHANGEME .org
$ pip3 install ansible==2.10.5
$ ansible-galaxy collection install git+https ://,master
$ ansible-playbook playbook.yml -u myremoteuser -i inventory.yml
 # open https :// in a web browser