Create a lot more host volumes

Some are NFS volumes and present on all devices
This commit is contained in:
IamTheFij 2022-04-04 22:20:19 -07:00
parent 18635aad2d
commit a1217250dc
6 changed files with 160 additions and 2 deletions

View File

@ -6,9 +6,27 @@ all:
nomad0.thefij:
# consul_node_role: bootstrap
nomad_node_role: both
nomad_host_volumes:
nomad_unique_host_volumes:
- name: mysql-data
path: /srv/volumes/mysql-data
path: /srv/volumes/mysql
owner: "root"
group: "bin"
mode: "0755"
read_only: false
- name: nextcloud-data
path: /srv/volumes/nextcloud
owner: "root"
group: "bin"
mode: "0755"
read_only: false
- name: gitea-data
path: /srv/volumes/gitea
owner: "root"
group: "bin"
mode: "0755"
read_only: false
- name: authentik-data
path: /srv/volumes/gitea
owner: "root"
group: "bin"
mode: "0755"

74
media/caddy.nomad Normal file
View File

@ -0,0 +1,74 @@
job "multimedia" {
datacenters = ["dc1"]
type = "service"
group "multimedia" {
count = 1
network {
mode = "bridge"
port "web" {
host_network = "loopback"
to = 80
}
}
volume "media-read" {
type = "host"
read_only = true
source = "media-read"
}
service {
name = "library"
port = "web"
connect {
sidecar_service {
proxy {
local_service_port = 80
}
}
sidecar_task {
resources {
cpu = 50
memory = 50
}
}
}
tags = [
"traefik.enable=true",
"traefik.http.routers.library.entryPoints=websecure",
]
}
task "main" {
driver = "docker"
volume_mount {
volume = "media-read"
destination = "/mnt/media"
read_only = true
}
config {
image = "caddy"
args = [
"caddy",
"file-server",
"--root",
"/mnt/media",
"--browse",
]
ports = ["web"]
}
resources {
cpu = 50
memory = 250
}
}
}
}

7
media/media.tf Normal file
View File

@ -0,0 +1,7 @@
resource "nomad_job" "caddy" {
hcl2 {
enabled = true
}
jobspec = file("${path.module}/caddy.nomad")
}

View File

@ -28,6 +28,12 @@ job "nextcloud" {
}
}
volume "nextcloud-data" {
type = "host"
read_only = false
source = "nextcloud-data"
}
service {
name = "nextcloud"
port = "web"
@ -100,6 +106,12 @@ job "nextcloud" {
task "main" {
driver = "docker"
volume_mount {
volume = "nextcloud-data"
destination = "/var/www/html"
read_only = false
}
config {
image = "nextcloud"

View File

@ -32,6 +32,10 @@ module "nextcloud" {
depends_on = [module.mysql-server]
}
module "media" {
source = "./media"
}
resource "nomad_job" "whoami" {
hcl2 {
enabled = true

View File

@ -97,11 +97,52 @@
# name: podman
# state: present
- name: Create NFS mounts
hosts: nomad_instances
become: true
tasks:
- name: Install nfs
package:
name: nfs-common
state: present
- name: Create Motioneye NFS mount
ansible.posix.mount:
src: 192.168.2.10:/Recordings/Motioneye
path: /srv/volumes/motioneye-recordings
opts: proto=tcp,port=2049,rw
state: mounted
fstype: nfs4
- name: Create Media Library RO NFS mount
ansible.posix.mount:
src: 192.168.2.10:/Multimedia
path: /srv/volumes/media-read
opts: proto=tcp,port=2049,ro
state: mounted
fstype: nfs4
- name: Build Nomad cluster
hosts: nomad_instances
any_errors_fatal: true
become: true
vars:
shared_host_volumes:
- name: motioneye-recordings
path: /srv/volumes/motioneye-recordings
owner: "root"
group: "bin"
mode: "0755"
read_only: false
- name: media-read
path: /srv/volumes/media-read
owner: "root"
group: "root"
mode: "0777"
read_only: true
roles:
- name: ansible-nomad
vars:
@ -137,6 +178,8 @@
nomad_docker_dmsetup: false
# nomad_podman_enable: true
nomad_host_volumes: "{{ shared_host_volumes + (nomad_unique_host_volumes | default([])) }}"
# Customize docker plugin
nomad_plugins:
docker: