No description
Find a file
Kristopher Newman efae27f7e7
Merge PR #2: make NFS optional and align docs
Includes NFS optional behavior plus README defaults alignment.
2026-02-11 02:06:02 -05:00
defaults chore: make nfs optional 2026-01-25 23:34:36 +00:00
handlers Initial Commit 2025-02-09 09:54:06 -05:00
meta Updates 2025-02-22 18:08:14 -05:00
tasks Merge PR #2: make NFS optional and align docs 2026-02-11 02:06:02 -05:00
vars Updated 2025-02-09 10:20:09 -05:00
.ansible-lint Initial Commit 2025-02-09 09:54:06 -05:00
.gitignore Reverted path change 2025-02-09 10:19:52 -05:00
LICENSE Initial commit 2025-02-08 21:32:03 -05:00
README.md docs: align NFS defaults with optional configuration 2026-02-11 02:04:48 -05:00

Ansible Role: Plex Media Server

Ansible License Ansible Role

An Ansible role that installs and configures Plex Media Server on Debian or Ubuntu servers. This role also mounts an NFS share to a specified directory, allowing Plex to access media files stored on a network file system.

Table of Contents

Requirements

  • Ansible 2.9 or higher
  • Supported Platforms:
    • Debian 10 (Buster)
    • Debian 11 (Bullseye)
    • Ubuntu 20.04 LTS (Focal)
    • Ubuntu 22.04 LTS (Jammy)
  • The target machine should have internet access to download packages and repositories.
  • Optional: An NFS server accessible from the target machine if you plan to mount a network share.

Role Variables

All variables are defined in defaults/main.yml and are prefixed with plex_server_ to avoid conflicts. Sensitive variables can be overridden in vars/secrets.yml, which is automatically ignored by Git.

Plex Media Server Variables

Variable Default Value Description
plex_server_plex_version public Plex version to install. Options are public or plexpass.
plex_server_plex_user plex The system user under which Plex runs.
plex_server_plex_group plex The system group under which Plex runs.
plex_server_plex_claim_token "" Claim token to automate server registration with your Plex account. Leave empty if not using.

NFS Variables

Variable Default Value Description
plex_server_nfs_server "" Fully qualified domain name (FQDN) of the NFS server. Leave empty to skip NFS setup.
plex_server_nfs_export "" The exported path on the NFS server to mount. Leave empty to skip NFS setup.
plex_server_nfs_mount_point "" The directory where the NFS share will be mounted. Leave empty to skip NFS setup.

Firewall Variables

Variable Default Value Description
plex_server_firewall_enabled false Set to true to configure UFW firewall rules for Plex.

Testing Variable

This variable is useful when testing the role in environments where certain tasks should be skipped, such as when using Molecule for automated testing.

Variable Default Value Description
plex_server_testing false Set to true to skip tasks that cannot run in a testing environment.

Handling Sensitive Variables

To securely manage sensitive variables, you can use vars/secrets.yml to override defaults without exposing them in version control. A file named defaults.secrets.yml can be renamed to secrets.yml to ease the process. Ensure that secrets.yml is added to .gitignore:

# .gitignore

# Ignore secret variable files
vars/secrets.yml

Alternatively, encrypt the secrets file using Ansible Vault:

ansible-vault encrypt vars/secrets.yml

Update your playbook and role to handle encrypted variables appropriately, and provide the vault password when running Ansible commands.

Customizing the Role

  • NFS Mount Options: You can customize NFS mount options by adding a variable plex_server_nfs_mount_opts if needed.
  • Firewall Configuration: The role currently supports UFW. If you're using a different firewall, you can extend the role to include appropriate rules.
  • Plex Plugins and Customization: You can enhance the role to include the installation of Plex plugins or custom configurations by adding tasks and templates.

Testing the Role

It's recommended to test the role using Ansible Molecule to ensure reliability and correctness across different environments. You can include tests and configurations within the role repository to facilitate continuous integration and testing.

Dependencies

None.

Example Playbook

---
- name: Install and configure Plex Media Server
  hosts: plex_servers
  become: yes
  vars:
    plex_server_plex_version: "public"
    plex_server_nfs_server: "nfs.yourdomain.com"
    plex_server_nfs_export: "/exported/path"
    plex_server_nfs_mount_point: "/media"
    plex_server_plex_user: "plex"
    plex_server_plex_group: "plex"
    plex_server_firewall_enabled: true
    plex_server_plex_claim_token: "{{ vault_plex_claim_token }}"
  roles:
    - role: plex_server
## Inventory File (hosts):

[plex_servers]
server1.yourdomain.com
server2.yourdomain.com

Note: Replace placeholder values with actual server names and desired configurations. For sensitive variables like plex_server_plex_claim_token, consider using Ansible Vault to encrypt them securely.

License

This project is licensed under the MIT License.

Author Information

Created by Kristopher Newman
GitHub Repository: ansible-role-plex-server
Ansible Galaxy: khaosx.plex-server

Contributing

Contributions are welcome! If you have improvements or feature requests, please open an issue or submit a pull request on GitHub.

  1. Fork the repository on GitHub.
  2. Create a new branch for your feature or bugfix.
  3. Write your code and tests.
  4. Submit a pull request with a clear description of your changes.

Issues

For any issues, questions, or suggestions, please open an issue on GitHub.