Start using roles

This commit is contained in:
Javier Feliz 2025-03-20 21:01:59 -04:00
parent 54fa8e9a03
commit 24a3b5fdec
10 changed files with 97 additions and 5 deletions

View File

@ -1,2 +1,3 @@
[defaults]
inventory = hosts.yml
roles_path = ./roles

View File

@ -21,14 +21,14 @@ services:
volumes:
- /etc/localtime:/etc/localtime:ro
## Keep configs, scrapers, and plugins here.
- ${STASH_DOCKER_FOLDER}/config:/root/.stash
- /home/docker/stash/config:/root/.stash
## Point this at your collection.
- /home/docker/xrandr:/data
## This is where your stash's metadata lives
- ${STASH_DOCKER_FOLDER}/metadata:/metadata
- /home/docker/stash/metadata:/metadata
## Any other cache content
- ${STASH_DOCKER_FOLDER}/cache:/cache
- /home/docker/stash/cache:/cache
## Where to store binary blob data (scene covers, images)
- ${STASH_DOCKER_FOLDER}/blobs:/blobs
- /home/docker/stash/blobs:/blobs
## Where to store generated content (screenshots,previews,transcodes,sprites)
- ${STASH_DOCKER_FOLDER}/generated:/generated
- /home/docker/stash/generated:/generated

View File

@ -1 +1,8 @@
ansible_become_pass: Cinnamonbun89$
project_root: "{{ inventory_dir }}"
# Local paths
docker_stacks: "{{ project_root }}/docker"
assets: "{{ project_root }}/assets"
# Remote paths
remote_stacks: "/home/javi/docker"
remote_app_mounts: "/home/docker"

View File

@ -9,6 +9,8 @@ all:
ansible_host: 10.89.0.11
node3:
ansible_host: 10.89.0.12
nas:
ansible_host: 10.89.0.15
virtual_machines:
hosts:
portainer_main:

View File

@ -1 +1,17 @@
ROLE="$1"
FULLPATH="./roles/$ROLE"
function makepart() {
mkdir -p "$FULLPATH/$1"
touch "$FULLPATH/$1/main.yml"
}
makepart "defaults"
makepart "tasks"
# The below are optional
# mkdir -p "$FULLPATH/files"
# touch "$FULLPATH/files/.gitkeep"
# makepart "handlers"
# makepart "meta"
# makepart "templates"
# makepart "vars"

13
playbooks/apps/stash.yml Normal file
View File

@ -0,0 +1,13 @@
---
- name: Deploy stash
hosts: streaming_services
roles:
- role: mount_nfs
vars:
share: "/mnt/main/xrandr"
mount_path: "/home/docker/xrandr"
- role: deploy_docker_stack
vars:
stack_name: stash
apps:
- stash

View File

@ -0,0 +1,2 @@
apps: []
stack_name: "willneverexist"

View File

@ -0,0 +1,27 @@
---
- name: Create app mount directories
ansible.builtin.file:
path: "{{ remote_app_mounts }}/{{ item }}"
state: directory
mode: '0777'
loop: "{{ apps }}"
- name: Create stack directory
ansible.builtin.file:
path: "{{ remote_stacks }}/{{ stack_name }}"
state: directory
mode: '0777'
- name: Copy docker-compose.yml to server
ansible.builtin.copy:
src: '{{ docker_stacks }}/{{ stack_name }}/docker-compose.yml'
dest: '{{ remote_stacks }}/{{ stack_name }}/docker-compose.yml'
owner: javi
group: javi
mode: '0777'
- name: Start up the containers
ansible.builtin.command: docker compose up -d
become: true
args:
chdir: "{{ remote_stacks }}/{{ stack_name }}"

View File

@ -0,0 +1,3 @@
mount_host: "{{ hostvars['nas'].ansible_host }}"
share: "/mnt/main/media"
mount_path: "/mnt/unspecifiedshare"

View File

@ -0,0 +1,21 @@
---
- name: Ensure NFS client is installed
ansible.builtin.package:
name: nfs-common
state: present
become: true
- name: Create mount point directory
ansible.builtin.file:
path: "{{ mount_path }}"
state: directory
mode: '0777'
become: true
- name: Mount share
ansible.posix.mount:
src: "{{ mount_host }}:{{ share }}"
path: "{{ mount_path }}"
fstype: nfs
state: mounted
become: true