semaphore setup

This commit is contained in:
tolerryan
2025-04-22 01:04:24 -05:00
parent 1adc4811fc
commit a81e761ea7
9 changed files with 45 additions and 194 deletions

View File

View File

@@ -0,0 +1,22 @@
services:
# semaphore server
semaphore:
ports:
- 3000:3000
image: semaphoreui/semaphore:v2.13.14
environment:
SEMAPHORE_DB_DIALECT: bolt
SEMAPHORE_ADMIN: semaadmin
SEMAPHORE_ADMIN_PASSWORD: G!$yrgMH8XkhPQ
SEMAPHORE_ADMIN_NAME: Admin
SEMAPHORE_ADMIN_EMAIL: admin@localhost
SEMAPHORE_USE_REMOTE_RUNNER: "True"
volumes:
- ./semaphore/data:/var/lib/semaphore
- ./semaphore/etc:/etc/semaphore
- ./semaphore/tmp:/tmp/semaphore
volumes:
./semaphore/data:
./semaphore/etc:
./semaphore/tmp:

View File

@@ -19,15 +19,6 @@
- name: Setup Restic Cron jobs
include: ../../lib/setup-restic-cron.yml
- name: Create zabbix user
user:
name: zabbix
uid: 2005
group: users
state: present
create_home: yes
home: /home/zabbix
shell: /bin/bash
- name: Install Python Packages
apt:
@@ -39,10 +30,10 @@
- name: Setup Service
copy:
dest: /etc/systemd/system/zabbix.service
dest: /etc/systemd/system/semaphone.service
content: |
[Unit]
Description=zabbix
Description=semaphone
After=network.target
[Service]
@@ -73,27 +64,27 @@
group: docker
mode: u=rw,g=r,o=r
- name: Check if zabbix directory exists
- name: Check if semaphone directory exists
stat:
path: /zabbix
register: zabbix_stat
path: /semaphone
register: semaphone_stat
- name: Restore zabbix Dir
- name: Restore semaphone Dir
shell: |
restic --password-file /home/restic/.resticpassword -r sftp:misamisa://home/restic/$(hostname) --target / --path /zabbix/zabbix-server restore latest
restic --password-file /home/restic/.resticpassword -r sftp:misamisa://home/restic/$(hostname) --target / --path /zabbix/zabbix-web restore latest
restic --password-file /home/restic/.resticpassword -r sftp:misamisa://home/restic/$(hostname) --target / --path /zabbix/zabbix-db/backups restore latest
restic --password-file /home/restic/.resticpassword -r sftp:misamisa://home/restic/$(hostname) --target / --path /semaphone/semaphone-server restore latest
restic --password-file /home/restic/.resticpassword -r sftp:misamisa://home/restic/$(hostname) --target / --path /semaphone/semaphone-web restore latest
restic --password-file /home/restic/.resticpassword -r sftp:misamisa://home/restic/$(hostname) --target / --path /semaphone/semaphone-db/backups restore latest
args:
chdir: /home/restic
creates: /zabbix
when: not zabbix_stat.stat.exists or not zabbix_stat.stat.isdir
chdir: /home/semaphone
creates: /semaphone
when: not semaphone_stat.stat.exists or not semaphone_stat.stat.isdir
- name: Reload systemd daemon
systemd:
daemon_reload: yes
- name: Start zabbix Service
- name: Start semaphone Service
systemd:
name: zabbix
name: semaphone
state: started
enabled: yes

View File

@@ -1,49 +0,0 @@
---
cronjob:
- name: Zabbix-server
job_name: "Weekly Zabbix-server Backup"
job_minute: "0"
job_hour: "2"
job_day: "4"
user: "root"
job_command: "/home/restic/restic.sh --backup /zabbix/zabbix-server/"
- name: Zabbix-web
job_name: "Weekly /zabbix/zabbix-web/ Backup"
job_minute: "0"
job_hour: "4"
job_day: "3"
user: "root"
job_command: "/home/docker/restic.sh --backup /zabbix/zabbix-web/ "
- name: Zabbix-db
job_name: "Weekly /zabbix/zabbix-db/backups/ Backup"
job_minute: "10"
job_hour: "5"
job_day: "1"
user: "root"
job_command: "/home/docker/restic.sh --backup /zabbix/zabbix-db/backups/"
- name: verify-Zabbix-server
job_name: "Weekly Zabbix-server verify"
job_minute: "0"
job_hour: "2"
job_day: "5"
user: "root"
job_command: "/home/restic/restic.sh --check /zabbix/zabbix-server/"
- name: verify-Zabbix-web
job_name: "Weekly /zabbix/zabbix-web/ verify"
job_minute: "0"
job_hour: "4"
job_day: "5"
user: "root"
job_command: "/home/docker/restic.sh --check /zabbix/zabbix-web/ "
- name: verify-Zabbix-db
job_name: "Weekly /zabbix/zabbix-db/backups/ verification"
job_minute: "10"
job_hour: "5"
job_day: "5"
user: "root"
job_command: "/home/docker/restic.sh --check /zabbix/zabbix-db/backups/"

View File

@@ -1,5 +0,0 @@
MYSQL_USER=zabbix
MYSQL_PASSWORD=zabbix
MYSQL_ROOT_PASSWORD=kqjnvq038rn32n4jkn
ZABBIX_DATA_PATH=/zabbix
ZBX_STARTPINGERS=1

View File

@@ -1,74 +0,0 @@
services:
# Zabbix database
zabbix-db:
container_name: zabbix-db
image: mariadb:11.4.4
restart: always
volumes:
- ${ZABBIX_DATA_PATH}/zabbix-db/mariadb:/var/lib/mysql:rw
- ${ZABBIX_DATA_PATH}/zabbix-db/backups:/backups
command:
- mariadbd
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_bin
##- --default-authentication-plugin=mysql_native_password
environment:
- MYSQL_USER=${MYSQL_USER}
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
stop_grace_period: 1m
# Zabbix server
zabbix-server:
container_name: zabbix-server
image: zabbix/zabbix-server-mysql:ubuntu-7.2-latest
restart: always
ports:
- 10051:10051
volumes:
- /etc/localtime:/etc/localtime:ro
- ${ZABBIX_DATA_PATH}/zabbix-server/zabbix_server.conf:/etc/zabbix/zabbix_server.conf
- ${ZABBIX_DATA_PATH}/zabbix-server/alertscripts:/usr/lib/zabbix/alertscripts:ro
- ${ZABBIX_DATA_PATH}/zabbix-server/externalscripts:/usr/lib/zabbix/externalscripts:ro
- ${ZABBIX_DATA_PATH}/zabbix-server/dbscripts:/var/lib/zabbix/dbscripts:ro
- ${ZABBIX_DATA_PATH}/zabbix-server/export:/var/lib/zabbix/export:rw
- ${ZABBIX_DATA_PATH}/zabbix-server/modules:/var/lib/zabbix/modules:ro
- ${ZABBIX_DATA_PATH}/zabbix-server/enc:/var/lib/zabbix/enc:ro
- ${ZABBIX_DATA_PATH}/zabbix-server/ssh_keys:/var/lib/zabbix/ssh_keys:ro
- ${ZABBIX_DATA_PATH}/zabbix-server/mibs:/var/lib/zabbix/mibs:ro
environment:
- MYSQL_ROOT_USER=root
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
- DB_SERVER_HOST=zabbix-db
- ZBX_STARTPINGERS=${ZBX_STARTPINGERS}
depends_on:
- zabbix-db
stop_grace_period: 30s
sysctls:
- net.ipv4.ip_local_port_range=1024 65000
- net.ipv4.conf.all.accept_redirects=0
- net.ipv4.conf.all.secure_redirects=0
- net.ipv4.conf.all.send_redirects=0
# Zabbix web UI
zabbix-web:
container_name: zabbix-web
image: zabbix/zabbix-web-nginx-mysql:ubuntu-7.2-latest
restart: always
ports:
- 8080:8080
volumes:
- /etc/localtime:/etc/localtime:ro
- ${ZABBIX_DATA_PATH}/zabbix-web/nginx:/etc/ssl/nginx:ro
- ${ZABBIX_DATA_PATH}/zabbix-web/modules/:/usr/share/zabbix/modules/:ro
environment:
- MYSQL_USER=${MYSQL_USER}
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
- DB_SERVER_HOST=zabbix-db
- ZBX_SERVER_HOST=zabbix-server
- ZBX_SERVER_NAME=Zabbix Docker
- PHP_TZ=America/Chicago
depends_on:
- zabbix-db
- zabbix-server
stop_grace_period: 10s

View File

@@ -1,33 +0,0 @@
- name: Download Zabbix Repo
ansible.builtin.get_url:
url: "https://repo.zabbix.com/zabbix/7.2/release/debian/pool/main/z/zabbix-release/zabbix-release_latest_7.2+debian12_all.deb"
dest: "/tmp/zabbix-release_7.2.deb"
- name: Install Zabbix Repo package
ansible.builtin.apt:
deb: /tmp/zabbix-release_7.2.deb
- name: Install zabbix-agent2 and plugins
ansible.builtin.apt:
name:
- zabbix-agent2
- zabbix-agent2-plugin-*
update_cache: yes
- name: Restart zabbix-agent2
systemd:
name: zabbix-agent2
state: restarted
- name: Enable zabbix-agent2 to start on boot
systemd:
name: zabbix-agent2
enabled: yes
- name: Update zabbix-agent2.conf
ansible.builtin.lineinfile:
path: /etc/zabbix/zabbix_agent2.conf
regexp: '^Server=.*'
line: 'Server=192.168.0.59'
state: present
backup: yes

View File

@@ -6,6 +6,13 @@
create: yes
mode: '0644'
- name: Set up apt proxy configuration
copy:
content: |
Acquire::http::Proxy "http://debcache:3142";
dest: /etc/apt/apt.conf.d/00cacher
mode: '0644'
- name: Update apt cache
ansible.builtin.apt:
update_cache: yes