ConfigLMM 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +34 -0
- data/CNAME +1 -0
- data/Examples/.lmm.state.yaml +159 -0
- data/Examples/ConfigLMM.mm.yaml +32 -0
- data/Examples/Implemented.mm.yaml +252 -4
- data/Examples/SmallBusiness.mm.yaml +492 -0
- data/Plugins/Apps/Answer/answer.lmm.rb +165 -0
- data/Plugins/Apps/Answer/answer@.service +40 -0
- data/Plugins/Apps/ArchiSteamFarm/ArchiSteamFarm.conf.erb +0 -3
- data/Plugins/Apps/ArchiSteamFarm/ArchiSteamFarm.lmm.rb +0 -1
- data/Plugins/Apps/Authentik/Authentik-ProxyOutpost.container +7 -1
- data/Plugins/Apps/Authentik/Authentik-Server.container +6 -1
- data/Plugins/Apps/Authentik/Authentik-Worker.container +6 -1
- data/Plugins/Apps/Authentik/Authentik.conf.erb +12 -7
- data/Plugins/Apps/Authentik/Authentik.lmm.rb +226 -61
- data/Plugins/Apps/BookStack/BookStack.conf.erb +0 -3
- data/Plugins/Apps/BookStack/BookStack.container +5 -0
- data/Plugins/Apps/BookStack/BookStack.lmm.rb +14 -3
- data/Plugins/Apps/Cassandra/Cassandra.lmm.rb +9 -19
- data/Plugins/Apps/ClickHouse/ClickHouse.container +28 -0
- data/Plugins/Apps/ClickHouse/ClickHouse.lmm.rb +113 -0
- data/Plugins/Apps/ClickHouse/Config/listen.yaml +2 -0
- data/Plugins/Apps/ClickHouse/Config/logger.yaml +8 -0
- data/Plugins/Apps/ClickHouse/Config/zookeepers.yaml +5 -0
- data/Plugins/Apps/ClickHouse/Connection.rb +96 -0
- data/Plugins/Apps/Discourse/Discourse-Sidekiq.container +5 -0
- data/Plugins/Apps/Discourse/Discourse.conf.erb +1 -4
- data/Plugins/Apps/Discourse/Discourse.container +4 -0
- data/Plugins/Apps/Discourse/Discourse.lmm.rb +116 -55
- data/Plugins/Apps/Dovecot/Dovecot.lmm.rb +74 -62
- data/Plugins/Apps/ERPNext/ERPNext-Frontend.container +6 -1
- data/Plugins/Apps/ERPNext/ERPNext-Queue.container +5 -0
- data/Plugins/Apps/ERPNext/ERPNext-Scheduler.container +5 -0
- data/Plugins/Apps/ERPNext/ERPNext-Websocket.container +6 -1
- data/Plugins/Apps/ERPNext/ERPNext.container +6 -1
- data/Plugins/Apps/ERPNext/ERPNext.lmm.rb +138 -127
- data/Plugins/Apps/GitLab/GitLab.container +6 -0
- data/Plugins/Apps/GitLab/GitLab.lmm.rb +43 -49
- data/Plugins/Apps/Homepage/Homepage.conf.erb +86 -0
- data/Plugins/Apps/Homepage/Homepage.container +19 -0
- data/Plugins/Apps/Homepage/Homepage.lmm.rb +54 -0
- data/Plugins/Apps/IPFS/IPFS.conf.erb +0 -3
- data/Plugins/Apps/IPFS/IPFS.lmm.rb +0 -1
- data/Plugins/Apps/InfluxDB/InfluxDB.conf.erb +0 -3
- data/Plugins/Apps/InfluxDB/InfluxDB.lmm.rb +0 -1
- data/Plugins/Apps/Jackett/Jackett.conf.erb +0 -3
- data/Plugins/Apps/Jackett/Jackett.lmm.rb +0 -1
- data/Plugins/Apps/Jellyfin/Jellyfin.conf.erb +0 -3
- data/Plugins/Apps/Jellyfin/Jellyfin.lmm.rb +0 -1
- data/Plugins/Apps/LetsEncrypt/LetsEncrypt.lmm.rb +49 -28
- data/Plugins/Apps/LibreTranslate/LibreTranslate.container +21 -0
- data/Plugins/Apps/LibreTranslate/LibreTranslate.lmm.rb +34 -0
- data/Plugins/Apps/Lobsters/Containerfile +81 -0
- data/Plugins/Apps/Lobsters/Lobsters-Tasks.container +26 -0
- data/Plugins/Apps/Lobsters/Lobsters.conf.erb +99 -0
- data/Plugins/Apps/Lobsters/Lobsters.container +27 -0
- data/Plugins/Apps/Lobsters/Lobsters.lmm.rb +196 -0
- data/Plugins/Apps/Lobsters/crontab +3 -0
- data/Plugins/Apps/Lobsters/database.yml +26 -0
- data/Plugins/Apps/Lobsters/entrypoint.sh +30 -0
- data/Plugins/Apps/Lobsters/generateCredentials.rb +19 -0
- data/Plugins/Apps/Lobsters/lobsters-cron.sh +25 -0
- data/Plugins/Apps/Lobsters/lobsters-daily.sh +23 -0
- data/Plugins/Apps/Lobsters/puma.rb +49 -0
- data/Plugins/Apps/MariaDB/Connection.rb +55 -0
- data/Plugins/Apps/MariaDB/MariaDB.lmm.rb +60 -53
- data/Plugins/Apps/Mastodon/Mastodon-Sidekiq.container +22 -0
- data/Plugins/Apps/Mastodon/Mastodon-Streaming.container +20 -0
- data/Plugins/Apps/Mastodon/Mastodon.conf.erb +34 -45
- data/Plugins/Apps/Mastodon/Mastodon.container +28 -0
- data/Plugins/Apps/Mastodon/Mastodon.lmm.rb +240 -5
- data/Plugins/Apps/Mastodon/configlmm.rake +30 -0
- data/Plugins/Apps/Mastodon/entrypoint.sh +16 -0
- data/Plugins/Apps/Matrix/Element.container +5 -0
- data/Plugins/Apps/Matrix/Matrix.conf.erb +2 -8
- data/Plugins/Apps/Matrix/Matrix.lmm.rb +100 -71
- data/Plugins/Apps/Matrix/Synapse.container +5 -0
- data/Plugins/Apps/Netdata/Netdata.conf.erb +0 -3
- data/Plugins/Apps/Netdata/Netdata.lmm.rb +0 -1
- data/Plugins/Apps/Nextcloud/Nextcloud.conf.erb +3 -4
- data/Plugins/Apps/Nextcloud/Nextcloud.lmm.rb +150 -68
- data/Plugins/Apps/Nextcloud/autoconfig.php +13 -0
- data/Plugins/Apps/Nextcloud/config.php +10 -1
- data/Plugins/Apps/Nextcloud/nextcloudcron.service +8 -0
- data/Plugins/Apps/Nextcloud/nextcloudcron.timer +10 -0
- data/Plugins/Apps/Nginx/Connection.rb +93 -0
- data/Plugins/Apps/Nginx/conf.d/configlmm.conf +50 -9
- data/Plugins/Apps/Nginx/conf.d/languages.conf +21 -0
- data/Plugins/Apps/Nginx/config-lmm/errors.conf +25 -20
- data/Plugins/Apps/Nginx/config-lmm/gateway-errors.conf +20 -0
- data/Plugins/Apps/Nginx/config-lmm/proxy.conf +1 -1
- data/Plugins/Apps/Nginx/main.conf.erb +7 -3
- data/Plugins/Apps/Nginx/nginx.conf +2 -2
- data/Plugins/Apps/Nginx/nginx.lmm.rb +99 -81
- data/Plugins/Apps/Nginx/proxy.conf.erb +11 -3
- data/Plugins/Apps/Odoo/Odoo.conf.erb +0 -3
- data/Plugins/Apps/Odoo/Odoo.container +5 -0
- data/Plugins/Apps/Odoo/Odoo.lmm.rb +4 -5
- data/Plugins/Apps/Ollama/Ollama.container +26 -0
- data/Plugins/Apps/Ollama/Ollama.lmm.rb +73 -0
- data/Plugins/Apps/OpenTelemetry/Config/config.yaml +704 -0
- data/Plugins/Apps/OpenTelemetry/OpenTelemetry.lmm.rb +154 -0
- data/Plugins/Apps/OpenVidu/Ingress.container +5 -0
- data/Plugins/Apps/OpenVidu/OpenVidu.conf.erb +0 -3
- data/Plugins/Apps/OpenVidu/OpenVidu.container +5 -0
- data/Plugins/Apps/OpenVidu/OpenVidu.lmm.rb +7 -3
- data/Plugins/Apps/OpenVidu/OpenViduCall.conf.erb +0 -3
- data/Plugins/Apps/OpenVidu/OpenViduCall.container +5 -0
- data/Plugins/Apps/PHP-FPM/Connection.rb +91 -0
- data/Plugins/Apps/PHP-FPM/PHP-FPM.lmm.rb +31 -4
- data/Plugins/Apps/Peppermint/Peppermint.conf.erb +2 -5
- data/Plugins/Apps/Peppermint/Peppermint.container +5 -0
- data/Plugins/Apps/Peppermint/Peppermint.lmm.rb +29 -33
- data/Plugins/Apps/Perplexica/Perplexica.container +25 -0
- data/Plugins/Apps/Perplexica/Perplexica.lmm.rb +92 -0
- data/Plugins/Apps/Perplexica/config.toml +26 -0
- data/Plugins/Apps/Podman/Connection.rb +24 -0
- data/Plugins/Apps/Podman/Podman.lmm.rb +80 -0
- data/Plugins/Apps/Podman/storage.conf +6 -0
- data/Plugins/Apps/Postfix/Postfix.lmm.rb +242 -164
- data/Plugins/Apps/PostgreSQL/Connection.rb +97 -0
- data/Plugins/Apps/PostgreSQL/PostgreSQL.lmm.rb +184 -148
- data/Plugins/Apps/Pterodactyl/Pterodactyl.conf.erb +0 -3
- data/Plugins/Apps/Pterodactyl/Pterodactyl.lmm.rb +0 -2
- data/Plugins/Apps/Pterodactyl/Wings.conf.erb +0 -3
- data/Plugins/Apps/RVM/RVM.lmm.rb +57 -0
- data/Plugins/Apps/Roundcube/Roundcube.conf.erb +0 -3
- data/Plugins/Apps/Roundcube/Roundcube.lmm.rb +15 -19
- data/Plugins/Apps/SSH/SSH.lmm.rb +9 -15
- data/Plugins/Apps/SearXNG/SearXNG.container +22 -0
- data/Plugins/Apps/SearXNG/SearXNG.lmm.rb +79 -0
- data/Plugins/Apps/SearXNG/limiter.toml +40 -0
- data/Plugins/Apps/SearXNG/settings.yml +2 -0
- data/Plugins/Apps/SigNoz/Config/alerts.yml +11 -0
- data/Plugins/Apps/SigNoz/Config/otel-collector-config.yaml +110 -0
- data/Plugins/Apps/SigNoz/Config/otel-collector-opamp-config.yaml +1 -0
- data/Plugins/Apps/SigNoz/Config/prometheus.yml +18 -0
- data/Plugins/Apps/SigNoz/SigNoz-Collector.container +23 -0
- data/Plugins/Apps/SigNoz/SigNoz-Migrator.container +17 -0
- data/Plugins/Apps/SigNoz/SigNoz.conf.erb +61 -0
- data/Plugins/Apps/SigNoz/SigNoz.container +26 -0
- data/Plugins/Apps/SigNoz/SigNoz.lmm.rb +319 -0
- data/Plugins/Apps/Solr/log4j2.xml +89 -0
- data/Plugins/Apps/Solr/solr.lmm.rb +82 -0
- data/Plugins/Apps/Sunshine/Sunshine.conf.erb +0 -3
- data/Plugins/Apps/Sunshine/Sunshine.lmm.rb +0 -1
- data/Plugins/Apps/Tunnel/tunnel.lmm.rb +33 -37
- data/Plugins/Apps/UVdesk/UVdesk.conf.erb +0 -3
- data/Plugins/Apps/Umami/Umami.container +19 -0
- data/Plugins/Apps/Umami/Umami.lmm.rb +108 -0
- data/Plugins/Apps/Valkey/Valkey.lmm.rb +54 -42
- data/Plugins/Apps/Vaultwarden/Vaultwarden.conf.erb +9 -6
- data/Plugins/Apps/Vaultwarden/Vaultwarden.container +7 -1
- data/Plugins/Apps/Vaultwarden/Vaultwarden.lmm.rb +64 -29
- data/Plugins/Apps/Wiki.js/Wiki.js.conf.erb +1 -4
- data/Plugins/Apps/Wiki.js/Wiki.js.container +5 -0
- data/Plugins/Apps/Wiki.js/Wiki.js.lmm.rb +31 -37
- data/Plugins/Apps/YaCy/YaCy.conf.erb +93 -0
- data/Plugins/Apps/YaCy/YaCy.container +21 -0
- data/Plugins/Apps/YaCy/YaCy.lmm.rb +160 -0
- data/Plugins/Apps/ZooKeeper/ZooKeeper.container +24 -0
- data/Plugins/Apps/ZooKeeper/ZooKeeper.lmm.rb +68 -0
- data/Plugins/Apps/bitmagnet/bitmagnet.conf.erb +0 -3
- data/Plugins/Apps/bitmagnet/bitmagnet.lmm.rb +0 -1
- data/Plugins/Apps/gollum/gollum.conf.erb +2 -4
- data/Plugins/Apps/gollum/gollum.container +6 -0
- data/Plugins/Apps/gollum/gollum.lmm.rb +51 -50
- data/Plugins/Apps/llama.cpp/llama.cpp.container +28 -0
- data/Plugins/Apps/llama.cpp/llama.cpp.lmm.rb +90 -0
- data/Plugins/Apps/vLLM/vLLM.container +32 -0
- data/Plugins/Apps/vLLM/vLLM.lmm.rb +89 -0
- data/Plugins/OS/General/Utils.lmm.rb +26 -0
- data/Plugins/OS/Linux/Connection.rb +472 -0
- data/Plugins/OS/Linux/Debian/preseed.cfg.erb +25 -6
- data/Plugins/OS/Linux/Flavours.yaml +13 -0
- data/Plugins/OS/Linux/Grub/grub.cfg +10 -0
- data/Plugins/OS/Linux/HTTP.rb +32 -0
- data/Plugins/OS/Linux/Linux.lmm.rb +533 -187
- data/Plugins/OS/Linux/Packages.yaml +20 -1
- data/Plugins/OS/Linux/Services.yaml +8 -0
- data/Plugins/OS/Linux/Shell.rb +70 -0
- data/Plugins/OS/Linux/Syslinux/default +8 -0
- data/Plugins/OS/Linux/WireGuard/WireGuard.lmm.rb +83 -59
- data/Plugins/OS/Linux/WireGuard/wg0.conf.erb +3 -0
- data/Plugins/OS/Linux/openSUSE/autoinst.xml.erb +29 -3
- data/Plugins/OS/Linux/systemd/systemd.lmm.rb +13 -11
- data/Plugins/OS/Routers/Aruba/ArubaInstant.lmm.rb +6 -5
- data/Plugins/Platforms/GitHub.lmm.rb +73 -28
- data/Plugins/Platforms/GoDaddy/GoDaddy.lmm.rb +9 -6
- data/Plugins/Platforms/Proxmox/Proxmox.lmm.rb +402 -0
- data/Plugins/Platforms/Proxmox/XTerm.rb +321 -0
- data/Plugins/Platforms/libvirt/libvirt.lmm.rb +38 -13
- data/Plugins/Platforms/porkbun.lmm.rb +12 -2
- data/Plugins/Platforms/porkbun_spec.rb +2 -2
- data/Plugins/Services/DNS/AmberBit.lmm.rb +1 -1
- data/Plugins/Services/DNS/ArubaItDNS.lmm.rb +1 -1
- data/Plugins/Services/DNS/NICLV.lmm.rb +1 -1
- data/Plugins/Services/DNS/PowerDNS.lmm.rb +70 -68
- data/Plugins/Services/DNS/tonic.lmm.rb +22 -12
- data/lib/ConfigLMM/Framework/plugins/dns.rb +4 -3
- data/lib/ConfigLMM/Framework/plugins/linuxApp.rb +145 -184
- data/lib/ConfigLMM/Framework/plugins/nginxApp.rb +34 -17
- data/lib/ConfigLMM/Framework/plugins/plugin.rb +53 -181
- data/lib/ConfigLMM/Framework/plugins/store.rb +4 -4
- data/lib/ConfigLMM/Framework/variables.rb +75 -0
- data/lib/ConfigLMM/Framework.rb +1 -0
- data/lib/ConfigLMM/cli.rb +12 -6
- data/lib/ConfigLMM/commands/configsCommand.rb +37 -6
- data/lib/ConfigLMM/commands/diff.rb +33 -9
- data/lib/ConfigLMM/context.rb +22 -3
- data/lib/ConfigLMM/io/configList.rb +82 -6
- data/lib/ConfigLMM/io/connection.rb +143 -0
- data/lib/ConfigLMM/io/dhcp.rb +330 -0
- data/lib/ConfigLMM/io/http.rb +78 -0
- data/lib/ConfigLMM/io/local.rb +207 -0
- data/lib/ConfigLMM/io/pxe.rb +92 -0
- data/lib/ConfigLMM/io/ssh.rb +156 -0
- data/lib/ConfigLMM/io/tftp.rb +105 -0
- data/lib/ConfigLMM/io.rb +2 -0
- data/lib/ConfigLMM/secrets/envStore.rb +39 -0
- data/lib/ConfigLMM/secrets/fileStore.rb +43 -0
- data/lib/ConfigLMM/state.rb +2 -1
- data/lib/ConfigLMM/version.rb +2 -1
- data/lib/ConfigLMM.rb +1 -0
- data/{Examples → scripts}/configlmmAuth.sh +7 -5
- metadata +205 -8
@@ -0,0 +1,108 @@
|
|
1
|
+
|
2
|
+
module ConfigLMM
|
3
|
+
module LMM
|
4
|
+
class Umami < Framework::Plugin
|
5
|
+
|
6
|
+
USER = 'umami'
|
7
|
+
HOME_DIR = '/var/lib/umami'
|
8
|
+
HOST_IP = '10.0.2.2'
|
9
|
+
|
10
|
+
def actionUmamiDeploy(id, target, activeState, context, options)
|
11
|
+
raise Framework::PluginProcessError.new('Domain field must be set!') if (!target.key?('Proxy') || target['Proxy']) && !target['Domain']
|
12
|
+
|
13
|
+
self.withConnection(target['Location'], target) do |connection|
|
14
|
+
Linux.withConnection(connection) do |linuxConnection|
|
15
|
+
if !target.key?('Proxy') || target['Proxy'] == false
|
16
|
+
dbUser, dbPassword = self.configurePostgreSQL(target, linuxConnection, context, options)
|
17
|
+
Podman.ensurePresent(linuxConnection, options)
|
18
|
+
Podman.createUser(USER, HOME_DIR, 'Umami', linuxConnection, options)
|
19
|
+
|
20
|
+
path = Podman.containersPath(HOME_DIR)
|
21
|
+
|
22
|
+
dbHost = target['Database']['HostName']
|
23
|
+
dbPort = target['Database']['Port']
|
24
|
+
linuxConnection.fileWrite("#{path}/Umami.env", "DATABASE_URL=postgresql://#{dbUser}:#{dbPassword}@#{dbHost}:#{dbPort}/#{dbUser}", { **options, hide: true })
|
25
|
+
|
26
|
+
linuxConnection.setUserGroup("#{path}/Umami.env", USER, USER, options)
|
27
|
+
linuxConnection.setPrivate("#{path}/Umami.env", options)
|
28
|
+
|
29
|
+
linuxConnection.upload(__dir__ + '/Umami.container', path, options)
|
30
|
+
end
|
31
|
+
|
32
|
+
if !target.key?('Proxy') || target['Proxy']
|
33
|
+
Nginx.withConnection(linuxConnection) do |nginxConnection|
|
34
|
+
nginxConnection.provisionProxy('http://127.0.0.1:13300', 'Umami', target, activeState, context, options)
|
35
|
+
end
|
36
|
+
elsif target.key?('Proxy') && target['Proxy'] == false
|
37
|
+
linuxConnection.fileReplace("#{path}/Umami.container", 'PublishPort=127.0.0.1:13300:', 'PublishPort=0.0.0.0:13300:', options)
|
38
|
+
linuxConnection.firewallAddPort('13300/tcp', options)
|
39
|
+
end
|
40
|
+
|
41
|
+
if !target.key?('Proxy') || target['Proxy'] == false
|
42
|
+
linuxConnection.reloadUserServices(USER, options)
|
43
|
+
linuxConnection.restartUserService(USER, 'Umami', options)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def configurePostgreSQL(target, linuxConnection, context, options)
|
50
|
+
target['Database'] ||= {}
|
51
|
+
target['Database']['Type'] = 'pgsql'
|
52
|
+
PostgreSQL.defaults(target['Database'])
|
53
|
+
username = target['Database']['Username'] || context.secrets.load(target['SecretId'], 'POSTGRESQL_USERNAME') || USER
|
54
|
+
context.secrets.store(target['SecretId'], 'POSTGRESQL_USERNAME', username)
|
55
|
+
password = context.secrets.load(target['SecretId'], 'POSTGRESQL_PASSWORD')
|
56
|
+
if password.nil?
|
57
|
+
password = SecureRandom.alphanumeric(20)
|
58
|
+
context.secrets.store(target['SecretId'], 'POSTGRESQL_PASSWORD', password)
|
59
|
+
end
|
60
|
+
PostgreSQL.withConnection(target['Database'], linuxConnection) do |postgres|
|
61
|
+
postgres.createUserAndDB(username, password, options)
|
62
|
+
end
|
63
|
+
if target['Database']['HostName'] == 'localhost'
|
64
|
+
target['Database']['HostName'] = HOST_IP
|
65
|
+
end
|
66
|
+
[username, password]
|
67
|
+
end
|
68
|
+
|
69
|
+
def cleanup(configs, state, context, options)
|
70
|
+
cleanupType(:Umami, configs, state, context, options) do |item, id, state, context, options, connection|
|
71
|
+
Linux.withConnection(connection) do |linuxConnection|
|
72
|
+
if !item['Config'].key?('Proxy') || item['Config']['Proxy']
|
73
|
+
Nginx.withConnection(linuxConnection) do |nginxConnection|
|
74
|
+
nginxConnection.cleanupConfig('Umami', context, options)
|
75
|
+
nginxConnection.reload(connection, options[:dry])
|
76
|
+
end
|
77
|
+
elsif item['Config'].key?('Proxy') && item['Config']['Proxy'] == false
|
78
|
+
linuxConnection.firewallRemovePort('13300/tcp', connection, options)
|
79
|
+
end
|
80
|
+
|
81
|
+
if !item['Config'].key?('Proxy') || item['Config']['Proxy'] == false
|
82
|
+
linuxConnection.stopUserService(USER, 'Umami', options)
|
83
|
+
|
84
|
+
path = Podman.containersPath(HOME_DIR)
|
85
|
+
linuxConnection.rm(path + '/Umami.container', options[:dry])
|
86
|
+
end
|
87
|
+
|
88
|
+
state.item(id)['Status'] = State::STATUS_DELETED unless options[:dry]
|
89
|
+
|
90
|
+
if options[:destroy]
|
91
|
+
if !item['Config'].key?('Proxy') || item['Config']['Proxy'] == false
|
92
|
+
if item['Config']['Database']['Type'] == 'pgsql'
|
93
|
+
username = context.secrets.load(target['SecretId'], 'POSTGRESQL_USERNAME') || USER
|
94
|
+
PostgreSQL.withConnection(settings, linuxConnection) do |postgres|
|
95
|
+
postgres.dropUserAndDB(item['Config']['Database'], username, options)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
linuxConnection.deleteUserAndGroup(USER, options)
|
99
|
+
end
|
100
|
+
state.item(id)['Status'] = State::STATUS_DESTROYED unless options[:dry]
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'uri'
|
1
2
|
|
2
3
|
module ConfigLMM
|
3
4
|
module LMM
|
@@ -7,16 +8,14 @@ module ConfigLMM
|
|
7
8
|
PID_FILE = '/run/redis/redis.pid'
|
8
9
|
|
9
10
|
def actionValkeyDeploy(id, target, activeState, context, options)
|
10
|
-
self.
|
11
|
+
self.withConnection(target['Location'], target) do |connection|
|
12
|
+
Linux.withConnection(connection) do |linuxConnection|
|
13
|
+
linuxConnection.ensurePackage(PACKAGE_NAME, options)
|
11
14
|
|
12
|
-
|
13
|
-
|
14
|
-
if target['Location'] && target['Location'] != '@me'
|
15
|
-
self.class.sshStart(target['Location']) do |ssh|
|
16
|
-
distroId = self.class.distroID(ssh)
|
17
|
-
if distroId == SUSE_ID
|
15
|
+
serviceName = 'redis'
|
16
|
+
if linuxConnection.distroID == SUSE_ID
|
18
17
|
serviceName = 'redis@redis'
|
19
|
-
|
18
|
+
linuxConnection.exec("touch #{CONFIG_FILE}", false, options)
|
20
19
|
|
21
20
|
target['Settings'] ||= {}
|
22
21
|
target['Settings']['pidfile'] = PID_FILE
|
@@ -24,15 +23,19 @@ module ConfigLMM
|
|
24
23
|
target['Settings']['dir'] = '/var/lib/redis/default/'
|
25
24
|
end
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
target['
|
26
|
+
password = context.secrets.load(target['SecretId'], 'VALKEY_PASSWORD')
|
27
|
+
if password.nil?
|
28
|
+
password = SecureRandom.urlsafe_base64(20)
|
29
|
+
context.secrets.store(target['SecretId'], 'VALKEY_PASSWORD', password)
|
30
|
+
end
|
31
|
+
|
32
|
+
if !password.empty? && password != 'no' && target['Password'] != false
|
33
|
+
target['Settings']['requirepass'] = password
|
31
34
|
end
|
32
35
|
|
33
36
|
if target['Settings']
|
34
37
|
target['Settings']['bind'] = '127.0.0.1' unless target['Settings']['bind']
|
35
|
-
|
38
|
+
linuxConnection.updateFile(CONFIG_FILE, options, false) do |configLines|
|
36
39
|
target['Settings'].each do |name, value|
|
37
40
|
configLines << "#{name} #{value}\n"
|
38
41
|
end
|
@@ -40,48 +43,57 @@ module ConfigLMM
|
|
40
43
|
end
|
41
44
|
end
|
42
45
|
|
43
|
-
|
44
|
-
self.class.exec("chmod 640 #{CONFIG_FILE}", ssh)
|
45
|
-
end
|
46
|
-
else
|
47
|
-
if target['Settings']
|
48
|
-
`touch #{CONFIG_FILE}`
|
49
|
-
updateLocalFile(CONFIG_FILE, options) do |configLines|
|
50
|
-
target['Settings'].each do |name, value|
|
51
|
-
configLines << "#{name} #{value}\n"
|
52
|
-
end
|
53
|
-
configLines
|
54
|
-
end
|
55
|
-
end
|
56
|
-
self.class.exec("chgrp redis #{CONFIG_FILE}", ssh)
|
57
|
-
self.class.exec("chmod 640 #{CONFIG_FILE}", nil)
|
58
|
-
end
|
46
|
+
target['Settings']['requirepass'] = '<REDACTED>' if target['Settings']['requirepass']
|
59
47
|
|
60
|
-
|
61
|
-
|
48
|
+
linuxConnection.setUserGroup(CONFIG_FILE, 'redis', nil, options)
|
49
|
+
linuxConnection.setPrivate(CONFIG_FILE, options)
|
62
50
|
|
63
|
-
|
51
|
+
linuxConnection.ensureServiceAutoStart(serviceName, options)
|
52
|
+
linuxConnection.restartService(serviceName, options)
|
53
|
+
end
|
54
|
+
end
|
64
55
|
end
|
65
56
|
|
66
57
|
def cleanup(configs, state, context, options)
|
67
|
-
cleanupType(:Valkey, configs, state, context, options) do |item, id, state, context, options,
|
68
|
-
|
69
|
-
|
70
|
-
|
58
|
+
cleanupType(:Valkey, configs, state, context, options) do |item, id, state, context, options, connection|
|
59
|
+
Linux.withConnection(connection) do |linuxConnection|
|
60
|
+
serviceName = 'redis'
|
61
|
+
serviceName = 'redis@redis' if linuxConnection.distroID == SUSE_ID
|
71
62
|
|
72
|
-
|
73
|
-
|
63
|
+
linuxConnection.stopService(serviceName, options)
|
64
|
+
linuxConnection.removePackage(PACKAGE_NAME, options)
|
74
65
|
|
75
|
-
|
66
|
+
state.item(id)['Status'] = State::STATUS_DELETED unless options[:dry]
|
76
67
|
|
77
|
-
|
78
|
-
|
68
|
+
if options[:destroy]
|
69
|
+
linuxConnection.rm('/etc/redis', options[:dry])
|
79
70
|
|
80
|
-
|
71
|
+
state.item(id)['Status'] = State::STATUS_DESTROYED unless options[:dry]
|
72
|
+
end
|
81
73
|
end
|
82
74
|
end
|
83
75
|
end
|
84
76
|
|
77
|
+
def self.connectionURL(params)
|
78
|
+
args = { scheme: 'redis', host: params[:host].to_s, path: '/' }
|
79
|
+
args[:scheme] += 's' if params[:ssl]
|
80
|
+
args[:path] += params[:db] if params[:db]
|
81
|
+
|
82
|
+
if args[:host].include?(':')
|
83
|
+
args[:host], args[:port] = args[:host].split(':')
|
84
|
+
end
|
85
|
+
|
86
|
+
userinfo = ''
|
87
|
+
if params[:username]
|
88
|
+
userinfo = URI.encode_uri_component(params[:username])
|
89
|
+
end
|
90
|
+
if params.key?(:password) && !params[:password].nil?
|
91
|
+
userinfo += ':' + URI.encode_uri_component(params[:password])
|
92
|
+
end
|
93
|
+
args[:userinfo] = userinfo unless userinfo.empty?
|
94
|
+
|
95
|
+
URI::Generic.build(args).to_s
|
96
|
+
end
|
85
97
|
end
|
86
98
|
|
87
99
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
upstream
|
2
|
+
upstream <%= config['Name'] %> {
|
3
3
|
<% if config['Server'] %>
|
4
4
|
server <%= config['Server'] %>;
|
5
5
|
<% else %>
|
@@ -38,19 +38,22 @@ server {
|
|
38
38
|
|
39
39
|
server_name <%= config['Domain'] %>;
|
40
40
|
|
41
|
+
<% if config['CertName'] %>
|
42
|
+
ssl_certificate "/etc/letsencrypt/live/<%= config['CertName'] %>/fullchain.pem";
|
43
|
+
ssl_certificate_key "/etc/letsencrypt/live/<%= config['CertName'] %>/privkey.pem";
|
44
|
+
ssl_trusted_certificate "/etc/letsencrypt/live/<%= config['CertName'] %>/chain.pem";
|
45
|
+
<% end %>
|
46
|
+
|
41
47
|
<% if config['Private'] %>
|
42
48
|
include config-lmm/private.conf;
|
43
49
|
<% end %>
|
44
50
|
|
45
|
-
access_log /var/log/nginx/vaultwarden.access.log;
|
46
|
-
error_log /var/log/nginx/vaultwarden.error.log;
|
47
|
-
|
48
51
|
client_max_body_size 200M;
|
49
52
|
|
50
|
-
include config-lmm/errors.conf;
|
53
|
+
include config-lmm/gateway-errors.conf;
|
51
54
|
|
52
55
|
location / {
|
53
|
-
proxy_pass http
|
56
|
+
proxy_pass http://<%= config['Name'] %>;
|
54
57
|
include config-lmm/proxy.conf;
|
55
58
|
}
|
56
59
|
|
@@ -3,7 +3,7 @@ Description=vaultwarden container
|
|
3
3
|
After=local-fs.target
|
4
4
|
|
5
5
|
[Container]
|
6
|
-
|
6
|
+
ContainerName=Vaultwarden
|
7
7
|
Image=ghcr.io/dani-garcia/vaultwarden:latest
|
8
8
|
Exec=/start.sh
|
9
9
|
EnvironmentFile=/var/lib/vaultwarden/.config/containers/systemd/Vaultwarden.env
|
@@ -11,6 +11,12 @@ Network=slirp4netns:allow_host_loopback=true
|
|
11
11
|
PublishPort=0.0.0.0:18000:8000
|
12
12
|
UserNS=keep-id:uid=1000,gid=1000
|
13
13
|
Volume=/var/lib/vaultwarden/data/:/data/
|
14
|
+
LogDriver=journald
|
15
|
+
AutoUpdate=registry
|
16
|
+
|
17
|
+
[Service]
|
18
|
+
TimeoutStartSec=6min
|
19
|
+
Restart=on-failure
|
14
20
|
|
15
21
|
[Install]
|
16
22
|
WantedBy=multi-user.target default.target
|
@@ -1,9 +1,11 @@
|
|
1
1
|
|
2
2
|
require 'fileutils'
|
3
|
+
require 'argon2'
|
4
|
+
require 'securerandom'
|
3
5
|
|
4
6
|
module ConfigLMM
|
5
7
|
module LMM
|
6
|
-
class Vaultwarden < Framework::
|
8
|
+
class Vaultwarden < Framework::Plugin
|
7
9
|
|
8
10
|
NAME = 'Vaultwarden'
|
9
11
|
USER = 'vaultwarden'
|
@@ -11,7 +13,9 @@ module ConfigLMM
|
|
11
13
|
SERVICE_PORT = '18000'
|
12
14
|
|
13
15
|
def actionVaultwardenBuild(id, target, state, context, options)
|
14
|
-
|
16
|
+
Nginx.withConnection(local) do |nginxConnection|
|
17
|
+
nginxConnection.writeConfig(__dir__, NAME, target, state, context, options)
|
18
|
+
end
|
15
19
|
end
|
16
20
|
|
17
21
|
def actionVaultwardenDiff(id, target, activeState, context, options)
|
@@ -19,47 +23,78 @@ module ConfigLMM
|
|
19
23
|
end
|
20
24
|
|
21
25
|
def actionVaultwardenDeploy(id, target, activeState, context, options)
|
22
|
-
|
23
|
-
|
24
|
-
self.class.sshStart(uri) do |ssh|
|
26
|
+
self.withConnection(target['Location'], target) do |connection|
|
27
|
+
Linux.withConnection(connection) do |linuxConnection|
|
25
28
|
if !target.key?('Proxy') || target['Proxy'] != 'only'
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
29
|
+
|
30
|
+
Podman.ensurePresent(linuxConnection, options)
|
31
|
+
Podman.createUser(USER, HOME_DIR, 'Vaultwarden', linuxConnection, options)
|
32
|
+
linuxConnection.withUserShell(USER) do |shell|
|
33
|
+
shell.createDirs(options, '~/data')
|
34
|
+
end
|
35
|
+
|
36
|
+
path = Podman.containersPath(HOME_DIR)
|
37
|
+
linuxConnection.fileWrite("#{path}/Vaultwarden.env", 'ROCKET_PORT=8000', options)
|
31
38
|
if target['Domain']
|
32
|
-
|
39
|
+
linuxConnection.fileAppend("#{path}/Vaultwarden.env", "DOMAIN=https://#{target['Domain']}", options)
|
33
40
|
end
|
34
41
|
target['Signups'] = false unless target['Signups']
|
35
|
-
|
42
|
+
linuxConnection.fileAppend("#{path}/Vaultwarden.env", "SIGNUPS_ALLOWED=#{target['Signups'].to_s}", options)
|
36
43
|
if target.key?('Invitations')
|
37
|
-
|
44
|
+
linuxConnection.fileAppend("#{path}/Vaultwarden.env", "INVITATIONS_ALLOWED=#{target['Invitations'].to_s}", options)
|
38
45
|
end
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
46
|
+
adminToken = context.secrets.load(target['SecretId'], 'VAULTWARDEN_ADMIN_TOKEN')
|
47
|
+
if !adminToken
|
48
|
+
adminToken = SecureRandom.alphanumeric(40)
|
49
|
+
context.secrets.store(target['SecretId'], 'VAULTWARDEN_ADMIN_TOKEN', adminToken)
|
50
|
+
end
|
51
|
+
|
52
|
+
adminTokenHash = Argon2::Password.new(profile: :rfc_9106_low_memory).create(adminToken)
|
53
|
+
linuxConnection.fileAppend("#{path}/Vaultwarden.env", "ADMIN_TOKEN=#{adminTokenHash}", { **options, hide: true })
|
54
|
+
|
55
|
+
|
56
|
+
if target['SMTP']
|
57
|
+
host = target['SMTP']['Host']
|
58
|
+
host = HOST_IP if host.to_s.empty? || ['localhost', '127.0.0.1'].include?(host)
|
59
|
+
|
60
|
+
linuxConnection.fileAppend("#{path}/Vaultwarden.env", "SMTP_HOST=#{host}", options)
|
61
|
+
if target['SMTP']['Port']
|
62
|
+
linuxConnection.fileAppend("#{path}/Vaultwarden.env", "SMTP_PORT=#{target['SMTP']['Port']}", options)
|
63
|
+
end
|
64
|
+
|
65
|
+
raise 'SMTP.FromAddress must be set!' unless target['SMTP']['FromAddress']
|
66
|
+
linuxConnection.fileAppend("#{path}/Vaultwarden.env", "SMTP_FROM=#{target['SMTP']['FromAddress']}", options)
|
67
|
+
|
68
|
+
if target['SMTP']['Username']
|
69
|
+
linuxConnection.fileAppend("#{path}/Vaultwarden.env", "SMTP_USERNAME=#{target['SMTP']['Username']}", options)
|
70
|
+
end
|
71
|
+
|
72
|
+
if target['SMTP']['SecretId']
|
73
|
+
smtpPassword = context.secrets.load(target['SMTP']['SecretId'], target['SMTP']['Username'].upcase + '_PASSWORD')
|
74
|
+
linuxConnection.fileAppend("#{path}/Vaultwarden.env", "SMTP_PASSWORD=#{smtpPassword}", { **options, hide: true })
|
75
|
+
end
|
76
|
+
|
77
|
+
if target['SMTP']['Port'] == 465
|
78
|
+
linuxConnection.fileAppend("#{path}/Vaultwarden.env", "SMTP_SECURITY=force_tls", options)
|
79
|
+
end
|
43
80
|
end
|
44
|
-
self.class.sshExec!(ssh, "chown #{USER}:#{USER} #{path}/Vaultwarden.env")
|
45
|
-
self.class.sshExec!(ssh, "chmod 600 #{path}/Vaultwarden.env")
|
46
81
|
|
47
|
-
|
48
|
-
|
49
|
-
|
82
|
+
linuxConnection.setUserGroup("#{path}/Vaultwarden.env", USER, USER, options)
|
83
|
+
linuxConnection.setPrivate("#{path}/Vaultwarden.env", options)
|
84
|
+
linuxConnection.upload(__dir__ + '/Vaultwarden.container', path, options)
|
85
|
+
linuxConnection.reloadUserServices(USER, options)
|
86
|
+
linuxConnection.restartUserService(USER, 'Vaultwarden', options)
|
50
87
|
if target['Proxy'] != 'only'
|
51
|
-
|
88
|
+
linuxConnection.firewallAddPort(SERVICE_PORT + '/tcp', options)
|
52
89
|
end
|
53
90
|
end
|
54
91
|
if !target.key?('Proxy') || !!target['Proxy']
|
55
|
-
|
56
|
-
|
57
|
-
|
92
|
+
Nginx.withConnection(linuxConnection) do |nginxConnection|
|
93
|
+
target['ConfigName'] = target['Name']
|
94
|
+
nginxConnection.provision(__dir__, NAME, target, activeState, context, options)
|
95
|
+
end
|
58
96
|
end
|
59
97
|
end
|
60
|
-
else
|
61
|
-
# TODO
|
62
|
-
activeState['Location'] = '@me'
|
63
98
|
end
|
64
99
|
end
|
65
100
|
|
@@ -22,10 +22,7 @@ server {
|
|
22
22
|
|
23
23
|
server_name <%= config['Domain'] %>;
|
24
24
|
|
25
|
-
|
26
|
-
error_log /var/log/nginx/wikijs.error.log;
|
27
|
-
|
28
|
-
include config-lmm/errors.conf;
|
25
|
+
include config-lmm/gateway-errors.conf;
|
29
26
|
include config-lmm/security.conf;
|
30
27
|
|
31
28
|
location / {
|
@@ -4,12 +4,17 @@ Description=Wiki.js container
|
|
4
4
|
After=local-fs.target
|
5
5
|
|
6
6
|
[Container]
|
7
|
+
ContainerName=WikiJS
|
7
8
|
Image=docker.io/requarks/wiki:latest
|
8
9
|
EnvironmentFile=/var/lib/wikijs/.config/containers/systemd/Wiki.js.env
|
9
10
|
Network=slirp4netns:allow_host_loopback=true
|
10
11
|
PublishPort=127.0.0.1:13200:3000
|
11
12
|
UserNS=keep-id:uid=1000,gid=1000
|
13
|
+
LogDriver=journald
|
12
14
|
AutoUpdate=registry
|
13
15
|
|
16
|
+
[Service]
|
17
|
+
Restart=on-failure
|
18
|
+
|
14
19
|
[Install]
|
15
20
|
WantedBy=multi-user.target default.target
|
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
module ConfigLMM
|
3
3
|
module LMM
|
4
|
-
class WikiJS < Framework::
|
4
|
+
class WikiJS < Framework::Plugin
|
5
5
|
|
6
6
|
USER = 'wikijs'
|
7
7
|
HOME_DIR = '/var/lib/wikijs'
|
@@ -11,51 +11,45 @@ module ConfigLMM
|
|
11
11
|
raise Framework::PluginProcessError.new('Domain field must be set!') unless target['Domain']
|
12
12
|
|
13
13
|
target['Database'] ||= {}
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
self.class.sshStart(uri) do |ssh|
|
19
|
-
|
20
|
-
dbPassword = self.configurePostgreSQL(target['Database'], ssh)
|
21
|
-
distroInfo = Framework::LinuxApp.currentDistroInfo(ssh)
|
22
|
-
Framework::LinuxApp.configurePodmanServiceOverSSH(USER, HOME_DIR, 'Wiki.js', distroInfo, ssh)
|
23
|
-
|
24
|
-
path = Framework::LinuxApp::SYSTEMD_CONTAINERS_PATH.gsub('~', HOME_DIR)
|
25
|
-
self.class.exec("echo 'DB_TYPE=postgres' > #{path}/Wiki.js.env", ssh)
|
26
|
-
self.class.exec("echo 'DB_HOST=#{HOST_IP}' >> #{path}/Wiki.js.env", ssh)
|
27
|
-
self.class.exec("echo 'DB_PORT=5432' >> #{path}/Wiki.js.env", ssh)
|
28
|
-
self.class.exec("echo 'DB_USER=#{USER}' >> #{path}/Wiki.js.env", ssh)
|
29
|
-
self.class.exec("echo 'DB_NAME=#{USER}' >> #{path}/Wiki.js.env", ssh)
|
30
|
-
self.class.exec(" echo 'DB_PASS=#{dbPassword}' >> #{path}/Wiki.js.env", ssh)
|
31
|
-
|
32
|
-
self.class.exec("chown #{USER}:#{USER} #{path}/Wiki.js.env", ssh)
|
33
|
-
self.class.exec("chmod 600 #{path}/Wiki.js.env", ssh)
|
34
|
-
|
35
|
-
ssh.scp.upload!(__dir__ + '/Wiki.js.container', path)
|
36
|
-
self.class.exec("systemctl --user --machine=#{USER}@ daemon-reload", ssh)
|
37
|
-
self.class.exec("systemctl --user --machine=#{USER}@ restart Wiki.js", ssh)
|
38
|
-
|
39
|
-
Framework::LinuxApp.ensurePackages([NGINX_PACKAGE], ssh)
|
40
|
-
Framework::LinuxApp.ensureServiceAutoStartOverSSH(NGINX_PACKAGE, ssh)
|
41
|
-
self.class.prepareNginxConfig(target, ssh)
|
42
|
-
self.writeNginxConfig(__dir__, 'Wiki.js', id, target, state, context, options)
|
43
|
-
self.deployNginxConfig(id, target, activeState, context, options)
|
44
|
-
Framework::LinuxApp.startServiceOverSSH(NGINX_PACKAGE, ssh)
|
14
|
+
self.withConnection(target['Location'], target) do |connection|
|
15
|
+
Linux.withConnection(connection) do |linuxConnection|
|
16
|
+
target['Database'] ||= {}
|
17
|
+
dbPassword = self.configurePostgreSQL(target['Database'], linuxConnection, options)
|
45
18
|
|
19
|
+
Podman.ensurePresent(linuxConnection, options)
|
20
|
+
Podman.createUser(USER, HOME_DIR, 'Wiki.js', linuxConnection, options)
|
21
|
+
|
22
|
+
path = Podman.containersPath(HOME_DIR)
|
23
|
+
linuxConnection.fileWrite("#{path}/Wiki.js.env", 'DB_TYPE=postgres', options)
|
24
|
+
linuxConnection.fileAppend("#{path}/Wiki.js.env", "DB_HOST=#{HOST_IP}", options)
|
25
|
+
linuxConnection.fileAppend("#{path}/Wiki.js.env", "DB_PORT=5432", options)
|
26
|
+
linuxConnection.fileAppend("#{path}/Wiki.js.env", "DB_USER=#{USER}", options)
|
27
|
+
linuxConnection.fileAppend("#{path}/Wiki.js.env", "DB_NAME=#{USER}", options)
|
28
|
+
linuxConnection.fileAppend("#{path}/Wiki.js.env", "DB_PASS=#{dbPassword}", { **options, hide: true })
|
29
|
+
|
30
|
+
linuxConnection.setUserGroup("#{path}/Wiki.js.env", USER, USER, options)
|
31
|
+
linuxConnection.setPrivate("#{path}/Wiki.js.env", options)
|
32
|
+
|
33
|
+
linuxConnection.upload(__dir__ + '/Wiki.js.container', path, options)
|
34
|
+
|
35
|
+
linuxConnection.reloadUserServices(USER, options)
|
36
|
+
linuxConnection.restartUserService(USER, 'Wiki.js', options)
|
37
|
+
|
38
|
+
Nginx.withConnection(linuxConnection) do |nginxConnection|
|
39
|
+
nginxConnection.provision(__dir__, 'Wiki.js', target, activeState, context, options)
|
40
|
+
end
|
46
41
|
end
|
47
|
-
else
|
48
|
-
# TODO
|
49
42
|
end
|
50
43
|
end
|
51
44
|
|
52
|
-
def configurePostgreSQL(
|
45
|
+
def configurePostgreSQL(dbSettings, linuxConnection, options)
|
53
46
|
password = SecureRandom.alphanumeric(20)
|
54
|
-
PostgreSQL.
|
47
|
+
PostgreSQL.withConnection(dbSettings, linuxConnection) do |postgresConnection|
|
48
|
+
postgresConnection.createUserAndDB(USER, password, options)
|
49
|
+
end
|
55
50
|
password
|
56
51
|
end
|
57
52
|
|
58
53
|
end
|
59
54
|
end
|
60
55
|
end
|
61
|
-
|