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.
Files changed (227) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +34 -0
  3. data/CNAME +1 -0
  4. data/Examples/.lmm.state.yaml +159 -0
  5. data/Examples/ConfigLMM.mm.yaml +32 -0
  6. data/Examples/Implemented.mm.yaml +252 -4
  7. data/Examples/SmallBusiness.mm.yaml +492 -0
  8. data/Plugins/Apps/Answer/answer.lmm.rb +165 -0
  9. data/Plugins/Apps/Answer/answer@.service +40 -0
  10. data/Plugins/Apps/ArchiSteamFarm/ArchiSteamFarm.conf.erb +0 -3
  11. data/Plugins/Apps/ArchiSteamFarm/ArchiSteamFarm.lmm.rb +0 -1
  12. data/Plugins/Apps/Authentik/Authentik-ProxyOutpost.container +7 -1
  13. data/Plugins/Apps/Authentik/Authentik-Server.container +6 -1
  14. data/Plugins/Apps/Authentik/Authentik-Worker.container +6 -1
  15. data/Plugins/Apps/Authentik/Authentik.conf.erb +12 -7
  16. data/Plugins/Apps/Authentik/Authentik.lmm.rb +226 -61
  17. data/Plugins/Apps/BookStack/BookStack.conf.erb +0 -3
  18. data/Plugins/Apps/BookStack/BookStack.container +5 -0
  19. data/Plugins/Apps/BookStack/BookStack.lmm.rb +14 -3
  20. data/Plugins/Apps/Cassandra/Cassandra.lmm.rb +9 -19
  21. data/Plugins/Apps/ClickHouse/ClickHouse.container +28 -0
  22. data/Plugins/Apps/ClickHouse/ClickHouse.lmm.rb +113 -0
  23. data/Plugins/Apps/ClickHouse/Config/listen.yaml +2 -0
  24. data/Plugins/Apps/ClickHouse/Config/logger.yaml +8 -0
  25. data/Plugins/Apps/ClickHouse/Config/zookeepers.yaml +5 -0
  26. data/Plugins/Apps/ClickHouse/Connection.rb +96 -0
  27. data/Plugins/Apps/Discourse/Discourse-Sidekiq.container +5 -0
  28. data/Plugins/Apps/Discourse/Discourse.conf.erb +1 -4
  29. data/Plugins/Apps/Discourse/Discourse.container +4 -0
  30. data/Plugins/Apps/Discourse/Discourse.lmm.rb +116 -55
  31. data/Plugins/Apps/Dovecot/Dovecot.lmm.rb +74 -62
  32. data/Plugins/Apps/ERPNext/ERPNext-Frontend.container +6 -1
  33. data/Plugins/Apps/ERPNext/ERPNext-Queue.container +5 -0
  34. data/Plugins/Apps/ERPNext/ERPNext-Scheduler.container +5 -0
  35. data/Plugins/Apps/ERPNext/ERPNext-Websocket.container +6 -1
  36. data/Plugins/Apps/ERPNext/ERPNext.container +6 -1
  37. data/Plugins/Apps/ERPNext/ERPNext.lmm.rb +138 -127
  38. data/Plugins/Apps/GitLab/GitLab.container +6 -0
  39. data/Plugins/Apps/GitLab/GitLab.lmm.rb +43 -49
  40. data/Plugins/Apps/Homepage/Homepage.conf.erb +86 -0
  41. data/Plugins/Apps/Homepage/Homepage.container +19 -0
  42. data/Plugins/Apps/Homepage/Homepage.lmm.rb +54 -0
  43. data/Plugins/Apps/IPFS/IPFS.conf.erb +0 -3
  44. data/Plugins/Apps/IPFS/IPFS.lmm.rb +0 -1
  45. data/Plugins/Apps/InfluxDB/InfluxDB.conf.erb +0 -3
  46. data/Plugins/Apps/InfluxDB/InfluxDB.lmm.rb +0 -1
  47. data/Plugins/Apps/Jackett/Jackett.conf.erb +0 -3
  48. data/Plugins/Apps/Jackett/Jackett.lmm.rb +0 -1
  49. data/Plugins/Apps/Jellyfin/Jellyfin.conf.erb +0 -3
  50. data/Plugins/Apps/Jellyfin/Jellyfin.lmm.rb +0 -1
  51. data/Plugins/Apps/LetsEncrypt/LetsEncrypt.lmm.rb +49 -28
  52. data/Plugins/Apps/LibreTranslate/LibreTranslate.container +21 -0
  53. data/Plugins/Apps/LibreTranslate/LibreTranslate.lmm.rb +34 -0
  54. data/Plugins/Apps/Lobsters/Containerfile +81 -0
  55. data/Plugins/Apps/Lobsters/Lobsters-Tasks.container +26 -0
  56. data/Plugins/Apps/Lobsters/Lobsters.conf.erb +99 -0
  57. data/Plugins/Apps/Lobsters/Lobsters.container +27 -0
  58. data/Plugins/Apps/Lobsters/Lobsters.lmm.rb +196 -0
  59. data/Plugins/Apps/Lobsters/crontab +3 -0
  60. data/Plugins/Apps/Lobsters/database.yml +26 -0
  61. data/Plugins/Apps/Lobsters/entrypoint.sh +30 -0
  62. data/Plugins/Apps/Lobsters/generateCredentials.rb +19 -0
  63. data/Plugins/Apps/Lobsters/lobsters-cron.sh +25 -0
  64. data/Plugins/Apps/Lobsters/lobsters-daily.sh +23 -0
  65. data/Plugins/Apps/Lobsters/puma.rb +49 -0
  66. data/Plugins/Apps/MariaDB/Connection.rb +55 -0
  67. data/Plugins/Apps/MariaDB/MariaDB.lmm.rb +60 -53
  68. data/Plugins/Apps/Mastodon/Mastodon-Sidekiq.container +22 -0
  69. data/Plugins/Apps/Mastodon/Mastodon-Streaming.container +20 -0
  70. data/Plugins/Apps/Mastodon/Mastodon.conf.erb +34 -45
  71. data/Plugins/Apps/Mastodon/Mastodon.container +28 -0
  72. data/Plugins/Apps/Mastodon/Mastodon.lmm.rb +240 -5
  73. data/Plugins/Apps/Mastodon/configlmm.rake +30 -0
  74. data/Plugins/Apps/Mastodon/entrypoint.sh +16 -0
  75. data/Plugins/Apps/Matrix/Element.container +5 -0
  76. data/Plugins/Apps/Matrix/Matrix.conf.erb +2 -8
  77. data/Plugins/Apps/Matrix/Matrix.lmm.rb +100 -71
  78. data/Plugins/Apps/Matrix/Synapse.container +5 -0
  79. data/Plugins/Apps/Netdata/Netdata.conf.erb +0 -3
  80. data/Plugins/Apps/Netdata/Netdata.lmm.rb +0 -1
  81. data/Plugins/Apps/Nextcloud/Nextcloud.conf.erb +3 -4
  82. data/Plugins/Apps/Nextcloud/Nextcloud.lmm.rb +150 -68
  83. data/Plugins/Apps/Nextcloud/autoconfig.php +13 -0
  84. data/Plugins/Apps/Nextcloud/config.php +10 -1
  85. data/Plugins/Apps/Nextcloud/nextcloudcron.service +8 -0
  86. data/Plugins/Apps/Nextcloud/nextcloudcron.timer +10 -0
  87. data/Plugins/Apps/Nginx/Connection.rb +93 -0
  88. data/Plugins/Apps/Nginx/conf.d/configlmm.conf +50 -9
  89. data/Plugins/Apps/Nginx/conf.d/languages.conf +21 -0
  90. data/Plugins/Apps/Nginx/config-lmm/errors.conf +25 -20
  91. data/Plugins/Apps/Nginx/config-lmm/gateway-errors.conf +20 -0
  92. data/Plugins/Apps/Nginx/config-lmm/proxy.conf +1 -1
  93. data/Plugins/Apps/Nginx/main.conf.erb +7 -3
  94. data/Plugins/Apps/Nginx/nginx.conf +2 -2
  95. data/Plugins/Apps/Nginx/nginx.lmm.rb +99 -81
  96. data/Plugins/Apps/Nginx/proxy.conf.erb +11 -3
  97. data/Plugins/Apps/Odoo/Odoo.conf.erb +0 -3
  98. data/Plugins/Apps/Odoo/Odoo.container +5 -0
  99. data/Plugins/Apps/Odoo/Odoo.lmm.rb +4 -5
  100. data/Plugins/Apps/Ollama/Ollama.container +26 -0
  101. data/Plugins/Apps/Ollama/Ollama.lmm.rb +73 -0
  102. data/Plugins/Apps/OpenTelemetry/Config/config.yaml +704 -0
  103. data/Plugins/Apps/OpenTelemetry/OpenTelemetry.lmm.rb +154 -0
  104. data/Plugins/Apps/OpenVidu/Ingress.container +5 -0
  105. data/Plugins/Apps/OpenVidu/OpenVidu.conf.erb +0 -3
  106. data/Plugins/Apps/OpenVidu/OpenVidu.container +5 -0
  107. data/Plugins/Apps/OpenVidu/OpenVidu.lmm.rb +7 -3
  108. data/Plugins/Apps/OpenVidu/OpenViduCall.conf.erb +0 -3
  109. data/Plugins/Apps/OpenVidu/OpenViduCall.container +5 -0
  110. data/Plugins/Apps/PHP-FPM/Connection.rb +91 -0
  111. data/Plugins/Apps/PHP-FPM/PHP-FPM.lmm.rb +31 -4
  112. data/Plugins/Apps/Peppermint/Peppermint.conf.erb +2 -5
  113. data/Plugins/Apps/Peppermint/Peppermint.container +5 -0
  114. data/Plugins/Apps/Peppermint/Peppermint.lmm.rb +29 -33
  115. data/Plugins/Apps/Perplexica/Perplexica.container +25 -0
  116. data/Plugins/Apps/Perplexica/Perplexica.lmm.rb +92 -0
  117. data/Plugins/Apps/Perplexica/config.toml +26 -0
  118. data/Plugins/Apps/Podman/Connection.rb +24 -0
  119. data/Plugins/Apps/Podman/Podman.lmm.rb +80 -0
  120. data/Plugins/Apps/Podman/storage.conf +6 -0
  121. data/Plugins/Apps/Postfix/Postfix.lmm.rb +242 -164
  122. data/Plugins/Apps/PostgreSQL/Connection.rb +97 -0
  123. data/Plugins/Apps/PostgreSQL/PostgreSQL.lmm.rb +184 -148
  124. data/Plugins/Apps/Pterodactyl/Pterodactyl.conf.erb +0 -3
  125. data/Plugins/Apps/Pterodactyl/Pterodactyl.lmm.rb +0 -2
  126. data/Plugins/Apps/Pterodactyl/Wings.conf.erb +0 -3
  127. data/Plugins/Apps/RVM/RVM.lmm.rb +57 -0
  128. data/Plugins/Apps/Roundcube/Roundcube.conf.erb +0 -3
  129. data/Plugins/Apps/Roundcube/Roundcube.lmm.rb +15 -19
  130. data/Plugins/Apps/SSH/SSH.lmm.rb +9 -15
  131. data/Plugins/Apps/SearXNG/SearXNG.container +22 -0
  132. data/Plugins/Apps/SearXNG/SearXNG.lmm.rb +79 -0
  133. data/Plugins/Apps/SearXNG/limiter.toml +40 -0
  134. data/Plugins/Apps/SearXNG/settings.yml +2 -0
  135. data/Plugins/Apps/SigNoz/Config/alerts.yml +11 -0
  136. data/Plugins/Apps/SigNoz/Config/otel-collector-config.yaml +110 -0
  137. data/Plugins/Apps/SigNoz/Config/otel-collector-opamp-config.yaml +1 -0
  138. data/Plugins/Apps/SigNoz/Config/prometheus.yml +18 -0
  139. data/Plugins/Apps/SigNoz/SigNoz-Collector.container +23 -0
  140. data/Plugins/Apps/SigNoz/SigNoz-Migrator.container +17 -0
  141. data/Plugins/Apps/SigNoz/SigNoz.conf.erb +61 -0
  142. data/Plugins/Apps/SigNoz/SigNoz.container +26 -0
  143. data/Plugins/Apps/SigNoz/SigNoz.lmm.rb +319 -0
  144. data/Plugins/Apps/Solr/log4j2.xml +89 -0
  145. data/Plugins/Apps/Solr/solr.lmm.rb +82 -0
  146. data/Plugins/Apps/Sunshine/Sunshine.conf.erb +0 -3
  147. data/Plugins/Apps/Sunshine/Sunshine.lmm.rb +0 -1
  148. data/Plugins/Apps/Tunnel/tunnel.lmm.rb +33 -37
  149. data/Plugins/Apps/UVdesk/UVdesk.conf.erb +0 -3
  150. data/Plugins/Apps/Umami/Umami.container +19 -0
  151. data/Plugins/Apps/Umami/Umami.lmm.rb +108 -0
  152. data/Plugins/Apps/Valkey/Valkey.lmm.rb +54 -42
  153. data/Plugins/Apps/Vaultwarden/Vaultwarden.conf.erb +9 -6
  154. data/Plugins/Apps/Vaultwarden/Vaultwarden.container +7 -1
  155. data/Plugins/Apps/Vaultwarden/Vaultwarden.lmm.rb +64 -29
  156. data/Plugins/Apps/Wiki.js/Wiki.js.conf.erb +1 -4
  157. data/Plugins/Apps/Wiki.js/Wiki.js.container +5 -0
  158. data/Plugins/Apps/Wiki.js/Wiki.js.lmm.rb +31 -37
  159. data/Plugins/Apps/YaCy/YaCy.conf.erb +93 -0
  160. data/Plugins/Apps/YaCy/YaCy.container +21 -0
  161. data/Plugins/Apps/YaCy/YaCy.lmm.rb +160 -0
  162. data/Plugins/Apps/ZooKeeper/ZooKeeper.container +24 -0
  163. data/Plugins/Apps/ZooKeeper/ZooKeeper.lmm.rb +68 -0
  164. data/Plugins/Apps/bitmagnet/bitmagnet.conf.erb +0 -3
  165. data/Plugins/Apps/bitmagnet/bitmagnet.lmm.rb +0 -1
  166. data/Plugins/Apps/gollum/gollum.conf.erb +2 -4
  167. data/Plugins/Apps/gollum/gollum.container +6 -0
  168. data/Plugins/Apps/gollum/gollum.lmm.rb +51 -50
  169. data/Plugins/Apps/llama.cpp/llama.cpp.container +28 -0
  170. data/Plugins/Apps/llama.cpp/llama.cpp.lmm.rb +90 -0
  171. data/Plugins/Apps/vLLM/vLLM.container +32 -0
  172. data/Plugins/Apps/vLLM/vLLM.lmm.rb +89 -0
  173. data/Plugins/OS/General/Utils.lmm.rb +26 -0
  174. data/Plugins/OS/Linux/Connection.rb +472 -0
  175. data/Plugins/OS/Linux/Debian/preseed.cfg.erb +25 -6
  176. data/Plugins/OS/Linux/Flavours.yaml +13 -0
  177. data/Plugins/OS/Linux/Grub/grub.cfg +10 -0
  178. data/Plugins/OS/Linux/HTTP.rb +32 -0
  179. data/Plugins/OS/Linux/Linux.lmm.rb +533 -187
  180. data/Plugins/OS/Linux/Packages.yaml +20 -1
  181. data/Plugins/OS/Linux/Services.yaml +8 -0
  182. data/Plugins/OS/Linux/Shell.rb +70 -0
  183. data/Plugins/OS/Linux/Syslinux/default +8 -0
  184. data/Plugins/OS/Linux/WireGuard/WireGuard.lmm.rb +83 -59
  185. data/Plugins/OS/Linux/WireGuard/wg0.conf.erb +3 -0
  186. data/Plugins/OS/Linux/openSUSE/autoinst.xml.erb +29 -3
  187. data/Plugins/OS/Linux/systemd/systemd.lmm.rb +13 -11
  188. data/Plugins/OS/Routers/Aruba/ArubaInstant.lmm.rb +6 -5
  189. data/Plugins/Platforms/GitHub.lmm.rb +73 -28
  190. data/Plugins/Platforms/GoDaddy/GoDaddy.lmm.rb +9 -6
  191. data/Plugins/Platforms/Proxmox/Proxmox.lmm.rb +402 -0
  192. data/Plugins/Platforms/Proxmox/XTerm.rb +321 -0
  193. data/Plugins/Platforms/libvirt/libvirt.lmm.rb +38 -13
  194. data/Plugins/Platforms/porkbun.lmm.rb +12 -2
  195. data/Plugins/Platforms/porkbun_spec.rb +2 -2
  196. data/Plugins/Services/DNS/AmberBit.lmm.rb +1 -1
  197. data/Plugins/Services/DNS/ArubaItDNS.lmm.rb +1 -1
  198. data/Plugins/Services/DNS/NICLV.lmm.rb +1 -1
  199. data/Plugins/Services/DNS/PowerDNS.lmm.rb +70 -68
  200. data/Plugins/Services/DNS/tonic.lmm.rb +22 -12
  201. data/lib/ConfigLMM/Framework/plugins/dns.rb +4 -3
  202. data/lib/ConfigLMM/Framework/plugins/linuxApp.rb +145 -184
  203. data/lib/ConfigLMM/Framework/plugins/nginxApp.rb +34 -17
  204. data/lib/ConfigLMM/Framework/plugins/plugin.rb +53 -181
  205. data/lib/ConfigLMM/Framework/plugins/store.rb +4 -4
  206. data/lib/ConfigLMM/Framework/variables.rb +75 -0
  207. data/lib/ConfigLMM/Framework.rb +1 -0
  208. data/lib/ConfigLMM/cli.rb +12 -6
  209. data/lib/ConfigLMM/commands/configsCommand.rb +37 -6
  210. data/lib/ConfigLMM/commands/diff.rb +33 -9
  211. data/lib/ConfigLMM/context.rb +22 -3
  212. data/lib/ConfigLMM/io/configList.rb +82 -6
  213. data/lib/ConfigLMM/io/connection.rb +143 -0
  214. data/lib/ConfigLMM/io/dhcp.rb +330 -0
  215. data/lib/ConfigLMM/io/http.rb +78 -0
  216. data/lib/ConfigLMM/io/local.rb +207 -0
  217. data/lib/ConfigLMM/io/pxe.rb +92 -0
  218. data/lib/ConfigLMM/io/ssh.rb +156 -0
  219. data/lib/ConfigLMM/io/tftp.rb +105 -0
  220. data/lib/ConfigLMM/io.rb +2 -0
  221. data/lib/ConfigLMM/secrets/envStore.rb +39 -0
  222. data/lib/ConfigLMM/secrets/fileStore.rb +43 -0
  223. data/lib/ConfigLMM/state.rb +2 -1
  224. data/lib/ConfigLMM/version.rb +2 -1
  225. data/lib/ConfigLMM.rb +1 -0
  226. data/{Examples → scripts}/configlmmAuth.sh +7 -5
  227. metadata +205 -8
@@ -1,6 +1,6 @@
1
1
 
2
2
  upstream mastodon {
3
- server unix:///run/mastodon.sock fail_timeout=0;
3
+ server <%= config['Server'] %>:13600 fail_timeout=0;
4
4
  }
5
5
 
6
6
  upstream mastodon-streaming {
@@ -8,70 +8,59 @@ upstream mastodon-streaming {
8
8
  # to ensure load is distributed evenly.
9
9
  least_conn;
10
10
 
11
- server 127.0.0.1:4000 fail_timeout=0;
11
+ server <%= config['Server'] %>:14000 fail_timeout=0;
12
12
  # Uncomment these lines for load-balancing multiple instances of streaming for scaling,
13
- # this assumes your running the streaming server on ports 4000, 4001, and 4002:
14
- # server 127.0.0.1:4001 fail_timeout=0;
15
- # server 127.0.0.1:4002 fail_timeout=0;
13
+ # this assumes your running the streaming server on ports 14000, 14001, and 14002:
14
+ # server <%= config['Server'] %>:14001 fail_timeout=0;
15
+ # server <%= config['Server'] %>:14002 fail_timeout=0;
16
16
  }
17
17
 
18
- # proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=CACHE:10m inactive=7d max_size=1g;
19
-
20
18
  server {
21
- <% if !config['TLS'] %>
22
- listen <%= config['Port'] %>;
23
- listen [::]:<%= config['Port'] %>;
24
- <% else %>
25
- listen <%= config['Port'] %> ssl;
26
- listen [::]:<%= config['Port'] %> ssl;
19
+
20
+ <% if config['NginxVersion'] >= 1.25 %>
21
+ <% if !config['TLS'] %>
22
+ listen <%= config['Port'] %>;
23
+ listen [::]:<%= config['Port'] %>;
24
+ <% else %>
25
+ listen <%= config['Port'] %> ssl;
26
+ listen [::]:<%= config['Port'] %> ssl;
27
+
28
+ include config-lmm/ssl.conf;
29
+ <% end %>
27
30
  http2 on;
28
- include config-lmm/ssl.conf;
31
+ http3 on;
32
+ quic_retry on;
33
+ add_header Alt-Svc 'h3=":443"; ma=86400';
34
+ <% else %>
35
+ <% if !config['TLS'] %>
36
+ listen <%= config['Port'] %>;
37
+ listen [::]:<%= config['Port'] %>;
38
+ <% else %>
39
+ listen <%= config['Port'] %> ssl http2;
40
+ listen [::]:<%= config['Port'] %> ssl http2;
41
+
42
+ include config-lmm/ssl.conf;
43
+ <% end %>
29
44
  <% end %>
30
45
 
31
46
  server_name <%= config['Domain'] %>;
32
47
 
33
- access_log /var/log/nginx/mastodon.access.log;
34
- error_log /var/log/nginx/mastodon.error.log;
48
+ <% if config['CertName'] %>
49
+ ssl_certificate "/etc/letsencrypt/live/<%= config['CertName'] %>/fullchain.pem";
50
+ ssl_certificate_key "/etc/letsencrypt/live/<%= config['CertName'] %>/privkey.pem";
51
+ ssl_trusted_certificate "/etc/letsencrypt/live/<%= config['CertName'] %>/chain.pem";
52
+ <% end %>
35
53
 
36
54
  client_max_body_size 99M;
37
55
 
38
56
  include config-lmm/errors.conf;
39
57
 
40
- # proxy_redirect off;
41
- # proxy_cache CACHE;
42
- # proxy_cache_valid 200 7d;
43
- # proxy_cache_valid 410 24h;
44
- # proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
45
- # add_header X-Cached $upstream_cache_status;
46
-
47
- root /var/lib/mastodon/public;
48
-
49
58
  location / {
50
- try_files $uri @mastodon;
51
- }
52
-
53
- location @mastodon {
54
59
  proxy_pass http://mastodon;
55
60
  include config-lmm/proxy.conf;
56
61
  }
57
62
 
58
- location ~ ^/assets|avatars|emoji|headers|packs|shortcuts|sounds/ {
59
-
60
- add_header Cache-Control "public, max-age=2419200, must-revalidate";
61
- add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
62
- try_files $uri =404;
63
- }
64
-
65
- location ~ ^/system/ {
66
- add_header Cache-Control "public, max-age=2419200, immutable";
67
- add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
68
- #add_header X-Content-Type-Options nosniff;
69
- add_header Content-Security-Policy "default-src 'none'; form-action 'none'";
70
- try_files $uri =404;
71
- }
72
-
73
63
  location ^~ /api/v1/streaming {
74
-
75
64
  proxy_buffering off;
76
65
  proxy_cache off;
77
66
  proxy_pass http://mastodon-streaming;
@@ -0,0 +1,28 @@
1
+
2
+ [Unit]
3
+ Description=Mastodon container
4
+ After=local-fs.target
5
+
6
+ [Container]
7
+ ContainerName=Mastodon
8
+ Image=ghcr.io/mastodon/mastodon:latest
9
+ # Need newer Podman
10
+ # Entrypoint=/entrypoint.sh
11
+ PodmanArgs=--entrypoint /entrypoint.sh
12
+ Exec=server
13
+ EnvironmentFile=/var/lib/mastodon/.config/containers/systemd/Mastodon.env
14
+ Network=slirp4netns:allow_host_loopback=true
15
+ PublishPort=127.0.0.1:13600:3000
16
+ UserNS=keep-id:uid=991,gid=991
17
+ Volume=/var/lib/mastodon/system:/mastodon/public/system
18
+ Volume=/var/lib/mastodon/.configlmm/entrypoint.sh:/entrypoint.sh
19
+ Volume=/var/lib/mastodon/.configlmm/configlmm.rake:/mastodon/lib/tasks/configlmm.rake
20
+ LogDriver=journald
21
+ AutoUpdate=registry
22
+
23
+ [Service]
24
+ TimeoutStartSec=6min
25
+ Restart=on-failure
26
+
27
+ [Install]
28
+ WantedBy=multi-user.target default.target
@@ -1,10 +1,22 @@
1
1
 
2
+ require 'base64'
3
+ require 'openssl'
4
+ require 'public_suffix'
5
+
2
6
  module ConfigLMM
3
7
  module LMM
4
- class Mastodon < Framework::NginxApp
8
+ class Mastodon < Framework::Plugin
9
+
10
+ NAME = 'Mastodon'
11
+ USER = 'mastodon'
12
+ HOME_DIR = '/var/lib/mastodon'
13
+ PORT = '13600'
14
+ STREAMING_PORT = '14000'
5
15
 
6
16
  def actionMastodonBuild(id, target, state, context, options)
7
- writeNginxConfig(__dir__, 'Mastodon', id, target, state, context, options)
17
+ Nginx.withConnection(local) do |nginxConnection|
18
+ nginxConnection.writeConfig(__dir__, NAME, target, state, context, options)
19
+ end
8
20
  end
9
21
 
10
22
  def actionMastodonDiff(id, target, activeState, context, options)
@@ -12,9 +24,232 @@ module ConfigLMM
12
24
  end
13
25
 
14
26
  def actionMastodonDeploy(id, target, activeState, context, options)
15
- if !target['Location'] || target['Location'] == '@me'
16
- deployNginxConfig(id, target, activeState, context, options)
17
- activeState['Location'] = '@me'
27
+ raise Framework::PluginProcessError.new('Domain field must be set!') unless target['Domain']
28
+
29
+ self.withConnection(target['Location'], target) do |connection|
30
+ Linux.withConnection(connection) do |linuxConnection|
31
+ if !target.key?('Proxy') || target['Proxy'] == false
32
+ deployService(linuxConnection, target, activeState, context, options)
33
+ end
34
+
35
+ deployNginxConfig(linuxConnection, target, activeState, context, options)
36
+ end
37
+ end
38
+ end
39
+
40
+ def deployService(linuxConnection, target, activeState, context, options)
41
+ target['Database'] ||= {}
42
+ dbPassword = self.configurePostgreSQL(target['Database'], linuxConnection, options)
43
+
44
+ Podman.ensurePresent(linuxConnection, options)
45
+ Podman.createUser(USER, HOME_DIR, 'Mastodon', linuxConnection, options)
46
+ linuxConnection.withUserShell(USER) do |shell|
47
+ shell.createDirs(options, '~/system', '~/.configlmm')
48
+ end
49
+
50
+ path = Podman.containersPath(HOME_DIR)
51
+
52
+ localDomain = PublicSuffix.domain(target['Domain'])
53
+ raise Framework::PluginProcessError.new('Invalid Domain!') unless localDomain
54
+
55
+ localDomain = target['LocalDomain'] if target['LocalDomain']
56
+ linuxConnection.fileWrite("#{path}/Mastodon.env", "LOCAL_DOMAIN=#{Addressable::IDNA.to_ascii(localDomain)}", options)
57
+
58
+ webDomain = nil
59
+ if localDomain != target['Domain']
60
+ webDomain = target['Domain']
61
+ end
62
+ linuxConnection.fileAppend("#{path}/Mastodon.env", "WEB_DOMAIN=#{Addressable::IDNA.to_ascii(webDomain)}", options) if webDomain
63
+
64
+ secretKeyBase = context.secrets.load(target['SecretId'], 'SECRET_KEY_BASE')
65
+ if !secretKeyBase
66
+ secretKeyBase = SecureRandom.hex(64)
67
+ context.secrets.store(target['SecretId'], 'SECRET_KEY_BASE', secretKeyBase) unless options['dry']
68
+ end
69
+ linuxConnection.fileAppend("#{path}/Mastodon.env", "SECRET_KEY_BASE=#{secretKeyBase}", { **options, hide: true })
70
+
71
+ otpSecret = context.secrets.load(target['SecretId'], 'OTP_SECRET')
72
+ if !otpSecret
73
+ otpSecret = SecureRandom.hex(64)
74
+ context.secrets.store(target['SecretId'], 'OTP_SECRET', otpSecret) unless options['dry']
75
+ end
76
+ linuxConnection.fileAppend("#{path}/Mastodon.env", "OTP_SECRET=#{otpSecret}", { **options, hide: true })
77
+
78
+ deterministicKey = context.secrets.load(target['SecretId'], 'ENCRYPTION_DETERMINISTIC_KEY')
79
+ if !deterministicKey
80
+ deterministicKey = SecureRandom.alphanumeric(32)
81
+ context.secrets.store(target['SecretId'], 'ENCRYPTION_DETERMINISTIC_KEY', deterministicKey) unless options['dry']
82
+ end
83
+
84
+ keySalt = context.secrets.load(target['SecretId'], 'KEY_DERIVATION_SALT')
85
+ if !keySalt
86
+ keySalt = SecureRandom.alphanumeric(32)
87
+ context.secrets.store(target['SecretId'], 'KEY_DERIVATION_SALT', keySalt) unless options['dry']
88
+ end
89
+
90
+ primaryKey = context.secrets.load(target['SecretId'], 'ENCRYPTION_PRIMARY_KEY')
91
+ if !primaryKey
92
+ primaryKey = SecureRandom.alphanumeric(32)
93
+ context.secrets.store(target['SecretId'], 'ENCRYPTION_PRIMARY_KEY', primaryKey) unless options['dry']
94
+ end
95
+
96
+ linuxConnection.fileAppend("#{path}/Mastodon.env", "ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY=#{deterministicKey}", { **options, hide: true })
97
+ linuxConnection.fileAppend("#{path}/Mastodon.env", "ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT=#{keySalt}", { **options, hide: true })
98
+ linuxConnection.fileAppend("#{path}/Mastodon.env", "ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY=#{primaryKey}", { **options, hide: true })
99
+
100
+ vapidPrivateKey = context.secrets.load(target['SecretId'], 'VAPID_PRIVATE_KEY')
101
+ vapidPublicKey = context.secrets.load(target['SecretId'], 'VAPID_PUBLIC_KEY')
102
+ if !vapidPrivateKey || !vapidPublicKey
103
+ curve = OpenSSL::PKey::EC.generate('prime256v1')
104
+ vapidPrivateKey = Base64.urlsafe_encode64(curve.public_key.to_bn.to_s(2))
105
+ vapidPublicKey = Base64.urlsafe_encode64(curve.private_key.to_s(2))
106
+ context.secrets.store(target['SecretId'], 'VAPID_PRIVATE_KEY', vapidPrivateKey) unless options['dry']
107
+ context.secrets.store(target['SecretId'], 'VAPID_PUBLIC_KEY', vapidPublicKey) unless options['dry']
108
+ end
109
+
110
+ linuxConnection.fileAppend("#{path}/Mastodon.env", "VAPID_PRIVATE_KEY=#{vapidPrivateKey}", { **options, hide: true })
111
+ linuxConnection.fileAppend("#{path}/Mastodon.env", "VAPID_PUBLIC_KEY=#{vapidPublicKey}", { **options, hide: true })
112
+
113
+ databaseHost = Podman.updateHost(target['Database'].to_h['HostName'])
114
+ linuxConnection.fileAppend("#{path}/Mastodon.env", "DB_HOST=#{databaseHost}", options)
115
+ linuxConnection.fileAppend("#{path}/Mastodon.env", "DB_PORT=#{target['Database']['Port']}", options) if target['Database'].to_h['Port']
116
+ linuxConnection.fileAppend("#{path}/Mastodon.env", "DB_USER=#{USER}", options)
117
+ linuxConnection.fileAppend("#{path}/Mastodon.env", "DB_NAME=#{USER}", options)
118
+ linuxConnection.fileAppend("#{path}/Mastodon.env", "DB_PASS=#{dbPassword}", { **options, hide: true })
119
+
120
+ valkeyHost = Podman.updateHost(target['Valkey'].to_h['Host'])
121
+ linuxConnection.fileAppend("#{path}/Mastodon.env", "REDIS_HOST=#{valkeyHost}", options)
122
+ if target['Valkey'].to_h['SecretId']
123
+ valkeyPassword = context.secrets.load(target['Valkey']['SecretId'], 'VALKEY_PASSWORD')
124
+ if !valkeyPassword.nil?
125
+ linuxConnection.fileAppend("#{path}/Mastodon.env", "REDIS_PASSWORD=#{valkeyPassword}", { **options, hide: true })
126
+ end
127
+ end
128
+
129
+ if target['Admin'].to_h['Username']
130
+ linuxConnection.fileAppend("#{path}/Mastodon.env", "ADMIN_USERNAME=#{target['Admin']['Username']}", options)
131
+ end
132
+
133
+ if target['Admin'].to_h['EMail']
134
+ adminPassword = context.secrets.load(target['SecretId'], 'ADMIN_PASSWORD')
135
+ if adminPassword.nil?
136
+ adminPassword = SecureRandom.alphanumeric(20)
137
+ context.secrets.store(target['SecretId'], 'ADMIN_PASSWORD', adminPassword)
138
+ context.secrets.print("Mastodon Admin '#{target['Admin']['EMail']}' password", adminPassword)
139
+ end
140
+ linuxConnection.fileAppend("#{path}/Mastodon.env", "ADMIN_EMAIL=#{target['Admin']['EMail']}", options)
141
+ linuxConnection.fileAppend("#{path}/Mastodon.env", "ADMIN_PASSWORD=#{adminPassword}", options)
142
+ end
143
+
144
+ if !target['SMTP'].to_h.empty?
145
+ emailHost = Podman.updateHost(target['SMTP']['Host'])
146
+
147
+ linuxConnection.fileAppend("#{path}/Mastodon.env", "SMTP_SERVER=#{emailHost}", options)
148
+
149
+ if target['SMTP']['Port']
150
+ linuxConnection.fileAppend("#{path}/Mastodon.env", "SMTP_PORT=#{target['SMTP']['Port']}", options)
151
+ end
152
+
153
+ if target['SMTP']['Username']
154
+ linuxConnection.fileAppend("#{path}/Mastodon.env", "SMTP_LOGIN=#{target['SMTP']['Username']}", options)
155
+ end
156
+
157
+ if target['SMTP']['SecretId']
158
+ smtpPassword = context.secrets.load(target['SMTP']['SecretId'], target['SMTP']['Username'].upcase + '_PASSWORD')
159
+ linuxConnection.fileAppend("#{path}/Mastodon.env", "SMTP_PASSWORD=#{smtpPassword}", { **options, hide: true })
160
+ end
161
+
162
+ if target['SMTP']['Port'] == 465
163
+ linuxConnection.fileAppend("#{path}/Mastodon.env", "SMTP_TLS=true", options)
164
+ end
165
+
166
+ if target['SMTP']['From']
167
+ linuxConnection.fileAppend("#{path}/Mastodon.env", "SMTP_FROM_ADDRESS=#{target['SMTP']['From']}", options)
168
+ end
169
+ end
170
+
171
+ if !target['Settings'].to_h.empty?
172
+ target['Settings'].each do |name, value|
173
+ linuxConnection.fileAppend("#{path}/Mastodon.env", "#{name}=#{value}", options)
174
+ end
175
+ end
176
+
177
+ linuxConnection.setUserGroup("#{path}/Mastodon.env", USER, USER, options)
178
+ linuxConnection.setPrivate("#{path}/Mastodon.env", options)
179
+
180
+ linuxConnection.upload(__dir__ + '/configlmm.rake', HOME_DIR + '/.configlmm/', options)
181
+ linuxConnection.upload(__dir__ + '/entrypoint.sh', HOME_DIR + '/.configlmm/', options)
182
+ linuxConnection.makeExecutable(HOME_DIR + '/.configlmm/entrypoint.sh', options)
183
+
184
+ linuxConnection.upload(__dir__ + '/Mastodon.container', path, options)
185
+ linuxConnection.upload(__dir__ + '/Mastodon-Sidekiq.container', path, options)
186
+ linuxConnection.upload(__dir__ + '/Mastodon-Streaming.container', path, options)
187
+
188
+ if target['Proxy'] == false
189
+ linuxConnection.fileReplace("#{path}/Mastodon.container", 'PublishPort=127.0.0.1:', 'PublishPort=0.0.0.0:', options)
190
+ linuxConnection.fileReplace("#{path}/Mastodon-Streaming.container", 'PublishPort=127.0.0.1:', 'PublishPort=0.0.0.0:', options)
191
+ linuxConnection.firewallAddPort("#{PORT}/tcp", options)
192
+ linuxConnection.firewallAddPort("#{STREAMING_PORT}/tcp", options)
193
+ end
194
+
195
+ linuxConnection.reloadUserServices(USER, options)
196
+ linuxConnection.restartUserService(USER, 'Mastodon', options)
197
+ linuxConnection.restartUserService(USER, 'Mastodon-Sidekiq', options)
198
+ linuxConnection.restartUserService(USER, 'Mastodon-Streaming', options)
199
+ end
200
+
201
+ def deployNginxConfig(linuxConnection, target, activeState, context, options)
202
+ if !target.key?('Proxy') || target['Proxy']
203
+ Nginx.withConnection(linuxConnection) do |nginxConnection|
204
+ target['Server'] = '127.0.0.1' unless target['Server']
205
+ nginxConnection.provision(__dir__, 'Mastodon', target, activeState, context, options)
206
+ end
207
+ end
208
+ end
209
+
210
+ def configurePostgreSQL(dbSettings, linuxConnection, options)
211
+ password = SecureRandom.alphanumeric(20)
212
+ PostgreSQL.withConnection(dbSettings, linuxConnection) do |postgresConnection|
213
+ postgresConnection.createUserAndDB(USER, password, options)
214
+ end
215
+ password
216
+ end
217
+
218
+ def cleanup(configs, state, context, options)
219
+ cleanupType(:Mastodon, configs, state, context, options) do |item, id, state, context, options, connection|
220
+ Linux.withConnection(connection) do |linuxConnection|
221
+
222
+ if !item['Config'].key?('Proxy') || item['Config']['Proxy']
223
+ Nginx.withConnection(linuxConnection) do |nginxConnection|
224
+ nginxConnection.cleanupConfig('Mastodon', context, options)
225
+ nginxConnection.reload(options)
226
+ end
227
+ elsif item['Config'].key?('Proxy') && item['Config']['Proxy'] == false
228
+ linuxConnection.firewallRemovePort("#{PORT}/tcp", options)
229
+ linuxConnection.firewallRemovePort("#{STREAMING_PORT}/tcp", options)
230
+ end
231
+
232
+ if !item['Config'].key?('Proxy') || item['Config']['Proxy'] == false
233
+ linuxConnection.stopUserService(USER, 'Mastodon-Sidekiq', options)
234
+ linuxConnection.stopUserService(USER, 'Mastodon-Streaming', options)
235
+ linuxConnection.stopUserService(USER, 'Mastodon', options)
236
+
237
+ path = Podman.containersPath(HOME_DIR)
238
+ linuxConnection.rm(path + '/Mastodon.container', options[:dry])
239
+ linuxConnection.rm(path + '/Mastodon-Streaming.container', options[:dry])
240
+ linuxConnection.rm(path + '/Mastodon-Sidekiq.container', options[:dry])
241
+
242
+ state.item(id)['Status'] = State::STATUS_DELETED unless options[:dry]
243
+
244
+ if options[:destroy]
245
+ linuxConnection.deleteUserAndGroup(USER, options)
246
+ linuxConnection.rm(HOME_DIR, options[:dry])
247
+ state.item(id)['Status'] = State::STATUS_DESTROYED unless options[:dry]
248
+ end
249
+ else
250
+ state.item(id)['Status'] = options[:destroy] ? State::STATUS_DESTROYED : State::STATUS_DELETED unless options[:dry]
251
+ end
252
+ end
18
253
  end
19
254
  end
20
255
 
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Based on https://github.com/mastodon/mastodon/blob/main/lib/tasks/mastodon.rake#L7
4
+
5
+ namespace :configlmm do
6
+ desc 'Configure the instance for production use'
7
+ task :setup do
8
+ username = 'admin'
9
+ username = ENV['ADMIN_USERNAME'] if ENV['ADMIN_USERNAME']
10
+ emailLocal, emailDomain = ENV['ADMIN_EMAIL'].to_s.split('@')
11
+ password = ENV['ADMIN_PASSWORD']
12
+
13
+ if !emailLocal.to_s.empty? && !emailDomain.to_s.empty? && !password.to_s.empty?
14
+ require_relative '../../config/environment'
15
+ require 'addressable/idna'
16
+
17
+ email = emailLocal + '@' + Addressable::IDNA.to_ascii(emailDomain)
18
+ user = User.where('LOWER(email) = ?', email.downcase).first
19
+ account = Account.where('LOWER(username) = ?', username.downcase).first
20
+ if !user && !account
21
+ owner_role = UserRole.find_by(name: 'Owner')
22
+ user = User.new(email: email, password: password, confirmed_at: Time.now.utc, account_attributes: { username: username }, bypass_invite_request_check: true, role: owner_role)
23
+ user.save(validate: false)
24
+ user.approve!
25
+
26
+ Setting.site_contact_username = username
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/sh
2
+
3
+ set -o errexit
4
+ set -o nounset
5
+
6
+ cmd="/usr/bin/tini"
7
+
8
+ if [ $# -gt 0 ] && [ "$1" = "server" ]; then
9
+ bin/rails db:prepare
10
+ bin/rails configlmm:setup
11
+ unset ADMIN_PASSWORD
12
+
13
+ exec $cmd -- bundle exec puma -C config/puma.rb
14
+ else
15
+ exec $cmd -- "$@"
16
+ fi
@@ -4,11 +4,16 @@ Description=Matrix (Element) container
4
4
  After=local-fs.target
5
5
 
6
6
  [Container]
7
+ ContainerName=Element
7
8
  Image=docker.io/vectorim/element-web:latest
8
9
  EnvironmentFile=/var/lib/matrix/.config/containers/systemd/Matrix.env
9
10
  PublishPort=127.0.0.1:18300:80
10
11
  Volume=/var/lib/matrix/config.json:/app/config.json
12
+ LogDriver=journald
11
13
  AutoUpdate=registry
12
14
 
15
+ [Service]
16
+ Restart=on-failure
17
+
13
18
  [Install]
14
19
  WantedBy=multi-user.target default.target
@@ -22,13 +22,10 @@ server {
22
22
 
23
23
  server_name <%= config['Domain'] %>;
24
24
 
25
- access_log /var/log/nginx/matrix.access.log;
26
- error_log /var/log/nginx/matrix.error.log;
27
-
28
25
  include config-lmm/errors.conf;
29
26
 
30
27
  location / {
31
- proxy_pass http://localhost:18300;
28
+ proxy_pass http://127.0.0.1:18300;
32
29
  include config-lmm/proxy.conf;
33
30
  }
34
31
  }
@@ -60,16 +57,13 @@ server {
60
57
 
61
58
  server_name <%= config['SynapseDomain'] %>;
62
59
 
63
- access_log /var/log/nginx/matrix.access.log;
64
- error_log /var/log/nginx/matrix.error.log;
65
-
66
60
  include config-lmm/errors.conf;
67
61
 
68
62
  location ~ ^(/_matrix|/_synapse/client) {
69
63
  # note: do not add a path (even a single /) after the port in `proxy_pass`,
70
64
  # otherwise nginx will canonicalise the URI and cause signature verification
71
65
  # errors.
72
- proxy_pass http://localhost:8008;
66
+ proxy_pass http://127.0.0.1:8008;
73
67
  include config-lmm/proxy.conf;
74
68
  proxy_intercept_errors off;
75
69