marvinpinto.htpc

htpc

Build Status Ansible Galaxy License

This is a tool for Ansible Galaxy that helps set up and manage a sample Home Theatre PC (HTPC) configuration.

The aim of this project is to show how Ansible can link together the necessary components for an HTPC setup, which has often been the most challenging part. Hopefully, this will simplify the process.

Features

  • SABnzbd: A downloader for newsgroups.
  • SickRage: A manager for TV show libraries.
  • CouchPotato: A PVR and manager for movie libraries.
  • Plex: A media server for movies, TV shows, music, and more.
  • nginx: A frontend proxy using Google authentication (via OAuth2 Proxy).
  • Designed to work together on an Ubuntu 14.04 server.

Pre-Requirements

  1. You need a domain to host this setup. The example used is htpc-sample.example.org. Change the htpc_dns_hostname variable to your domain.

  2. The default setup uses Google authentication, so you must register an OAuth Web Application (find instructions here). Keep the Client ID and Client Secret, and set them as htpc_oauth_client_id and htpc_oauth_client_secret.

    You can also use other authentication providers; just update the oauth2_proxy_cli_args variable accordingly.

  3. Generate a random 32-byte string with:

    $ date +%s | sha256sum | base64 | head -c 32 ; echo
    

    Use this value as your htpc_oauth_cookie_secret.

  4. Get an HTTPS TLS certificate for your domain (htpc_dns_hostname). Update the htpc_tls_cert and htpc_tls_cert_key variables with your certificate and private key.

Role Variables

The HTPC-specific variables can be found in defaults/main.yml, while role-specific meta variables are in meta/main.yml.

Example

To install this module from Ansible Galaxy into the './roles' directory, run:

ansible-galaxy install marvinpinto.htpc -p ./roles

You can use it in a playbook like this:

- hosts: '127.0.0.1'
  become: true
  roles:
    - role: 'marvinpinto.htpc'
      htpc_dns_hostname: 'htpc-sample.example.org'
      htpc_oauth_client_id: 'your-client-id'
      htpc_oauth_client_secret: 'your-client-secret'
      htpc_oauth_cookie_secret: 'N2U2NTI0NzljNjc2Y2VmNGVlZDZmMDg5'
      htpc_authorized_users_emails: |
        [email protected]
        [email protected]
      htpc_tls_cert: |
        -----BEGIN CERTIFICATE-----
        ...
        -----END CERTIFICATE-----
      htpc_tls_cert_key: |
        -----BEGIN RSA PRIVATE KEY-----
        ...
        -----END RSA PRIVATE KEY-----

Post-setup Configuration

SABnzbd

  1. Open your browser and go to /sabnzbd to start the setup wizard.

  2. In /sabnzbd/config/general/, you may want to Disable API-key since it’s behind OAuth2 Proxy.

  3. In /sabnzbd/config/folders/, set up:

  • Temporary Download Folder: /opt/downloads/sabnzbd-incomplete
  • Completed Download Folder: /opt/downloads/misc
  • Permissions for completed downloads: 777
  • Scripts folder: /opt/nzbtomedia
  1. In /sabnzbd/config/categories/, for processing:
  • Movies:

    • Category: movies
    • Script: nzbToCouchPotato.py
    • Folder/Path: /opt/downloads/unprocessed/movies
  • TV:

    • Category: tv
    • Script: nzbToSickBeard.py
    • Folder/Path: /opt/downloads/tv
  • Audio:

    • Category: audio
    • Script: nzbToHeadPhones.py
    • Folder/Path: /opt/downloads/unprocessed/audio
  1. In /sabnzbd/config/switches/, set:
  • Action when encrypted RAR is downloaded: abort
  • Action when unwanted extension detected: abort
  • Unwanted extensions: exe, com
  • Post-Process Only Verified Jobs: off
  • Ignore Samples: on
  • Cleanup List: nfo, sfv
  1. In /sabnzbd/config/special/, set empty_postproc to on.

SickRage

  1. Stop the SickRage service:
$ service sickrage stop
  1. Update settings to allow nginx to proxy requests:
$ sed -i 's/^web_root = ""/web_root = \/sickrage/g' /opt/config/sickrage-config/config.ini
$ sed -i 's/^handle_reverse_proxy = 0/handle_reverse_proxy = 1/g' /opt/config/sickrage-config/config.ini
  1. Change other settings:
$ sed -i 's/^use_failed_downloads = 0/use_failed_downloads = 1/g' /opt/config/sickrage-config/config.ini
$ sed -i 's/^log_nr = 5/log_nr = 1/g' /opt/config/sickrage-config/config.ini
$ sed -i 's/^auto_update =.*/auto_update = 0/g' /opt/config/sickrage-config/config.ini
$ sed -i 's/^version_notify =.*/version_notify = 0/g' /opt/config/sickrage-config/config.ini
$ sed -i 's/^naming_pattern =.*/naming_pattern = %S.N.S%0SE%0E.%E.N/g' /opt/config/sickrage-config/config.ini
$ sed -i 's/^web_host =.*/web_host = 127.0.0.1/g' /opt/config/sickrage-config/config.ini
  1. Start the SickRage service:
$ service sickrage start

CouchPotato

  1. Stop the CouchPotato service:
$ service couchpotato stop
  1. Update settings for nginx proxy:
$ sed -i 's/^url_base =.*/url_base = \/couchpotato/g' /opt/config/couchpotato-config/settings.conf
$ sed -i 's/^show_wizard =.*/show_wizard = 0/g' /opt/config/couchpotato-config/settings.conf
  1. Add this line to the [core] section in /opt/config/couchpotato-config/settings.conf:
host = 127.0.0.1
  1. Start the CouchPotato service:
$ service couchpotato start
  1. Go to /couchpotato/settings/general in your browser to disable periodic update checking.

  2. In /couchpotato/settings/renamer, enable movie renaming and make sure the folder paths are correct.

  3. Take note of your API Key and update htpc_couchpotato_api_key with this value.

  4. In /couchpotato/settings/downloaders, enable SABnzbd and set the host.

Plex Media Server

For the initial setup, create an SSH tunnel to your server as follows:

ssh ip.address.of.server -L 8888:localhost:32400

Then, access Plex at http://localhost:8888/web to complete the setup.

For a Vagrant environment, the SSH command will look like this:

ssh \
  -p <Port> \
  -i <IdentityFile> \
  -L 8888:localhost:32400 \
  <User>@<HostName>

Headphones

  1. Stop the Headphones service:
$ service headphones stop
  1. Configure nginx to proxy requests:
sed -i 's/^http_root =.*/http_root = \/headphones/g' /opt/config/headphones-config/config.ini
sed -i 's/^http_host =.*/http_host = 127.0.0.1/g' /opt/config/headphones-config/config.ini
  1. Adjust the configuration settings as mentioned.

  2. Finally, start the Headphones service:

$ service headphones start

Development

Use the provided Vagrantfile for local development and testing:

$ vagrant up --provision
Informazioni sul progetto

This is an Ansible Galaxy meta-role of sorts to install and manage a sample Home Theatre PC (HTPC) setup.

Installa
ansible-galaxy install marvinpinto.htpc
Licenza
mit
Download
69
Proprietario
Computer nerd.