first commit

This commit is contained in:
2026-01-30 14:49:44 -05:00
commit eb829c624c
5 changed files with 210 additions and 0 deletions

95
Jenkinsfile vendored Normal file
View File

@@ -0,0 +1,95 @@
pipeline {
agent any
parameters {
choice(
name: 'PLAYBOOK',
choices: ['dockerUpdate.yml', 'dockerPrune.yaml'],
description: 'Select the playbook to run'
)
string(
name: 'LIMIT',
defaultValue: '',
description: 'Limit to specific hosts or groups (e.g., "vms", "lxcs", "update_targets", or hostname) no.lan required'
)
booleanParam(
name: 'DRY_RUN',
defaultValue: false,
description: 'Run in check mode (no changes made)'
)
}
environment {
PROXMOX_URL = 'https://192.168.0.166:8006'
PROXMOX_USER = 'dynamic-inventory@pve'
PROXMOX_TOKEN_ID = 'dynamic-inventory'
PROXMOX_TOKEN_SECRET = credentials('PROXMOX_TOKEN_SECRET')
ANSIBLE_HOST_KEY_CHECKING = 'False'
}
stages {
stage('Checkout') {
steps {
checkout scm
}
}
stage('Verify Inventory') {
steps {
sh '''
echo "Testing dynamic inventory connection..."
ansible-inventory -i inventories/inventory.proxmox.yml --list | head -10
'''
}
}
stage('Run Playbook') {
steps {
script {
def dockerPlaybooks = ['dockerUpdate.yml', 'dockerPrune.yaml']
def isDockerPlaybook = params.PLAYBOOK in dockerPlaybooks
// Build the limit flag
def limitValue = ''
if (isDockerPlaybook) {
// Docker playbooks always target 'docker' tagged hosts
// If user provides a limit, use intersection (docker AND limit)
limitValue = params.LIMIT ? "docker:&${params.LIMIT}" : 'docker'
} else {
limitValue = params.LIMIT ?: ''
}
def limitFlag = limitValue ? "--limit '${limitValue}'" : ''
def checkFlag = (params.DRY_RUN == true) ? '--check --diff' : ''
def extraVars = (params.CLEANUP_SNAPSHOTS == true) ? "-e cleanup_old_snapshots=true" : ''
echo "DRY_RUN parameter: ${params.DRY_RUN}"
echo "Check flag: '${checkFlag}'"
echo "Limit: '${limitValue}'"
if (isDockerPlaybook) {
echo "Docker playbook detected - targeting hosts with 'docker' tag"
}
sh """
ansible-playbook \
-i inventories/inventory.proxmox.yml \
playbooks/${params.PLAYBOOK} \
${limitFlag} \
${checkFlag} \
${extraVars} \
-v
"""
}
}
}
}
post {
success {
echo "Playbook ${params.PLAYBOOK} completed successfully"
}
failure {
echo "Playbook ${params.PLAYBOOK} failed"
}
}
}

22
README.md Normal file
View File

@@ -0,0 +1,22 @@
# Infrastructure
Master Node runs on Plex VM
# Example Commands
`ansible VMs -m ping`
This runs the ping module on all hosts in the VMs group
`ansible vpn -m ping`
Runs the ping module on the host named vpn
`ansible vpn -m ansible.builtin.copy -a "src=/home/jerick/plex/docker-compose.yml dest=/home/jerick/"`
Copied the Plex docker-compose file from plex to vpn
`ansible-playbook update.yaml -kK`
Runs the update.yml playbook
/etc/ansible for app directory
#update.yaml
ansible-playbook -i inventories/inventory.linux.proxmox.yml update.yaml -kK
this will update all runningVMs and LXCs with the linux tag

View File

@@ -0,0 +1,25 @@
# Proxmox Dynamic Inventory
# Requires PROXMOX_TOKEN_SECRET environment variable to be set
plugin: community.proxmox.proxmox
url: https://192.168.0.166:8006
user: dynamic-inventory@pve
token_id: dynamic-inventory
validate_certs: false
want_facts: true
# Filter to only running machines
filters:
- proxmox_status == 'running'
# Group by Proxmox tags and type
groups:
vms: "'qemu' in proxmox_type"
lxcs: "'lxc' in proxmox_type"
# Tag-based groups - add tags in Proxmox to auto-group
update_targets: "'update' in (proxmox_tags | default([]))"
docker_hosts: "'docker' in (proxmox_tags | default([]))"
kubernetes: "'k8s' in (proxmox_tags | default([]))"
compose:
ansible_host: name + '.lan'
ansible_user: 'jenkins'

View File

@@ -0,0 +1,11 @@
- hosts: VMs
gather_facts: no
tasks:
- name: Prune all unused containers, images, networks, volumes
community.docker.docker_prune:
containers: true
images: true
networks: true
volumes: true
builder_cache: true

View File

@@ -0,0 +1,57 @@
# Use with: ansible-playbook -i inventories/inventory.proxmox.yml playbooks/dockerUpdate.yml --limit docker_hosts
- name: Update Docker containers for media-app
hosts: media-app
tasks:
- name: Pull new images for all services
community.docker.docker_compose_v2:
project_src: "{{ item.directory }}"
state: present
loop:
- { directory: "/home/jerick/audiobookshelf" }
- { directory: "/home/jerick/authelia" }
- { directory: "/home/jerick/bazarr" }
- { directory: "/home/jerick/firefly3" }
- { directory: "/home/jerick/gitea" }
- { directory: "/home/jerick/gotify" }
- { directory: "/home/jerick/it-tools" }
- { directory: "/home/jerick/joplin" }
- { directory: "/home/jerick/nginxproxy" }
- { directory: "/home/jerick/ombi" }
- { directory: "/home/jerick/picoshare" }
- { directory: "/home/jerick/romM" }
- { directory: "/home/jerick/tandoor_recipes" }
- { directory: "/home/jerick/tautulli" }
- { directory: "/home/jerick/watchtower" }
- { directory: "/home/jerick/immich" }
- name: Update Docker containers for media-management
hosts: media-management
tasks:
- name: Pull new images for all services
community.docker.docker_compose_v2:
project_src: "{{ item.directory }}"
state: present
loop:
- { directory: "/home/jerick/docker" }
- name: Update Docker containers for plex
hosts: plex
tasks:
- name: Pull new images for all services
community.docker.docker_compose_v2:
project_src: "{{ item.directory }}"
state: present
loop:
- { directory: "/home/jerick/plex" }
- { directory: "/home/jerick/plexAutoLanguages" }
- name: Cleanup
hosts: docker_hosts
tasks:
- name: Prune Docker Images, Networks, etc
community.docker.docker_prune:
containers: true
images: true
networks: true
volumes: true
builder_cache: true