Migrate to nodes directory and make bwfiles base configurable
This commit is contained in:
77
nodes.py
77
nodes.py
@@ -1,6 +1,16 @@
|
||||
bws = libs.bwsops.BwSops("secrets.json")
|
||||
from bundlewrap.utils import error_context
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
uberspaceify = libs.uberspace.Uberspaceify()
|
||||
|
||||
# Lookup other nodes from different path
|
||||
bwfiles_base_path = Path(os.environ.get("BWFILES_BASE_PATH", ".")).absolute()
|
||||
bwfiles_nodes_dir_path = bwfiles_base_path / "nodes"
|
||||
bwfiles_secrets_file_path = bwfiles_base_path / "secrets.json"
|
||||
|
||||
bws = libs.bwsops.BwSops(bwfiles_secrets_file_path)
|
||||
|
||||
def generate_default_repos(node_name, username):
|
||||
return {
|
||||
"main-cyan": {
|
||||
@@ -31,64 +41,7 @@ def generate_default_repos(node_name, username):
|
||||
},
|
||||
}
|
||||
|
||||
nodes = uberspaceify.nodes({
|
||||
"clerie.uber.space": {
|
||||
"bundles": (
|
||||
"uberspace-redirect-clerie",
|
||||
"uberspace-clerie-backup",
|
||||
"uberspace-clerie-monitoring",
|
||||
"uberspace-crontab-dir",
|
||||
"uberspace-supervisord",
|
||||
),
|
||||
"metadata": {
|
||||
"clerie-backup": {
|
||||
"repos": generate_default_repos("clerie.uber.space", "clerie"),
|
||||
},
|
||||
"cron": {
|
||||
"jobs": {
|
||||
"backup_main-cyan": "42 */2 * * * clerie-backup main-cyan backup && clerie-backup-update-monitoring main cyan",
|
||||
"backup_main-cyan_mysql": "52 */2 * * * clerie-backup main-cyan restic backup --stdin-filename mysql-databases.sql --stdin-from-command -- mysqldump --all-databases && clerie-backup-update-monitoring main_mysql cyan",
|
||||
"backup_main-magenta": "13 */2 * * * clerie-backup main-magenta backup && clerie-backup-update-monitoring main magenta",
|
||||
"backup_main-magenta_mysql": "23 */2 * * * clerie-backup main-magenta restic backup --stdin-filename mysql-databases.sql --stdin-from-command -- mysqldump --all-databases && clerie-backup-update-monitoring main_mysql magenta",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
"cleriewi.uber.space": {
|
||||
"bundles": (
|
||||
"uberspace-redirect-clerie",
|
||||
"uberspace-clerie-backup",
|
||||
"uberspace-clerie-monitoring",
|
||||
"uberspace-crontab-dir",
|
||||
"uberspace-supervisord",
|
||||
),
|
||||
"metadata": {
|
||||
"clerie-backup": {
|
||||
"repos": generate_default_repos("cleriewi.uber.space", "cleriewi"),
|
||||
},
|
||||
"cron": {
|
||||
"jobs": {
|
||||
"backup_main-cyan": "42 */2 * * * clerie-backup main-cyan backup && clerie-backup-update-monitoring main cyan",
|
||||
"backup_main-magenta": "13 */2 * * * clerie-backup main-magenta backup && clerie-backup-update-monitoring main magenta",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
nodes.update({
|
||||
"mercury.net.clerie.de": {
|
||||
"username": "root",
|
||||
"bundles": (
|
||||
"systemd",
|
||||
"debian-user-clerie",
|
||||
"debian-clerie-monitoring",
|
||||
),
|
||||
"metadata": {
|
||||
"clerie-monitoring": {
|
||||
"id": 401,
|
||||
"private-key": bws.get(["mercury.net.clerie.de", "wg-monitoring"]),
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
for node_file in sorted(node_file.absolute() for node_file in bwfiles_nodes_dir_path.iterdir() if node_file.is_file() and node_file.suffix == ".py"):
|
||||
with error_context(filename=str(node_file)):
|
||||
with node_file.open() as f:
|
||||
exec(f.read())
|
||||
|
||||
24
nodes/clerie.uber.space.py
Normal file
24
nodes/clerie.uber.space.py
Normal file
@@ -0,0 +1,24 @@
|
||||
nodes.update(uberspaceify.nodes({
|
||||
"clerie.uber.space": {
|
||||
"bundles": (
|
||||
"uberspace-redirect-clerie",
|
||||
"uberspace-clerie-backup",
|
||||
"uberspace-clerie-monitoring",
|
||||
"uberspace-crontab-dir",
|
||||
"uberspace-supervisord",
|
||||
),
|
||||
"metadata": {
|
||||
"clerie-backup": {
|
||||
"repos": generate_default_repos("clerie.uber.space", "clerie"),
|
||||
},
|
||||
"cron": {
|
||||
"jobs": {
|
||||
"backup_main-cyan": "42 */2 * * * clerie-backup main-cyan backup && clerie-backup-update-monitoring main cyan",
|
||||
"backup_main-cyan_mysql": "52 */2 * * * clerie-backup main-cyan restic backup --stdin-filename mysql-databases.sql --stdin-from-command -- mysqldump --all-databases && clerie-backup-update-monitoring main_mysql cyan",
|
||||
"backup_main-magenta": "13 */2 * * * clerie-backup main-magenta backup && clerie-backup-update-monitoring main magenta",
|
||||
"backup_main-magenta_mysql": "23 */2 * * * clerie-backup main-magenta restic backup --stdin-filename mysql-databases.sql --stdin-from-command -- mysqldump --all-databases && clerie-backup-update-monitoring main_mysql magenta",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}))
|
||||
22
nodes/cleriewi.uber.space.py
Normal file
22
nodes/cleriewi.uber.space.py
Normal file
@@ -0,0 +1,22 @@
|
||||
nodes.update(uberspaceify.nodes({
|
||||
"cleriewi.uber.space": {
|
||||
"bundles": (
|
||||
"uberspace-redirect-clerie",
|
||||
"uberspace-clerie-backup",
|
||||
"uberspace-clerie-monitoring",
|
||||
"uberspace-crontab-dir",
|
||||
"uberspace-supervisord",
|
||||
),
|
||||
"metadata": {
|
||||
"clerie-backup": {
|
||||
"repos": generate_default_repos("cleriewi.uber.space", "cleriewi"),
|
||||
},
|
||||
"cron": {
|
||||
"jobs": {
|
||||
"backup_main-cyan": "42 */2 * * * clerie-backup main-cyan backup && clerie-backup-update-monitoring main cyan",
|
||||
"backup_main-magenta": "13 */2 * * * clerie-backup main-magenta backup && clerie-backup-update-monitoring main magenta",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}))
|
||||
16
nodes/mercury.net.clerie.de.py
Normal file
16
nodes/mercury.net.clerie.de.py
Normal file
@@ -0,0 +1,16 @@
|
||||
nodes.update({
|
||||
"mercury.net.clerie.de": {
|
||||
"username": "root",
|
||||
"bundles": (
|
||||
"systemd",
|
||||
"debian-user-clerie",
|
||||
"debian-clerie-monitoring",
|
||||
),
|
||||
"metadata": {
|
||||
"clerie-monitoring": {
|
||||
"id": 401,
|
||||
"private-key": bws.get(["mercury.net.clerie.de", "wg-monitoring"]),
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user