mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-09-09 19:57:16 +02:00
Compare commits
18 Commits
3a839cfe37
...
0a4b9bc8e4
Author | SHA1 | Date | |
---|---|---|---|
0a4b9bc8e4 | |||
2887e54cca | |||
630fd43382 | |||
3114a7b586 | |||
34d771266a | |||
73b7d2728e | |||
fc4df980c5 | |||
763b43b44c | |||
db860e6ae3 | |||
2ba486902f | |||
7848226f83 | |||
185f37af52 | |||
b9461026a6 | |||
bf63e01b98 | |||
4a600ac531 | |||
dc0bb555c1 | |||
5adce08aea | |||
2569abc0be |
38
filter_plugins/get_service_name.py
Normal file
38
filter_plugins/get_service_name.py
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
"""
|
||||||
|
Custom Ansible filter to build a systemctl unit name (always lowercase).
|
||||||
|
|
||||||
|
Rules:
|
||||||
|
- If `systemctl_id` ends with '@': drop the '@' and return
|
||||||
|
"{systemctl_id_without_at}.{software_name}@{suffix_handling}".
|
||||||
|
- Else: return "{systemctl_id}.{software_name}{suffix_handling}".
|
||||||
|
|
||||||
|
Suffix handling:
|
||||||
|
- Default "" → automatically pick:
|
||||||
|
- ".service" if no '@' in systemctl_id
|
||||||
|
- ".timer" if '@' in systemctl_id
|
||||||
|
- Explicit False → no suffix at all
|
||||||
|
- Any string → ".{suffix}" (lowercased)
|
||||||
|
"""
|
||||||
|
|
||||||
|
def get_service_name(systemctl_id, software_name, suffix=""):
|
||||||
|
sid = str(systemctl_id).strip().lower()
|
||||||
|
sw = str(software_name).strip().lower()
|
||||||
|
|
||||||
|
# Determine suffix
|
||||||
|
if suffix is False:
|
||||||
|
sfx = "" # no suffix at all
|
||||||
|
elif suffix == "" or suffix is None:
|
||||||
|
sfx = ".service"
|
||||||
|
else:
|
||||||
|
sfx = "." + str(suffix).strip().lower()
|
||||||
|
|
||||||
|
if sid.endswith("@"):
|
||||||
|
base = sid[:-1] # drop the trailing '@'
|
||||||
|
return f"{base}.{sw}@{sfx}"
|
||||||
|
else:
|
||||||
|
return f"{sid}.{sw}{sfx}"
|
||||||
|
|
||||||
|
|
||||||
|
class FilterModule(object):
|
||||||
|
def filters(self):
|
||||||
|
return {"get_service_name": get_service_name}
|
24
filter_plugins/get_service_script_path.py
Normal file
24
filter_plugins/get_service_script_path.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# filter_plugins/get_service_script_path.py
|
||||||
|
# Custom Ansible filter to generate service script paths.
|
||||||
|
|
||||||
|
def get_service_script_path(systemctl_id, script_type):
|
||||||
|
"""
|
||||||
|
Build the path to a service script based on systemctl_id and type.
|
||||||
|
|
||||||
|
:param systemctl_id: The identifier of the system service.
|
||||||
|
:param script_type: The script type/extension (e.g., sh, py, yml).
|
||||||
|
:return: The full path string.
|
||||||
|
"""
|
||||||
|
if not systemctl_id or not script_type:
|
||||||
|
raise ValueError("Both systemctl_id and script_type are required")
|
||||||
|
|
||||||
|
return f"/opt/scripts/systemctl/{systemctl_id}/script.{script_type}"
|
||||||
|
|
||||||
|
|
||||||
|
class FilterModule(object):
|
||||||
|
""" Custom filters for Ansible """
|
||||||
|
|
||||||
|
def filters(self):
|
||||||
|
return {
|
||||||
|
"get_service_script_path": get_service_script_path
|
||||||
|
}
|
@@ -2,5 +2,7 @@
|
|||||||
# Path Variables for Key Directories and Scripts
|
# Path Variables for Key Directories and Scripts
|
||||||
PATH_ADMINISTRATOR_HOME: "/home/administrator/"
|
PATH_ADMINISTRATOR_HOME: "/home/administrator/"
|
||||||
PATH_ADMINISTRATOR_SCRIPTS: "/opt/scripts/"
|
PATH_ADMINISTRATOR_SCRIPTS: "/opt/scripts/"
|
||||||
|
PATH_SYSTEMCTL_SCRIPTS: "{{ [ PATH_ADMINISTRATOR_SCRIPTS, 'systemctl' ] | path_join }}"
|
||||||
PATH_DOCKER_COMPOSE_INSTANCES: "/opt/docker/"
|
PATH_DOCKER_COMPOSE_INSTANCES: "/opt/docker/"
|
||||||
PATH_SYSTEM_LOCK_SCRIPT: "/opt/scripts/sys-lock.py"
|
PATH_SYSTEM_LOCK_SCRIPT: "/opt/scripts/sys-lock.py"
|
||||||
|
PATH_SYSTEM_SERVICE_DIR: "/etc/systemd/system"
|
@@ -2,10 +2,22 @@
|
|||||||
# Services
|
# Services
|
||||||
|
|
||||||
## Meta
|
## Meta
|
||||||
SYS_SERVICE_SUFFIX: ".{{ SOFTWARE_NAME | lower }}.service"
|
SYS_SERVICE_SUFFIX: ".{{ SOFTWARE_NAME | lower }}.service"
|
||||||
|
SYS_SERVICE_ALL_ENABLED: false # Flush all services
|
||||||
|
SYS_SERVICE_DEFAULT_STATE: "{{ omit }}"
|
||||||
|
|
||||||
## Names
|
## Names
|
||||||
SYS_SERVICE_ALARM_CMP: "sys-ctl-alm-compose.{{ SOFTWARE_NAME }}@.service"
|
SYS_SERVICE_CLEANUP_BACKUPS_OLD: "{{ 'sys-ctl-cln-backups' | get_service_name(SOFTWARE_NAME) }}"
|
||||||
|
SYS_SERVICE_CLEANUP_BACKUPS_FAILED: "{{ 'sys-ctl-cln-faild-bkps' | get_service_name(SOFTWARE_NAME) }}"
|
||||||
|
SYS_SERVICE_OPTIMIZE_DRIVE: "{{ 'svc-opt-ssd-hdd' | get_service_name(SOFTWARE_NAME) }}"
|
||||||
|
SYS_SERVICE_BACKUP_RMT_2_LOC: "{{ 'svc-bkp-rmt-2-loc' | get_service_name(SOFTWARE_NAME) }}"
|
||||||
|
SYS_SERVICE_REPAIR_DOCKER_HARD: "{{ 'sys-ctl-rpr-docker-hard' | get_service_name(SOFTWARE_NAME) }}"
|
||||||
|
SYS_SERVICE_UPDATE_DOCKER: "{{ 'update-docker' | get_service_name(SOFTWARE_NAME) }}"
|
||||||
|
|
||||||
|
## On Failure
|
||||||
|
SYS_SERVICE_ON_FAILURE_COMPOSE: "{{ 'sys-ctl-alm-compose' | get_service_name(SOFTWARE_NAME,'%i.service') }}"
|
||||||
|
SYS_SERVICE_ON_FAILURE_EMAIL: "{{ 'sys-ctl-alm-email' | get_service_name(SOFTWARE_NAME,'%i.service') }}"
|
||||||
|
SYS_SERVICE_ON_FAILURE_TELEGRAM: "{{ 'sys-ctl-alm-telegram' | get_service_name(SOFTWARE_NAME,'%i.service') }}"
|
||||||
|
|
||||||
## Groups
|
## Groups
|
||||||
SYS_SERVICE_GROUP_BACKUPS: >
|
SYS_SERVICE_GROUP_BACKUPS: >
|
||||||
@@ -36,5 +48,6 @@ SYS_SERVICE_GROUP_MANIPULATION: >
|
|||||||
SYS_SERVICE_GROUP_REPAIR +
|
SYS_SERVICE_GROUP_REPAIR +
|
||||||
SYS_SERVICE_GROUP_OPTIMIZATION +
|
SYS_SERVICE_GROUP_OPTIMIZATION +
|
||||||
SYS_SERVICE_GROUP_MAINTANANCE +
|
SYS_SERVICE_GROUP_MAINTANANCE +
|
||||||
[ 'update-docker' ]
|
[ SYS_SERVICE_UPDATE_DOCKER ]
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
@@ -2,13 +2,13 @@
|
|||||||
# Service Timers
|
# Service Timers
|
||||||
|
|
||||||
## Meta
|
## Meta
|
||||||
SYS_TIMER_SUFFIX: ".{{ SOFTWARE_NAME | lower }}.timer"
|
SYS_TIMER_SUFFIX: ".{{ SOFTWARE_NAME | lower }}.timer"
|
||||||
|
SYS_TIMER_ALL_ENABLED: false # Runtime Variables for Process Control - Activates all timers, independend if the handlers had been triggered
|
||||||
|
|
||||||
## Server Tact Variables
|
## Server Tact Variables
|
||||||
|
|
||||||
HOURS_SERVER_AWAKE: "0..23" # Ours in which the server is "awake" (100% working). Rest of the time is reserved for maintanance
|
HOURS_SERVER_AWAKE: "0..23" # Ours in which the server is "awake" (100% working). Rest of the time is reserved for maintanance
|
||||||
RANDOMIZED_DELAY_SEC: "5min" # Random delay for systemd timers to avoid peak loads.
|
RANDOMIZED_DELAY_SEC: "5min" # Random delay for systemd timers to avoid peak loads.
|
||||||
ACTIVATE_ALL_TIMERS: false # Runtime Variables for Process Control - Activates all timers, independend if the handlers had been triggered
|
|
||||||
|
|
||||||
## Timeouts for all services
|
## Timeouts for all services
|
||||||
SYS_TIMEOUT_CLEANUP_SERVICES: "15min"
|
SYS_TIMEOUT_CLEANUP_SERVICES: "15min"
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
backups_folder_path: "/Backups/" # Path to the backups folder
|
BACKUPS_FOLDER_PATH: "/Backups/" # Path to the backups folder
|
||||||
|
|
||||||
# Storage Space-Related Configurations
|
# Storage Space-Related Configurations
|
||||||
size_percent_maximum_backup: 75 # Maximum storage space in percent for backups
|
SIZE_PERCENT_MAXIMUM_BACKUP: 75 # Maximum storage space in percent for backups
|
||||||
size_percent_cleanup_disc_space: 85 # Threshold for triggering cleanup actions
|
SIZE_PERCENT_CLEANUP_DISC_SPACE: 85 # Threshold for triggering cleanup actions
|
||||||
size_percent_disc_space_warning: 90 # Warning threshold in percent for free disk space
|
SIZE_PERCENT_DISC_SPACE_WARNING: 90 # Warning threshold in percent for free disk space
|
@@ -134,11 +134,6 @@ roles:
|
|||||||
title: "Webserver Optimation"
|
title: "Webserver Optimation"
|
||||||
description: "Tools which help to optimize webservers"
|
description: "Tools which help to optimize webservers"
|
||||||
invokable: true
|
invokable: true
|
||||||
net:
|
|
||||||
title: "Network"
|
|
||||||
description: "Network setup (DNS, Let's Encrypt HTTP, WireGuard, etc.)"
|
|
||||||
icon: "fas fa-globe"
|
|
||||||
invokable: true
|
|
||||||
svc:
|
svc:
|
||||||
title: "Services"
|
title: "Services"
|
||||||
description: "Infrastructure services like databases"
|
description: "Infrastructure services like databases"
|
||||||
@@ -158,7 +153,11 @@ roles:
|
|||||||
description: "Reverse‑proxy roles for routing and load‑balancing traffic to backend services"
|
description: "Reverse‑proxy roles for routing and load‑balancing traffic to backend services"
|
||||||
icon: "fas fa-project-diagram"
|
icon: "fas fa-project-diagram"
|
||||||
invokable: true
|
invokable: true
|
||||||
|
net:
|
||||||
|
title: "Network"
|
||||||
|
description: "Network setup (DNS, Let's Encrypt HTTP, WireGuard, etc.)"
|
||||||
|
icon: "fas fa-globe"
|
||||||
|
invokable: true
|
||||||
user:
|
user:
|
||||||
title: "Users & Access"
|
title: "Users & Access"
|
||||||
description: "User accounts & access control"
|
description: "User accounts & access control"
|
||||||
|
@@ -1,38 +0,0 @@
|
|||||||
- include_role:
|
|
||||||
name: '{{ item }}'
|
|
||||||
loop:
|
|
||||||
- dev-yay
|
|
||||||
- sys-ctl-alm-compose
|
|
||||||
|
|
||||||
- name: Install MSI packages
|
|
||||||
kewlfft.aur.aur:
|
|
||||||
use: yay
|
|
||||||
name:
|
|
||||||
- msi-perkeyrgb
|
|
||||||
|
|
||||||
- name: Copy keyboard_color.sh script
|
|
||||||
copy:
|
|
||||||
src: keyboard_color.py
|
|
||||||
dest: /opt/keyboard_color.py
|
|
||||||
mode: "0755"
|
|
||||||
|
|
||||||
- name: Copy keyboard-color{{ SYS_SERVICE_SUFFIX }} file
|
|
||||||
template:
|
|
||||||
src: keyboard-color.service.j2
|
|
||||||
dest: /etc/systemd/system/keyboard-color{{ SYS_SERVICE_SUFFIX }}
|
|
||||||
mode: 0644
|
|
||||||
|
|
||||||
- name: Reload systemd daemon
|
|
||||||
systemd:
|
|
||||||
daemon_reload: yes
|
|
||||||
|
|
||||||
- name: "set 'service_name' to '{{ role_name }}'"
|
|
||||||
set_fact:
|
|
||||||
service_name: "{{ role_name }}"
|
|
||||||
|
|
||||||
- name: "include role for sys-timer for {{ service_name }}"
|
|
||||||
include_role:
|
|
||||||
name: sys-timer
|
|
||||||
vars:
|
|
||||||
on_calendar: "{{SYS_SCHEDULE_ANIMATION_KEYBOARD_COLOR}}"
|
|
||||||
persistent: "true"
|
|
@@ -1,5 +0,0 @@
|
|||||||
- block:
|
|
||||||
- include_tasks: 01_core.yml
|
|
||||||
- set_fact:
|
|
||||||
run_once_drv_msi_keyboard_color: true
|
|
||||||
when: run_once_drv_msi_keyboard_color is not defined
|
|
@@ -1,7 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=Keyboard Color Service
|
|
||||||
OnFailure=sys-ctl-alm-compose.{{ SOFTWARE_NAME }}@%n.service
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=oneshot
|
|
||||||
ExecStart=/bin/python /opt/keyboard_color.py {{ vendor_and_product_id }}
|
|
@@ -1 +0,0 @@
|
|||||||
application_id: net-wireguard-core
|
|
@@ -1 +0,0 @@
|
|||||||
application_id: net-wireguard-firewalled
|
|
@@ -1,6 +0,0 @@
|
|||||||
- name: "restart set-mtu service"
|
|
||||||
systemd:
|
|
||||||
name: set-mtu{{ SYS_SERVICE_SUFFIX }}
|
|
||||||
state: restarted
|
|
||||||
enabled: yes
|
|
||||||
daemon_reload: yes
|
|
@@ -1,11 +0,0 @@
|
|||||||
- name: create set-mtu service
|
|
||||||
template:
|
|
||||||
src: set-mtu.service.j2
|
|
||||||
dest: /etc/systemd/system/set-mtu{{ SYS_SERVICE_SUFFIX }}
|
|
||||||
notify: restart set-mtu service
|
|
||||||
|
|
||||||
- name: create set-mtu.sh
|
|
||||||
template:
|
|
||||||
src: set-mtu.sh.j2
|
|
||||||
dest: /usr/local/bin/set-mtu.sh
|
|
||||||
notify: restart set-mtu service
|
|
@@ -1,10 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=set MTU
|
|
||||||
Before=wg-quick@wg0{{ SYS_SERVICE_SUFFIX }}
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=oneshot
|
|
||||||
ExecStart=bash /usr/local/bin/set-mtu.sh
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
RequiredBy=wg-quick@wg0{{ SYS_SERVICE_SUFFIX }}
|
|
@@ -1 +0,0 @@
|
|||||||
application_id: net-wireguard-plain
|
|
@@ -16,7 +16,7 @@ This role is built on top of your existing `srv-web-7-4-core` role, and it autom
|
|||||||
When you apply **srv-web-7-6-https**, it will:
|
When you apply **srv-web-7-6-https**, it will:
|
||||||
|
|
||||||
1. **Include** the `srv-web-7-4-core` role to install and configure Nginx.
|
1. **Include** the `srv-web-7-4-core` role to install and configure Nginx.
|
||||||
2. **Clean up** any stale vHost files under `sys-ctl-cln-domains`.
|
2. **Clean up** any stale vHost files under `sys-svc-cln-domains`.
|
||||||
3. **Deploy** the Let’s Encrypt challenge-and-redirect snippet from `srv-web-7-7-letsencrypt`.
|
3. **Deploy** the Let’s Encrypt challenge-and-redirect snippet from `srv-web-7-7-letsencrypt`.
|
||||||
4. **Reload** Nginx automatically when any template changes.
|
4. **Reload** Nginx automatically when any template changes.
|
||||||
|
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
name: '{{ item }}'
|
name: '{{ item }}'
|
||||||
loop:
|
loop:
|
||||||
- srv-web-7-4-core
|
- srv-web-7-4-core
|
||||||
- sys-ctl-cln-domains
|
- sys-svc-cln-domains
|
||||||
- srv-web-7-7-letsencrypt
|
- srv-web-7-7-letsencrypt
|
||||||
- include_tasks: utils/run_once.yml
|
- include_tasks: utils/run_once.yml
|
||||||
when: run_once_srv_web_7_6_https is not defined
|
when: run_once_srv_web_7_6_https is not defined
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
- name: "reload svc-bkp-loc-2-usb service"
|
- name: "reload svc-bkp-loc-2-usb service"
|
||||||
systemd:
|
systemd:
|
||||||
name: svc-bkp-loc-2-usb{{ SYS_SERVICE_SUFFIX }}
|
name: "{{ 'svc-bkp-loc-2-usb' | get_service_name(SOFTWARE_NAME) }}"
|
||||||
state: reloaded
|
state: reloaded
|
||||||
daemon_reload: yes
|
daemon_reload: yes
|
||||||
|
@@ -11,9 +11,9 @@
|
|||||||
- name: Fail if any backup_to_usb variable is empty
|
- name: Fail if any backup_to_usb variable is empty
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- backup_to_usb_mount != ""
|
- BACKUP_TO_USB_MOUNT != ""
|
||||||
- backup_to_usb_target != ""
|
- BACKUP_TO_USB_target != ""
|
||||||
- backup_to_usb_source != ""
|
- BACKUP_TO_USB_SOURCE != ""
|
||||||
fail_msg: |
|
fail_msg: |
|
||||||
One or more of the configuration variables are empty!
|
One or more of the configuration variables are empty!
|
||||||
Please set:
|
Please set:
|
||||||
@@ -22,19 +22,5 @@
|
|||||||
- source
|
- source
|
||||||
to non‑empty values in your configuration file.
|
to non‑empty values in your configuration file.
|
||||||
|
|
||||||
- name: Copy backup script to the scripts directory
|
- include_role:
|
||||||
copy:
|
name: sys-systemctl
|
||||||
src: svc-bkp-loc-2-usb.py
|
|
||||||
dest: "{{ backup_to_usb_script_path }}"
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: '0755'
|
|
||||||
|
|
||||||
- name: Copy systemd service to systemd directory
|
|
||||||
template:
|
|
||||||
src: svc-bkp-loc-2-usb.service.j2
|
|
||||||
dest: /etc/systemd/system/svc-bkp-loc-2-usb{{ SYS_SERVICE_SUFFIX }}
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: '0644'
|
|
||||||
notify: reload svc-bkp-loc-2-usb service
|
|
||||||
|
@@ -1,12 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=Backup to USB when mounted to {{ backup_to_usb_mount }}
|
|
||||||
Wants={{systemctl_mount_service_name}}
|
|
||||||
OnFailure=sys-ctl-alm-compose.{{ SOFTWARE_NAME }}@%n.service
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=oneshot
|
|
||||||
ExecStart=/bin/python {{ backup_to_usb_script_path }} {{backup_to_usb_source}} {{backup_to_usb_destination}}
|
|
||||||
ExecStartPost=/bin/systemctl start sys-ctl-cln-backups{{ SYS_SERVICE_SUFFIX }}
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
12
roles/svc-bkp-loc-2-usb/templates/systemctl.service.j2
Normal file
12
roles/svc-bkp-loc-2-usb/templates/systemctl.service.j2
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Backup to USB when mounted to {{ BACKUP_TO_USB_MOUNT }}
|
||||||
|
Wants={{ BACKUPS_SERVICE_MNT_NAME }}
|
||||||
|
OnFailure={{ SYS_SERVICE_ON_FAILURE_COMPOSE }}
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/bin/python {{ systemctl_id | get_service_script_path('py') }} {{ BACKUP_TO_USB_SOURCE }} {{ BACKUP_TO_USB_DESTINATION }}
|
||||||
|
ExecStartPost=/bin/systemctl start {{ SYS_SERVICE_CLEANUP_BACKUPS_OLD }}
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
@@ -1,10 +1,9 @@
|
|||||||
application_id: "svc-bkp-loc-2-usb"
|
application_id: "svc-bkp-loc-2-usb"
|
||||||
|
systemctl_id: "{{ application_id }}"
|
||||||
|
|
||||||
backup_to_usb_script_path: "/usr/local/sbin/svc-bkp-loc-2-usb.py"
|
BACKUP_TO_USB_DESTINATION: '{{ BACKUP_TO_USB_MOUNT}}{{ BACKUP_TO_USB_TARGET }}'
|
||||||
backup_to_usb_destination: '{{ backup_to_usb_mount}}{{ backup_to_usb_targed }}'
|
BACKUPS_SERVICE_MNT_NAME: '{{ BACKUP_TO_USB_MOUNT | trim(''/'') | replace(''/'',''-'') }}.mount'
|
||||||
backups_folder_path: '{{ backup_to_usb_destination }}'
|
|
||||||
systemctl_mount_service_name: '{{ backup_to_usb_mount | trim(''/'') | replace(''/'',''-'') }}.mount'
|
|
||||||
|
|
||||||
backup_to_usb_mount: "{{ applications | get_app_conf(application_id, 'mount') }}"
|
BACKUP_TO_USB_MOUNT: "{{ applications | get_app_conf(application_id, 'mount') }}"
|
||||||
backup_to_usb_targed: "{{ applications | get_app_conf(application_id, 'target') }}"
|
BACKUP_TO_USB_TARGET: "{{ applications | get_app_conf(application_id, 'target') }}"
|
||||||
backup_to_usb_source: "{{ applications | get_app_conf(application_id, 'source') }}"
|
BACKUP_TO_USB_SOURCE: "{{ applications | get_app_conf(application_id, 'source') }}"
|
@@ -9,17 +9,17 @@ To track what the service is doing, execute one of the following commands:
|
|||||||
#### Using systemctl
|
#### Using systemctl
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
watch -n2 "systemctl status sys-bkp-rmt-2-loc{{ SYS_SERVICE_SUFFIX }}"
|
watch -n2 "systemctl status {{ 'sys-bkp-rmt-2-loc' | get_service_name(SOFTWARE_NAME) }}"
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Using journalctl
|
#### Using journalctl
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
journalctl -fu sys-bkp-rmt-2-loc{{ SYS_SERVICE_SUFFIX }}
|
journalctl -fu {{ 'sys-bkp-rmt-2-loc' | get_service_name(SOFTWARE_NAME) }}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Viewing History
|
### Viewing History
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo journalctl -u sys-bkp-rmt-2-loc{{ SYS_SERVICE_SUFFIX }}
|
sudo journalctl -u {{ 'sys-bkp-rmt-2-loc' | get_service_name(SOFTWARE_NAME) }}
|
||||||
```
|
```
|
@@ -1,4 +0,0 @@
|
|||||||
- name: "reload svc-bkp-rmt-2-loc service"
|
|
||||||
systemd:
|
|
||||||
name: svc-bkp-rmt-2-loc{{ SYS_SERVICE_SUFFIX }}
|
|
||||||
daemon_reload: yes
|
|
@@ -23,5 +23,4 @@ galaxy_info:
|
|||||||
issue_tracker_url: "https://s.infinito.nexus/issues"
|
issue_tracker_url: "https://s.infinito.nexus/issues"
|
||||||
documentation: "https://docs.infinito.nexus"
|
documentation: "https://docs.infinito.nexus"
|
||||||
dependencies:
|
dependencies:
|
||||||
- sys-timer-cln-bkps
|
|
||||||
- sys-ctl-cln-faild-bkps
|
- sys-ctl-cln-faild-bkps
|
||||||
|
@@ -6,41 +6,25 @@
|
|||||||
- dev-git
|
- dev-git
|
||||||
- sys-ctl-alm-compose
|
- sys-ctl-alm-compose
|
||||||
- sys-lock
|
- sys-lock
|
||||||
- sys-rst-daemon
|
- sys-timer-cln-bkps
|
||||||
- include_tasks: utils/run_once.yml
|
- include_tasks: utils/run_once.yml
|
||||||
when: run_once_svc_bkp_rmt_2_loc is not defined
|
when: run_once_svc_bkp_rmt_2_loc is not defined
|
||||||
|
|
||||||
- name: "create {{docker_backup_remote_to_local_folder}}"
|
- name: "create {{ DOCKER_BACKUP_REMOTE_2_LOCAL_DIR }}"
|
||||||
file:
|
file:
|
||||||
path: "{{docker_backup_remote_to_local_folder}}"
|
path: "{{ DOCKER_BACKUP_REMOTE_2_LOCAL_DIR }}"
|
||||||
state: directory
|
state: directory
|
||||||
mode: "0755"
|
mode: "0755"
|
||||||
|
|
||||||
- name: create svc-bkp-rmt-2-loc.sh
|
- name: create svc-bkp-rmt-2-loc.sh
|
||||||
copy:
|
copy:
|
||||||
src: svc-bkp-rmt-2-loc.sh
|
src: svc-bkp-rmt-2-loc.sh
|
||||||
dest: "{{docker_backup_remote_to_local_folder}}svc-bkp-rmt-2-loc.sh"
|
dest: "{{ DOCKER_BACKUP_REMOTE_2_LOCAL_SCRIPT }}"
|
||||||
mode: "0755"
|
mode: "0755"
|
||||||
|
|
||||||
- name: create svc-bkp-rmt-2-loc{{ SYS_SERVICE_SUFFIX }}
|
- include_role:
|
||||||
template:
|
name: sys-systemctl
|
||||||
src: svc-bkp-rmt-2-loc.service.j2
|
|
||||||
dest: /etc/systemd/system/svc-bkp-rmt-2-loc{{ SYS_SERVICE_SUFFIX }}
|
|
||||||
notify: reload svc-bkp-rmt-2-loc service
|
|
||||||
|
|
||||||
- name: create sys-bkp-rmt-2-loc-multi-provider.sh
|
|
||||||
template:
|
|
||||||
src: sys-bkp-rmt-2-loc-multi-provider.sh.j2
|
|
||||||
dest: "{{docker_backup_remote_to_local_folder}}sys-bkp-rmt-2-loc-multi-provider.sh"
|
|
||||||
mode: "0755"
|
|
||||||
|
|
||||||
- name: "set 'service_name' to '{{ role_name }}'"
|
|
||||||
set_fact:
|
|
||||||
service_name: "{{ role_name }}"
|
|
||||||
|
|
||||||
- name: "include role for sys-timer for {{ service_name }}"
|
|
||||||
include_role:
|
|
||||||
name: sys-timer
|
|
||||||
vars:
|
vars:
|
||||||
on_calendar: "{{SYS_SCHEDULE_BACKUP_REMOTE_TO_LOCAL}}"
|
systemctl_timer_enabled: true
|
||||||
|
systemctl_on_calendar: "{{ SYS_SCHEDULE_BACKUP_REMOTE_TO_LOCAL }}"
|
||||||
|
|
||||||
|
8
roles/svc-bkp-rmt-2-loc/templates/script.sh.j2
Normal file
8
roles/svc-bkp-rmt-2-loc/templates/script.sh.j2
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Pulls the remote backups from multiple hosts
|
||||||
|
hosts="{{ DOCKER_BACKUP_REMOTE_2_LOCAL_BACKUP_PROVIDERS | join(' ') }}";
|
||||||
|
errors=0
|
||||||
|
for host in $hosts; do
|
||||||
|
bash {{ DOCKER_BACKUP_REMOTE_2_LOCAL_SCRIPT }} $host || ((errors+=1));
|
||||||
|
done;
|
||||||
|
exit $errors;
|
@@ -1,8 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# Pulls the remote backups from multiple hosts
|
|
||||||
hosts="{{ rmt2loc_backup_providers | join(' ') }}";
|
|
||||||
errors=0
|
|
||||||
for host in $hosts; do
|
|
||||||
bash {{ docker_backup_remote_to_local_folder }}svc-bkp-rmt-2-loc.sh $host || ((errors+=1));
|
|
||||||
done;
|
|
||||||
exit $errors;
|
|
@@ -1,8 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=pull remote backups
|
|
||||||
OnFailure=sys-ctl-alm-compose.{{ SOFTWARE_NAME }}@%n.service sys-ctl-cln-faild-bkps{{ SYS_SERVICE_SUFFIX }}
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=oneshot
|
|
||||||
ExecStartPre=/bin/sh -c '/usr/bin/python {{ PATH_SYSTEM_LOCK_SCRIPT }} {{ SYS_SERVICE_GROUP_MANIPULATION | join(' ') }} --ignore {{SYS_SERVICE_GROUP_BACKUPS| join(' ') }} --timeout "{{ SYS_TIMEOUT_BACKUP_SERVICES }}"'
|
|
||||||
ExecStart=/bin/sh -c '/usr/bin/bash {{docker_backup_remote_to_local_folder}}sys-bkp-rmt-2-loc-multi-provider.sh'
|
|
8
roles/svc-bkp-rmt-2-loc/templates/systemctl.service.j2
Normal file
8
roles/svc-bkp-rmt-2-loc/templates/systemctl.service.j2
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=pull remote backups
|
||||||
|
OnFailure={{ SYS_SERVICE_ON_FAILURE_COMPOSE }} {{ SYS_SERVICE_CLEANUP_BACKUPS_FAILED }}
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStartPre=/bin/sh -c '/usr/bin/python {{ PATH_SYSTEM_LOCK_SCRIPT }} {{ SYS_SERVICE_GROUP_MANIPULATION | join(' ') }} --ignore {{ SYS_SERVICE_GROUP_BACKUPS| join(' ') }} --timeout "{{ SYS_TIMEOUT_BACKUP_SERVICES }}"'
|
||||||
|
ExecStart=/bin/sh -c '/usr/bin/bash {{ systemctl_id | get_service_script_path('sh') }}'
|
@@ -1,3 +1,5 @@
|
|||||||
application_id: svc-bkp-rmt-2-loc
|
application_id: svc-bkp-rmt-2-loc
|
||||||
docker_backup_remote_to_local_folder: '{{ PATH_ADMINISTRATOR_SCRIPTS }}{{ application_id }}/'
|
systemctl_id: "{{ application_id }}"
|
||||||
rmt2loc_backup_providers: "{{ applications | get_app_conf(application_id, 'backup_providers') }}"
|
DOCKER_BACKUP_REMOTE_2_LOCAL_DIR: '{{ PATH_ADMINISTRATOR_SCRIPTS }}{{ application_id }}/'
|
||||||
|
DOCKER_BACKUP_REMOTE_2_LOCAL_SCRIPT: "{{ DOCKER_BACKUP_REMOTE_2_LOCAL_DIR }}svc-bkp-rmt-2-loc.sh"
|
||||||
|
DOCKER_BACKUP_REMOTE_2_LOCAL_BACKUP_PROVIDERS: "{{ applications | get_app_conf(application_id, 'backup_providers') }}"
|
@@ -17,12 +17,12 @@
|
|||||||
### Activate Configuration
|
### Activate Configuration
|
||||||
```bash
|
```bash
|
||||||
cp /path/to/wg0.conf /etc/wireguard/wg0.conf
|
cp /path/to/wg0.conf /etc/wireguard/wg0.conf
|
||||||
systemctl enable wg-quick@wg0{{ SYS_SERVICE_SUFFIX }} --now
|
systemctl enable wg-quick@wg0.service --now
|
||||||
```
|
```
|
||||||
|
|
||||||
### Check status
|
### Check status
|
||||||
```bash
|
```bash
|
||||||
systemctl status wg-quick@wg0{{ SYS_SERVICE_SUFFIX }}
|
systemctl status wg-quick@wg0.service
|
||||||
```
|
```
|
||||||
|
|
||||||
## Other Resources
|
## Other Resources
|
@@ -1,6 +1,6 @@
|
|||||||
- name: "restart wireguard"
|
- name: "restart wireguard"
|
||||||
systemd:
|
systemd:
|
||||||
name: wg-quick@wg0{{ SYS_SERVICE_SUFFIX }}
|
name: wg-quick@wg0.service
|
||||||
state: restarted
|
state: restarted
|
||||||
enabled: yes
|
enabled: yes
|
||||||
daemon_reload: yes
|
daemon_reload: yes
|
@@ -18,10 +18,10 @@
|
|||||||
group: root
|
group: root
|
||||||
notify: reload sysctl configuration
|
notify: reload sysctl configuration
|
||||||
|
|
||||||
- name: create /etc/wireguard/wg0.infinito.conf
|
- name: create /etc/wireguard/wg0.{{ SOFTWARE_NAME | lower }}.conf
|
||||||
copy:
|
copy:
|
||||||
src: "{{ inventory_dir }}/files/{{ inventory_hostname }}/etc/wireguard/wg0.conf"
|
src: "{{ inventory_dir }}/files/{{ inventory_hostname }}/etc/wireguard/wg0.conf"
|
||||||
dest: /etc/wireguard/wg0.infinito.conf
|
dest: /etc/wireguard/wg0.{{ SOFTWARE_NAME | lower }}.conf
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
notify: restart wireguard
|
notify: restart wireguard
|
1
roles/svc-net-wireguard-core/vars/main.yml
Normal file
1
roles/svc-net-wireguard-core/vars/main.yml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
application_id: svc-net-wireguard-core
|
@@ -19,7 +19,7 @@ The primary purpose of this role is to enable proper routing and connectivity fo
|
|||||||
|
|
||||||
- **iptables Rule Adaptation:** Modifies iptables to allow forwarding and NAT masquerading for the WireGuard client.
|
- **iptables Rule Adaptation:** Modifies iptables to allow forwarding and NAT masquerading for the WireGuard client.
|
||||||
- **NAT Support:** Configures the external interface for proper masquerading.
|
- **NAT Support:** Configures the external interface for proper masquerading.
|
||||||
- **Role Integration:** Depends on the [net-wireguard-plain](../net-wireguard-plain/README.md) role to ensure that WireGuard is properly configured before applying firewall rules.
|
- **Role Integration:** Depends on the [svc-net-wireguard-plain](../svc-net-wireguard-plain/README.md) role to ensure that WireGuard is properly configured before applying firewall rules.
|
||||||
|
|
||||||
## Other Resources
|
## Other Resources
|
||||||
- https://gist.github.com/insdavm/b1034635ab23b8839bf957aa406b5e39
|
- https://gist.github.com/insdavm/b1034635ab23b8839bf957aa406b5e39
|
@@ -23,4 +23,4 @@ galaxy_info:
|
|||||||
issue_tracker_url: "https://s.infinito.nexus/issues"
|
issue_tracker_url: "https://s.infinito.nexus/issues"
|
||||||
documentation: "https://docs.infinito.nexus"
|
documentation: "https://docs.infinito.nexus"
|
||||||
dependencies:
|
dependencies:
|
||||||
- net-wireguard-plain
|
- svc-net-wireguard-plain
|
1
roles/svc-net-wireguard-firewalled/vars/main.yml
Normal file
1
roles/svc-net-wireguard-firewalled/vars/main.yml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
application_id: svc-net-wireguard-firewalled
|
@@ -7,7 +7,7 @@ This role manages WireGuard on a client system. It sets up essential services an
|
|||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
Optimized for client configurations, this role:
|
Optimized for client configurations, this role:
|
||||||
- Deploys a systemd service (`set-mtu{{ SYS_SERVICE_SUFFIX }}`) and its associated script to set the MTU on specified network interfaces.
|
- Deploys a systemd service and its associated script to set the MTU on specified network interfaces.
|
||||||
- Uses a Jinja2 template to generate the `set-mtu.sh` script.
|
- Uses a Jinja2 template to generate the `set-mtu.sh` script.
|
||||||
- Ensures that the MTU is configured correctly before starting WireGuard with [wg-quick](https://www.wireguard.com/quickstart/).
|
- Ensures that the MTU is configured correctly before starting WireGuard with [wg-quick](https://www.wireguard.com/quickstart/).
|
||||||
|
|
@@ -24,4 +24,4 @@ galaxy_info:
|
|||||||
issue_tracker_url: "https://s.infinito.nexus/issues"
|
issue_tracker_url: "https://s.infinito.nexus/issues"
|
||||||
documentation: "https://docs.infinito.nexus"
|
documentation: "https://docs.infinito.nexus"
|
||||||
dependencies:
|
dependencies:
|
||||||
- net-wireguard-core
|
- svc-net-wireguard-core
|
2
roles/svc-net-wireguard-plain/tasks/main.yml
Normal file
2
roles/svc-net-wireguard-plain/tasks/main.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
- include_role:
|
||||||
|
name: sys-systemctl
|
10
roles/svc-net-wireguard-plain/templates/systemctl.service.j2
Normal file
10
roles/svc-net-wireguard-plain/templates/systemctl.service.j2
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=set MTU
|
||||||
|
Before=wg-quick@wg0.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=bash {{ systemctl_id | get_service_script_path('sh') }}
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
RequiredBy=wg-quick@wg0.service
|
2
roles/svc-net-wireguard-plain/vars/main.yml
Normal file
2
roles/svc-net-wireguard-plain/vars/main.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
application_id: svc-net-wireguard-plain
|
||||||
|
systemctl_id: "{{ application_id }}"
|
18
roles/svc-opt-keyboard-color/tasks/01_core.yml
Normal file
18
roles/svc-opt-keyboard-color/tasks/01_core.yml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
- include_role:
|
||||||
|
name: '{{ item }}'
|
||||||
|
loop:
|
||||||
|
- dev-yay
|
||||||
|
- sys-ctl-alm-compose
|
||||||
|
|
||||||
|
- name: Install MSI packages
|
||||||
|
kewlfft.aur.aur:
|
||||||
|
use: yay
|
||||||
|
name:
|
||||||
|
- msi-perkeyrgb
|
||||||
|
|
||||||
|
- include_role:
|
||||||
|
name: sys-systemctl
|
||||||
|
vars:
|
||||||
|
systemctl_on_calendar: "{{ SYS_SCHEDULE_ANIMATION_KEYBOARD_COLOR }}"
|
||||||
|
systemctl_timer_enabled: true
|
||||||
|
persistent: true
|
5
roles/svc-opt-keyboard-color/tasks/main.yml
Normal file
5
roles/svc-opt-keyboard-color/tasks/main.yml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
- block:
|
||||||
|
- include_tasks: 01_core.yml
|
||||||
|
- set_fact:
|
||||||
|
run_once_svc_opt_keyboard_color: true
|
||||||
|
when: run_once_svc_opt_keyboard_color is not defined
|
@@ -0,0 +1,7 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Keyboard Color Service
|
||||||
|
OnFailure={{ SYS_SERVICE_ON_FAILURE_COMPOSE }}
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/bin/python {{ systemctl_id | get_service_script_path('py') }} {{ vendor_and_product_id }}
|
@@ -1,2 +1,3 @@
|
|||||||
application_id: drv-msi-keyboard-color
|
application_id: svc-opt-keyboard-color
|
||||||
|
systemctl_id: "{{ application_id }}"
|
||||||
vendor_and_product_id: "{{ applications | get_app_conf(application_id, 'vendor_and_product_id') }}"
|
vendor_and_product_id: "{{ applications | get_app_conf(application_id, 'vendor_and_product_id') }}"
|
@@ -1,5 +0,0 @@
|
|||||||
- name: "reload svc-opt-ssd-hdd service"
|
|
||||||
systemd:
|
|
||||||
name: svc-opt-ssd-hdd{{ SYS_SERVICE_SUFFIX }}
|
|
||||||
state: reloaded
|
|
||||||
daemon_reload: yes
|
|
@@ -4,8 +4,8 @@ credentials:
|
|||||||
algorithm: "bcrypt"
|
algorithm: "bcrypt"
|
||||||
validation: "^\\$2[aby]\\$.{56}$"
|
validation: "^\\$2[aby]\\$.{56}$"
|
||||||
|
|
||||||
path_rapid_storage:
|
OPT_DRIVE_RAPID_STORAGE_PATH:
|
||||||
description: "Mount path of the servers SSD"
|
description: "Mount path of the servers SSD"
|
||||||
|
|
||||||
path_mass_storage:
|
OPT_DRIVE_MASS_STORAGE_PATH:
|
||||||
description: "Mount path of the servers HDD"
|
description: "Mount path of the servers HDD"
|
@@ -1,22 +1,2 @@
|
|||||||
- name: "create {{storage_optimizer_directory}}"
|
- include_role:
|
||||||
file:
|
name: sys-systemctl
|
||||||
path: "{{storage_optimizer_directory}}"
|
|
||||||
state: directory
|
|
||||||
mode: "0755"
|
|
||||||
|
|
||||||
- name: create svc-opt-ssd-hdd{{ SYS_SERVICE_SUFFIX }}
|
|
||||||
template:
|
|
||||||
src: svc-opt-ssd-hdd.service.j2
|
|
||||||
dest: /etc/systemd/system/svc-opt-ssd-hdd{{ SYS_SERVICE_SUFFIX }}
|
|
||||||
notify: reload svc-opt-ssd-hdd service
|
|
||||||
|
|
||||||
- name: create svc-opt-ssd-hdd.py
|
|
||||||
copy:
|
|
||||||
src: svc-opt-ssd-hdd.py
|
|
||||||
dest: "{{storage_optimizer_script}}"
|
|
||||||
mode: "0755"
|
|
||||||
|
|
||||||
- name: "optimize storage performance"
|
|
||||||
systemd:
|
|
||||||
name: svc-opt-ssd-hdd{{ SYS_SERVICE_SUFFIX }}
|
|
||||||
state: started
|
|
@@ -1,8 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=Optimize storage paths
|
|
||||||
OnFailure=sys-ctl-alm-compose.{{ SOFTWARE_NAME }}@%n.service
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=oneshot
|
|
||||||
ExecStartPre=/bin/sh -c '/usr/bin/python {{ PATH_SYSTEM_LOCK_SCRIPT }} {{ SYS_SERVICE_GROUP_MANIPULATION | join(' ') }} --ignore svc-opt-ssd-hdd svc-bkp-rmt-2-loc --timeout "{{SYS_TIMEOUT_STORAGE_OPTIMIZER}}"'
|
|
||||||
ExecStart=/bin/sh -c '/usr/bin/python {{storage_optimizer_script}} --rapid-storage-path {{path_rapid_storage}} --mass-storage-path {{path_mass_storage}}'
|
|
8
roles/svc-opt-ssd-hdd/templates/systemctl.service.j2
Normal file
8
roles/svc-opt-ssd-hdd/templates/systemctl.service.j2
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Optimize storage paths
|
||||||
|
OnFailure={{ SYS_SERVICE_ON_FAILURE_COMPOSE }}
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStartPre=/bin/sh -c '/usr/bin/python {{ PATH_SYSTEM_LOCK_SCRIPT }} {{ SYS_SERVICE_GROUP_MANIPULATION | join(' ') }} --ignore {{ SYS_SERVICE_OPTIMIZE_DRIVE }} {{ SYS_SERVICE_BACKUP_RMT_2_LOC }} --timeout "{{ SYS_TIMEOUT_STORAGE_OPTIMIZER }}"'
|
||||||
|
ExecStart=/bin/sh -c '/usr/bin/python {{ systemctl_id | get_service_script_path('sh') }} --rapid-storage-path {{ OPT_DRIVE_RAPID_STORAGE_PATH }} --mass-storage-path {{ OPT_DRIVE_MASS_STORAGE_PATH }}'
|
@@ -1,5 +1,4 @@
|
|||||||
application_id: svc-opt-ssd-hdd
|
application_id: svc-opt-ssd-hdd
|
||||||
storage_optimizer_directory: '{{ PATH_ADMINISTRATOR_SCRIPTS }}{{ application_id }}/'
|
systemctl_id: "{{ application_id }}"
|
||||||
storage_optimizer_script: '{{ storage_optimizer_directory }}{{ application_id }}.py'
|
OPT_DRIVE_RAPID_STORAGE_PATH: "{{ applications | get_app_conf(application_id, 'volumes.rapid_storage') }}"
|
||||||
path_rapid_storage: "{{ applications | get_app_conf(application_id, 'volumes.rapid_storage') }}"
|
OPT_DRIVE_MASS_STORAGE_PATH: "{{ applications | get_app_conf(application_id, 'volumes.mass_storage') }}"
|
||||||
path_mass_storage: "{{ applications | get_app_conf(application_id, 'volumes.mass_storage') }}"
|
|
||||||
|
@@ -1,5 +0,0 @@
|
|||||||
- name: "restart sys-ctl-alm-compose service"
|
|
||||||
systemd:
|
|
||||||
name: "{{ SYS_SERVICE_ALARM_CMP }}"
|
|
||||||
daemon_reload: yes
|
|
||||||
when: run_once_sys_ctl_alm_compose is not defined
|
|
@@ -1,14 +1,14 @@
|
|||||||
- block:
|
- block:
|
||||||
- name: Include dependencies
|
- name: "Include '{{ systemctl_id }}'"
|
||||||
include_role:
|
include_role:
|
||||||
name: '{{ item }}'
|
name: '{{ item }}'
|
||||||
loop:
|
loop:
|
||||||
- sys-ctl-alm-telegram
|
- sys-ctl-alm-telegram
|
||||||
- sys-ctl-alm-email
|
- sys-ctl-alm-email
|
||||||
- name: "setup '{{ SYS_SERVICE_ALARM_CMP }}'"
|
- sys-systemctl
|
||||||
template:
|
vars:
|
||||||
src: sys-ctl-alm-compose@.service.j2
|
flush_handlers: true
|
||||||
dest: "/etc/systemd/system/{{ SYS_SERVICE_ALARM_CMP }}"
|
systemctl_timer_enabled: false
|
||||||
notify: "restart sys-ctl-alm-compose service"
|
systemctl_copy_files: false
|
||||||
- include_tasks: utils/run_once.yml
|
- include_tasks: utils/run_once.yml
|
||||||
when: run_once_sys_ctl_alm_compose is not defined
|
when: run_once_sys_ctl_alm_compose is not defined
|
||||||
|
@@ -1,8 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=Notifier for %i
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=oneshot
|
|
||||||
ExecStart=/usr/bin/systemctl start sys-ctl-alm-telegram.infinito@%i.service sys-ctl-alm-email.infinito@%i.service
|
|
||||||
User=root
|
|
||||||
Group=systemd-journal
|
|
@@ -0,0 +1,8 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Notifier for %i
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/usr/bin/systemctl start {{ SYS_SERVICE_ON_FAILURE_EMAIL }} {{ SYS_SERVICE_ON_FAILURE_TELEGRAM }}
|
||||||
|
User=root
|
||||||
|
Group=systemd-journal
|
1
roles/sys-ctl-alm-compose/vars/main.yml
Normal file
1
roles/sys-ctl-alm-compose/vars/main.yml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
systemctl_id: sys-ctl-alm-compose@
|
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
## Description
|
## Description
|
||||||
|
|
||||||
This role installs and configures the necessary components for sending email notifications via systemd when a service fails. It sets up the `sys-ctl-alm-email` service and configures email parameters and templates using msmtp.
|
This role installs and configures the necessary components for sending email notifications via systemd when a service fails. It sets up the `{{ systemctl_id }}` service and configures email parameters and templates using msmtp.
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
|
@@ -1,4 +0,0 @@
|
|||||||
- name: "restart sys-ctl-alm-email service"
|
|
||||||
systemd:
|
|
||||||
name: sys-ctl-alm-email{{ SYS_SERVICE_SUFFIX }}
|
|
||||||
daemon_reload: yes
|
|
@@ -3,21 +3,10 @@
|
|||||||
name: '{{ item }}'
|
name: '{{ item }}'
|
||||||
loop:
|
loop:
|
||||||
- sys-svc-msmtp
|
- sys-svc-msmtp
|
||||||
- sys-rst-daemon
|
|
||||||
|
|
||||||
- name: "create {{systemd_notifier_email_folder}}"
|
- include_role:
|
||||||
file:
|
name: sys-systemctl
|
||||||
path: "{{systemd_notifier_email_folder}}"
|
vars:
|
||||||
state: directory
|
systemctl_copy_files: true
|
||||||
mode: "0755"
|
|
||||||
|
|
||||||
- name: configure sys-ctl-alm-email.sh
|
|
||||||
template:
|
|
||||||
src: sys-ctl-alm-email.sh.j2
|
|
||||||
dest: "{{systemd_notifier_email_folder}}sys-ctl-alm-email.sh"
|
|
||||||
|
|
||||||
- name: configure sys-ctl-alm-email{{ SYS_SERVICE_SUFFIX }}
|
|
||||||
template:
|
|
||||||
src: sys-ctl-alm-email@.service.j2
|
|
||||||
dest: /etc/systemd/system/sys-ctl-alm-email.infinito@.service
|
|
||||||
notify: restart sys-ctl-alm-email service
|
|
||||||
|
@@ -3,6 +3,6 @@ Description=status email for %i to user
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
ExecStart=/bin/bash {{systemd_notifier_email_folder}}sys-ctl-alm-email.sh %i
|
ExecStart=/bin/bash {{ systemctl_id | get_service_script_path('sh') }} %i
|
||||||
User=root
|
User=root
|
||||||
Group=systemd-journal
|
Group=systemd-journal
|
@@ -1 +1 @@
|
|||||||
systemd_notifier_email_folder: '{{ PATH_ADMINISTRATOR_SCRIPTS }}sys-ctl-alm-email/'
|
systemctl_id: sys-ctl-alm-email@
|
||||||
|
@@ -1,4 +0,0 @@
|
|||||||
- name: "restart sys-ctl-alm-telegram service"
|
|
||||||
systemd:
|
|
||||||
name: sys-ctl-alm-telegram{{ SYS_SERVICE_SUFFIX }}
|
|
||||||
daemon_reload: yes
|
|
@@ -1,8 +1,3 @@
|
|||||||
- name: Include dependency 'sys-rst-daemon'
|
|
||||||
include_role:
|
|
||||||
name: sys-rst-daemon
|
|
||||||
when: run_once_sys_rst_daemon is not defined
|
|
||||||
|
|
||||||
- name: Fail if Telegram bot credentials are not set
|
- name: Fail if Telegram bot credentials are not set
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
@@ -14,24 +9,12 @@
|
|||||||
- telegram_bot_token # Your Telegram bot’s API token
|
- telegram_bot_token # Your Telegram bot’s API token
|
||||||
- telegram_chat_id # The Telegram chat ID to send messages to
|
- telegram_chat_id # The Telegram chat ID to send messages to
|
||||||
|
|
||||||
|
- include_role:
|
||||||
|
name: sys-systemctl
|
||||||
|
vars:
|
||||||
|
systemctl_copy_files: true
|
||||||
|
|
||||||
- name: install curl
|
- name: install curl
|
||||||
community.general.pacman:
|
community.general.pacman:
|
||||||
name: curl
|
name: curl
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: Create a directory with a subdirectory
|
|
||||||
ansible.builtin.file:
|
|
||||||
path: "{{systemd_telegram_folder}}"
|
|
||||||
state: directory
|
|
||||||
mode: '0755'
|
|
||||||
|
|
||||||
- name: configure sys-ctl-alm-telegram.sh
|
|
||||||
template:
|
|
||||||
src: sys-ctl-alm-telegram.sh.j2
|
|
||||||
dest: "{{ systemd_telegram_script }}"
|
|
||||||
|
|
||||||
- name: configure sys-ctl-alm-telegram{{ SYS_SERVICE_SUFFIX }}
|
|
||||||
template:
|
|
||||||
src: sys-ctl-alm-telegram@.service.j2
|
|
||||||
dest: "/etc/systemd/system/sys-ctl-alm-telegram.infinito@.service"
|
|
||||||
notify: "restart sys-ctl-alm-telegram service"
|
|
||||||
|
@@ -3,6 +3,6 @@ Description=status Telegram message for %i to user
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
ExecStart=/bin/bash {{ systemd_telegram_script }} %i
|
ExecStart=/bin/bash {{ systemctl_id | get_service_script_path('sh') }} %i
|
||||||
User=root
|
User=root
|
||||||
Group=systemd-journal
|
Group=systemd-journal
|
@@ -1,2 +1 @@
|
|||||||
systemd_telegram_folder: /opt/ansible-roles/sys-ctl-alm-telegram/
|
systemctl_id: sys-ctl-alm-telegram@
|
||||||
systemd_telegram_script: '{{systemd_telegram_folder}}sys-ctl-alm-telegram.sh'
|
|
||||||
|
@@ -1,9 +0,0 @@
|
|||||||
- name: "reload backup docker to local (all) service"
|
|
||||||
systemd:
|
|
||||||
name: "{{ BKP_DOCKER_2_LOC_SERVICE_ALL }}"
|
|
||||||
daemon_reload: yes
|
|
||||||
|
|
||||||
- name: "reload backup docker to local service"
|
|
||||||
systemd:
|
|
||||||
name: "{{ BKP_DOCKER_2_LOC_SERVICE }}"
|
|
||||||
daemon_reload: yes
|
|
@@ -14,24 +14,9 @@
|
|||||||
include_tasks: 03_reset.yml
|
include_tasks: 03_reset.yml
|
||||||
when: MODE_RESET | bool
|
when: MODE_RESET | bool
|
||||||
|
|
||||||
- name: "setup '{{ BKP_DOCKER_2_LOC_SERVICE_ALL }}'"
|
- include_role:
|
||||||
template:
|
name: sys-systemctl
|
||||||
src: "{{ role_name }}-everything.service.j2"
|
|
||||||
dest: /etc/systemd/system/{{ BKP_DOCKER_2_LOC_SERVICE_ALL }}
|
|
||||||
notify: reload backup docker to local (all) service
|
|
||||||
|
|
||||||
- name: "setup '{{ BKP_DOCKER_2_LOC_SERVICE }}'"
|
|
||||||
template:
|
|
||||||
src: "{{ role_name }}.service.j2"
|
|
||||||
dest: /etc/systemd/system/{{ BKP_DOCKER_2_LOC_SERVICE }}
|
|
||||||
notify: reload backup docker to local service
|
|
||||||
|
|
||||||
- name: "set 'service_name' to '{{ role_name }}'"
|
|
||||||
set_fact:
|
|
||||||
service_name: "{{ role_name }}"
|
|
||||||
|
|
||||||
- name: "include role for sys-timer for {{ service_name }}"
|
|
||||||
include_role:
|
|
||||||
name: sys-timer
|
|
||||||
vars:
|
vars:
|
||||||
on_calendar: "{{SYS_SCHEDULE_BACKUP_DOCKER_TO_LOCAL}}"
|
systemctl_copy_files: false
|
||||||
|
systemctl_timer_enabled: false
|
||||||
|
systemctl_on_calendar: "{{ SYS_SCHEDULE_BACKUP_DOCKER_TO_LOCAL }}"
|
||||||
|
@@ -1,9 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=backup all docker volumes to local folder
|
|
||||||
OnFailure=sys-ctl-alm-compose.{{ SOFTWARE_NAME }}@%n.service sys-ctl-cln-faild-bkps{{ SYS_SERVICE_SUFFIX }}
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=oneshot
|
|
||||||
ExecStartPre=/bin/sh -c '/usr/bin/python {{ PATH_SYSTEM_LOCK_SCRIPT }} {{ SYS_SERVICE_GROUP_MANIPULATION | join(' ') }} --ignore {{ SYS_SERVICE_GROUP_BACKUPS | reject('equalto', role_name ) | join(' ') }} --timeout "{{ SYS_TIMEOUT_BACKUP_SERVICES }}"'
|
|
||||||
ExecStart=/bin/sh -c '{{ BKP_DOCKER_2_LOC_EXEC }} --everything'
|
|
||||||
ExecStartPost=/bin/sh -c '/bin/systemctl start sys-ctl-rpr-docker-soft{{ SYS_SERVICE_SUFFIX }} &'
|
|
@@ -1,9 +1,9 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=backup docker volumes to local folder
|
Description=backup docker volumes to local folder
|
||||||
OnFailure=sys-ctl-alm-compose.{{ SOFTWARE_NAME }}@%n.service sys-ctl-cln-faild-bkps{{ SYS_SERVICE_SUFFIX }}
|
OnFailure={{ SYS_SERVICE_ON_FAILURE_COMPOSE }} {{ SYS_SERVICE_CLEANUP_BACKUPS_FAILED }}
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
ExecStartPre=/bin/sh -c '/usr/bin/python {{ PATH_SYSTEM_LOCK_SCRIPT }} {{ SYS_SERVICE_GROUP_MANIPULATION | join(' ') }} --ignore {{ SYS_SERVICE_GROUP_BACKUPS | reject('equalto', role_name ~ '-everything') | join(' ') }} --timeout "{{ SYS_TIMEOUT_BACKUP_SERVICES }}"'
|
ExecStartPre=/bin/sh -c '/usr/bin/python {{ PATH_SYSTEM_LOCK_SCRIPT }} {{ SYS_SERVICE_GROUP_MANIPULATION | join(' ') }} --ignore {{ SYS_SERVICE_GROUP_BACKUPS | reject('equalto', role_name ~ '-everything') | join(' ') }} --timeout "{{ SYS_TIMEOUT_BACKUP_SERVICES }}"'
|
||||||
ExecStart=/bin/sh -c '{{ BKP_DOCKER_2_LOC_EXEC }}'
|
ExecStart=/bin/sh -c '{{ BKP_DOCKER_2_LOC_EXEC }}'
|
||||||
ExecStartPost=/bin/sh -c '/bin/systemctl start sys-ctl-rpr-docker-soft{{ SYS_SERVICE_SUFFIX }} &'
|
ExecStartPost=/bin/sh -c '/bin/systemctl start {{ 'sys-ctl-rpr-docker-soft' | get_service_name(SOFTWARE_NAME) }} &'
|
@@ -5,9 +5,7 @@
|
|||||||
# - BKP_DOCKER_2_LOC_DISABLED: All images where backup.disabled is set (for --images-no-backup-required)
|
# - BKP_DOCKER_2_LOC_DISABLED: All images where backup.disabled is set (for --images-no-backup-required)
|
||||||
# CLI-ready variables render these lists as argument strings.
|
# CLI-ready variables render these lists as argument strings.
|
||||||
|
|
||||||
BKP_DOCKER_2_LOC_SERVICE: "{{ role_name ~ SYS_SERVICE_SUFFIX }}"
|
systemctl_id: sys-ctl-bkp-docker-2-loc
|
||||||
|
|
||||||
BKP_DOCKER_2_LOC_SERVICE_ALL: "{{ role_name }}-everything{{ SYS_SERVICE_SUFFIX }}"
|
|
||||||
|
|
||||||
# Verify if DB is enabled
|
# Verify if DB is enabled
|
||||||
BKP_DOCKER_2_LOC_DB_ENABLED: "{{ database_type | default('') | bool }}"
|
BKP_DOCKER_2_LOC_DB_ENABLED: "{{ database_type | default('') | bool }}"
|
||||||
|
@@ -1,27 +0,0 @@
|
|||||||
- name: Check if docker is installed
|
|
||||||
ansible.builtin.stat:
|
|
||||||
path: /usr/bin/docker
|
|
||||||
register: docker_bin
|
|
||||||
|
|
||||||
- name: "pkgmgr install"
|
|
||||||
include_role:
|
|
||||||
name: pkgmgr-install
|
|
||||||
vars:
|
|
||||||
package_name: dockreap
|
|
||||||
when:
|
|
||||||
- run_once_sys_ctl_cln_anon_volumes is not defined
|
|
||||||
- docker_bin.stat.exists
|
|
||||||
|
|
||||||
- name: run dockreap with --no-confirmation
|
|
||||||
command:
|
|
||||||
cmd: "dockreap --no-confirmation"
|
|
||||||
when:
|
|
||||||
- run_once_sys_ctl_cln_anon_volumes is not defined
|
|
||||||
- docker_bin.stat.exists
|
|
||||||
|
|
||||||
- name: mark dockreap as run
|
|
||||||
set_fact:
|
|
||||||
run_once_sys_ctl_cln_anon_volumes: true
|
|
||||||
when:
|
|
||||||
- run_once_sys_ctl_cln_anon_volumes is not defined
|
|
||||||
- docker_bin.stat.exists
|
|
@@ -1,5 +0,0 @@
|
|||||||
- name: "reload sys-ctl-cln-backups service"
|
|
||||||
systemd:
|
|
||||||
name: sys-ctl-cln-backups{{ SYS_SERVICE_SUFFIX }}
|
|
||||||
enabled: yes
|
|
||||||
daemon_reload: yes
|
|
@@ -5,7 +5,6 @@
|
|||||||
- dev-python-pip
|
- dev-python-pip
|
||||||
- sys-ctl-alm-compose
|
- sys-ctl-alm-compose
|
||||||
- sys-lock
|
- sys-lock
|
||||||
- sys-rst-daemon
|
|
||||||
|
|
||||||
- name: install lsof and python-psutil
|
- name: install lsof and python-psutil
|
||||||
community.general.pacman:
|
community.general.pacman:
|
||||||
@@ -14,19 +13,5 @@
|
|||||||
- python-psutil
|
- python-psutil
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: "create {{cleanup_backups_directory}}"
|
- include_role:
|
||||||
file:
|
name: sys-systemctl
|
||||||
path: "{{cleanup_backups_directory}}"
|
|
||||||
state: directory
|
|
||||||
mode: "0755"
|
|
||||||
|
|
||||||
- name: create sys-ctl-cln-backups.py
|
|
||||||
copy:
|
|
||||||
src: "sys-ctl-cln-backups.py"
|
|
||||||
dest: "{{cleanup_backups_directory}}sys-ctl-cln-backups.py"
|
|
||||||
|
|
||||||
- name: create sys-ctl-cln-backups{{ SYS_SERVICE_SUFFIX }}
|
|
||||||
template:
|
|
||||||
src: "sys-ctl-cln-backups.service.j2"
|
|
||||||
dest: "/etc/systemd/system/sys-ctl-cln-backups{{ SYS_SERVICE_SUFFIX }}"
|
|
||||||
notify: reload sys-ctl-cln-backups service
|
|
@@ -1,8 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=delete old backups
|
|
||||||
OnFailure=sys-ctl-alm-compose.{{ SOFTWARE_NAME }}@%n.service
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=oneshot
|
|
||||||
ExecStartPre=/bin/sh -c '/usr/bin/python {{ PATH_SYSTEM_LOCK_SCRIPT }} {{ SYS_SERVICE_GROUP_MANIPULATION | join(' ') }} --ignore {{SYS_SERVICE_GROUP_CLEANUP| join(' ') }} --timeout "{{ SYS_TIMEOUT_BACKUP_SERVICES }}"'
|
|
||||||
ExecStart=/bin/sh -c '/usr/bin/python {{cleanup_backups_directory}}sys-ctl-cln-backups.py --backups-folder-path {{backups_folder_path}} --maximum-backup-size-percent {{size_percent_maximum_backup}}'
|
|
8
roles/sys-ctl-cln-bkps/templates/systemctl.service.j2
Normal file
8
roles/sys-ctl-cln-bkps/templates/systemctl.service.j2
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=delete old backups
|
||||||
|
OnFailure={{ SYS_SERVICE_ON_FAILURE_COMPOSE }}
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStartPre=/bin/sh -c '/usr/bin/python {{ PATH_SYSTEM_LOCK_SCRIPT }} {{ SYS_SERVICE_GROUP_MANIPULATION | join(' ') }} --ignore {{ SYS_SERVICE_GROUP_CLEANUP| join(' ') }} --timeout "{{ SYS_TIMEOUT_BACKUP_SERVICES }}"'
|
||||||
|
ExecStart=/bin/sh -c '/usr/bin/python {{ systemctl_id | get_service_script_path('sh') }} --backups-folder-path {{ BACKUPS_FOLDER_PATH }} --maximum-backup-size-percent {{SIZE_PERCENT_MAXIMUM_BACKUP}}'
|
@@ -1,2 +1 @@
|
|||||||
cleanup_backups_directory: '{{ PATH_ADMINISTRATOR_SCRIPTS }}sys-ctl-cln-backups/'
|
systemctl_id: "sys-ctl-cln-bkps"
|
||||||
|
|
||||||
|
@@ -7,7 +7,7 @@ This Ansible role automates the detection, revocation and deletion of unused Let
|
|||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
- Installs the `certreap` cleanup tool using the `pkgmgr-install` role
|
- Installs the `certreap` cleanup tool using the `pkgmgr-install` role
|
||||||
- Deploys and configures a `sys-ctl-cln-certs{{ SYS_SERVICE_SUFFIX }}` systemd unit
|
- Deploys and configures a systemd unit
|
||||||
- (Optionally) Sets up a recurring cleanup via a systemd timer using the `sys-timer` role
|
- (Optionally) Sets up a recurring cleanup via a systemd timer using the `sys-timer` role
|
||||||
- Integrates with `sys-ctl-alm-compose` to send failure notifications
|
- Integrates with `sys-ctl-alm-compose` to send failure notifications
|
||||||
- Ensures idempotent execution with a `run_once_sys_ctl_cln_certs` flag
|
- Ensures idempotent execution with a `run_once_sys_ctl_cln_certs` flag
|
||||||
@@ -18,7 +18,7 @@ This Ansible role automates the detection, revocation and deletion of unused Let
|
|||||||
Uses `pkgmgr-install` to install the `certreap` binary.
|
Uses `pkgmgr-install` to install the `certreap` binary.
|
||||||
|
|
||||||
- **Systemd Service Configuration**
|
- **Systemd Service Configuration**
|
||||||
Deploys `sys-ctl-cln-certs{{ SYS_SERVICE_SUFFIX }}` and reloads/restarts it on changes.
|
Deploys service and reloads/restarts it on changes.
|
||||||
|
|
||||||
- **Systemd Timer Scheduling**
|
- **Systemd Timer Scheduling**
|
||||||
Optionally wires in a timer via the `sys-timer` role, controlled by the `on_calendar_cleanup_certs` variable.
|
Optionally wires in a timer via the `sys-timer` role, controlled by the `on_calendar_cleanup_certs` variable.
|
||||||
@@ -27,7 +27,7 @@ This Ansible role automates the detection, revocation and deletion of unused Let
|
|||||||
Prevents multiple runs in one play by setting a `run_once_sys_ctl_cln_certs` fact.
|
Prevents multiple runs in one play by setting a `run_once_sys_ctl_cln_certs` fact.
|
||||||
|
|
||||||
- **Failure Notification**
|
- **Failure Notification**
|
||||||
Triggers `sys-ctl-alm-compose.infinito@sys-ctl-cln-certs{{ SYS_SERVICE_SUFFIX }}` on failure.
|
Triggers service on failure.
|
||||||
|
|
||||||
## Further Resources
|
## Further Resources
|
||||||
|
|
||||||
|
@@ -1,6 +0,0 @@
|
|||||||
- name: "Reload and restart sys-ctl-cln-certs service"
|
|
||||||
systemd:
|
|
||||||
name: sys-ctl-cln-certs{{ SYS_SERVICE_SUFFIX }}
|
|
||||||
enabled: yes
|
|
||||||
daemon_reload: yes
|
|
||||||
state: restarted
|
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user