Create Jellyfin job (#6)

Closes #5

Reviewed-on: #6
This commit is contained in:
Ben Martin 2024-06-15 00:22:02 +01:00
parent cf3b9f4518
commit 70aff7bed1
4 changed files with 87 additions and 0 deletions

View file

@ -15,6 +15,7 @@ env:
TF_PLUGIN_CACHE_DIR: ${{ gitea.workspace }}/.terraform.d/plugin-cache TF_PLUGIN_CACHE_DIR: ${{ gitea.workspace }}/.terraform.d/plugin-cache
TF_IN_AUTOMATION: true TF_IN_AUTOMATION: true
TF_CLI_ARGS: "-no-color" TF_CLI_ARGS: "-no-color"
NOMAD_ADDR: "${{ vars.NOMAD_ADDR }}"
NOMAD_TOKEN: "${{ secrets.NOMAD_TOKEN }}" NOMAD_TOKEN: "${{ secrets.NOMAD_TOKEN }}"
PG_CONN_STR: "${{ secrets.PG_CONN_STR }}" PG_CONN_STR: "${{ secrets.PG_CONN_STR }}"
@ -44,6 +45,11 @@ jobs:
id: plan id: plan
run: terraform plan -out=tfplan run: terraform plan -out=tfplan
continue-on-error: true continue-on-error: true
- uses: hashicorp/setup-nomad@main
- name: Install jq
run: sudo apt-get update && sudo apt-get install -y jq
- name: Nomad Validate
run: terraform show -json tfplan | jq -r '.planned_values.root_module.child_modules[].resources[].values.jobspec' | nomad job validate -json -
- uses: actions/github-script@v7 - uses: actions/github-script@v7
if: github.event_name == 'pull_request' if: github.event_name == 'pull_request'
env: env:

View file

@ -5,3 +5,7 @@ terraform {
module "dummy" { module "dummy" {
source = "./modules/dummy" source = "./modules/dummy"
} }
module "media-centre" {
source = "./modules/media-centre"
}

View file

@ -0,0 +1,73 @@
{
"ID": "media-centre",
"Name": "Media Centre",
"TaskGroups": [
{
"Name": "Media Servers",
"Tasks": [
{
"Name": "Jellyfin",
"Type": "docker",
"Config": {
"image": "lscr.io/linuxserver/jellyfin:latest",
"ports": [
"jellyfin"
],
"mounts": [
{
"type": "volume",
"target": "/media",
"VolumeOptions": {
"driver": "local",
"driver_opts": {
"type": "nfs",
"o": "addr=martinibar.lan,nolock,soft,rw",
"device": ":/volume1/docker"
}
}
},
{
"type": "volume",
"target": "/config",
"source": "jellyfin-config"
}
]
},
"Env": {
"TZ": "Europe/London",
"PUID": "985",
"PGID": "997",
"JELLYFIN_PublishedServerUrl": "192.168.1.5"
},
"Resources": {
"CPU": 3100,
"MemoryMB": 8129
}
}
],
"Services": [
{
"Name": "Jellyfin",
"Provider": "nomad",
"PortLabel": "jellyfin",
"Tags": [
"traefik.enable=true",
"traefik.http.routers.jellyfin.entrypoints=websecure",
"traefik.http.routers.jellyfin.rule=Host(`jellyfin.brmartin.co.uk`)"
]
}
],
"Networks": [
{
"DynamicPorts": [
{
"Label": "jellyfin",
"To": 8096
}
]
}
]
}
]
}

View file

@ -0,0 +1,4 @@
resource "nomad_job" "media-centre" {
jobspec = file("${path.module}/jobspec.json")
json = true
}