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 428306cdb2
commit 96ca3270fa
6 changed files with 160 additions and 2 deletions

View File

@ -6,9 +6,27 @@ all:
nomad0.thefij: nomad0.thefij:
# consul_node_role: bootstrap # consul_node_role: bootstrap
nomad_node_role: both nomad_node_role: both
nomad_host_volumes: nomad_unique_host_volumes:
- name: mysql-data - 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" owner: "root"
group: "bin" group: "bin"
mode: "0755" mode: "0755"

74
nomad/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
nomad/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 { service {
name = "nextcloud" name = "nextcloud"
port = "web" port = "web"
@ -101,6 +107,12 @@ job "nextcloud" {
task "main" { task "main" {
driver = "docker" driver = "docker"
volume_mount {
volume = "nextcloud-data"
destination = "/var/www/html"
read_only = false
}
config { config {
image = "nextcloud" image = "nextcloud"
ports = ["web"] ports = ["web"]

View File

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

View File

@ -97,11 +97,52 @@
# name: podman # name: podman
# state: present # 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 - name: Build Nomad cluster
hosts: nomad_instances hosts: nomad_instances
any_errors_fatal: true any_errors_fatal: true
become: 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: roles:
- name: ansible-nomad - name: ansible-nomad
vars: vars:
@ -137,6 +178,8 @@
nomad_docker_dmsetup: false nomad_docker_dmsetup: false
# nomad_podman_enable: true # nomad_podman_enable: true
nomad_host_volumes: "{{ shared_host_volumes + (nomad_unique_host_volumes | default([])) }}"
# Customize docker plugin # Customize docker plugin
nomad_plugins: nomad_plugins:
docker: docker: