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
@@ -10,7 +10,6 @@ module ConfigLMM
10
10
  def actionArchiSteamFarmDeploy(id, target, activeState, context, options)
11
11
  if !target['Location'] || target['Location'] == '@me'
12
12
  deployNginxConfig(id, target, activeState, context, options)
13
- activeState['Location'] = '@me'
14
13
  end
15
14
  end
16
15
 
@@ -4,11 +4,17 @@ Description=Authentik Proxy Outpost container
4
4
  After=local-fs.target
5
5
 
6
6
  [Container]
7
- Image=ghcr.io/goauthentik/proxy:latest
7
+ ContainerName=Authentik-ProxyOutpost
8
+ Image=ghcr.io/goauthentik/proxy:2025.2
8
9
  EnvironmentFile=/var/lib/authentik/.config/containers/systemd/ProxyOutpost.env
10
+ Network=slirp4netns:allow_host_loopback=true
9
11
  PublishPort=127.0.0.1:19010:9000
10
12
  UserNS=keep-id:uid=1000,gid=1000
13
+ LogDriver=journald
11
14
  AutoUpdate=registry
12
15
 
16
+ [Service]
17
+ Restart=on-failure
18
+
13
19
  [Install]
14
20
  WantedBy=multi-user.target default.target
@@ -4,7 +4,8 @@ Description=Authentik Server container
4
4
  After=local-fs.target
5
5
 
6
6
  [Container]
7
- Image=ghcr.io/goauthentik/server:latest
7
+ ContainerName=Authentik-Server
8
+ Image=ghcr.io/goauthentik/server:2025.2
8
9
  Exec=server
9
10
  EnvironmentFile=/var/lib/authentik/.config/containers/systemd/Authentik.env
10
11
  Network=slirp4netns:allow_host_loopback=true
@@ -13,7 +14,11 @@ PublishPort=127.0.0.1:19300:9300
13
14
  UserNS=keep-id:uid=1000,gid=1000
14
15
  Volume=/var/lib/authentik/media:/media
15
16
  Volume=/var/lib/authentik/templates:/templates
17
+ LogDriver=journald
16
18
  AutoUpdate=registry
17
19
 
20
+ [Service]
21
+ Restart=on-failure
22
+
18
23
  [Install]
19
24
  WantedBy=multi-user.target default.target
@@ -4,7 +4,8 @@ Description=Authentik Worker container
4
4
  After=local-fs.target
5
5
 
6
6
  [Container]
7
- Image=ghcr.io/goauthentik/server:latest
7
+ ContainerName=Authentik-Worker
8
+ Image=ghcr.io/goauthentik/server:2025.2
8
9
  Exec=worker
9
10
  EnvironmentFile=/var/lib/authentik/.config/containers/systemd/Authentik.env
10
11
  Network=slirp4netns:allow_host_loopback=true
@@ -12,7 +13,11 @@ UserNS=keep-id:uid=1000,gid=1000
12
13
  Volume=/var/lib/authentik/media:/media
13
14
  Volume=/var/lib/authentik/templates:/templates
14
15
  Volume=/var/lib/authentik/certs:/certs
16
+ LogDriver=journald
15
17
  AutoUpdate=registry
16
18
 
19
+ [Service]
20
+ Restart=on-failure
21
+
17
22
  [Install]
18
23
  WantedBy=multi-user.target default.target
@@ -1,7 +1,7 @@
1
1
 
2
2
  # Upstream where your authentik server is hosted.
3
- upstream authentik {
4
- server localhost:19000;
3
+ upstream <%= config['Name'] %> {
4
+ server <%= config['Server'] %>:19000;
5
5
 
6
6
  # Improve performance by keeping some connections alive.
7
7
  keepalive 10;
@@ -20,22 +20,27 @@ server {
20
20
  listen [::]:443 ssl http2;
21
21
  <% end %>
22
22
 
23
+ include config-lmm/gateway-errors.conf;
24
+ include config-lmm/security.conf;
23
25
  include config-lmm/ssl.conf;
24
26
 
25
27
  server_name <%= config['Domain'] %>;
26
28
 
27
- access_log /var/log/nginx/authentik.access.log;
28
- error_log /var/log/nginx/authentik.error.log;
29
+ <% if config['CertName'] %>
30
+ ssl_certificate "/etc/letsencrypt/live/<%= config['CertName'] %>/fullchain.pem";
31
+ ssl_certificate_key "/etc/letsencrypt/live/<%= config['CertName'] %>/privkey.pem";
32
+ ssl_trusted_certificate "/etc/letsencrypt/live/<%= config['CertName'] %>/chain.pem";
33
+ <% end %>
29
34
 
30
- # Proxy site
31
35
  location / {
32
- proxy_pass http://authentik;
36
+ proxy_pass http://<%= config['Name'] %>;
33
37
  include config-lmm/proxy.conf;
34
38
  }
35
39
 
36
40
  <% if config['Outposts'].to_a.include?('Proxy') %>
37
41
  location /outpost.goauthentik.io {
38
- proxy_pass http://localhost:19010/outpost.goauthentik.io;
42
+ proxy_pass http://<%= config['Server'] %>:19010/outpost.goauthentik.io;
43
+ set $ProxyForwardedHost $http_x_authentik_host;
39
44
  include config-lmm/proxy.conf;
40
45
  }
41
46
  <% end %>
@@ -1,92 +1,257 @@
1
1
 
2
+ require 'json'
3
+
2
4
  module ConfigLMM
3
5
  module LMM
4
- class Authentik < Framework::NginxApp
6
+ class Authentik < Framework::Plugin
5
7
 
6
8
  USER = 'authentik'
7
9
  HOME_DIR = '/var/lib/authentik'
8
- HOST_IP = '10.0.2.2'
9
10
 
10
11
  def actionAuthentikBuild(id, target, state, context, options)
11
- self.writeNginxConfig(__dir__, 'Authentik', id, target, state, context, options)
12
+ Nginx.withConnection(local) do |nginxConnection|
13
+ nginxConnection.writeConfig(__dir__, 'Authentik', target, state, context, options)
14
+ end
12
15
  end
13
16
 
14
17
  def actionAuthentikDeploy(id, target, activeState, context, options)
15
- if target['Location'] && target['Location'] != '@me'
16
- uri = Addressable::URI.parse(target['Location'])
17
- case uri.scheme
18
- when 'ssh'
19
- self.class.sshStart(uri) do |ssh|
20
- self.prepareConfig(target, ssh)
21
-
22
- dbPassword = self.configurePostgreSQL(target['Database'], ssh)
23
- distroInfo = Framework::LinuxApp.currentDistroInfo(ssh)
24
- Framework::LinuxApp.configurePodmanServiceOverSSH(USER, HOME_DIR, 'Authentik IdP and SSO', distroInfo, ssh)
25
- self.class.sshExec!(ssh, "su --login #{USER} --shell /bin/sh --command 'mkdir -p ~/media'")
26
- self.class.sshExec!(ssh, "su --login #{USER} --shell /bin/sh --command 'mkdir -p ~/templates'")
27
- self.class.sshExec!(ssh, "su --login #{USER} --shell /bin/sh --command 'mkdir -p ~/certs'")
28
-
29
- path = Framework::LinuxApp::SYSTEMD_CONTAINERS_PATH.gsub('~', HOME_DIR)
30
- self.class.sshExec!(ssh, " echo 'AUTHENTIK_SECRET_KEY=#{SecureRandom.urlsafe_base64(60)}' > #{path}/Authentik.env")
31
- self.class.sshExec!(ssh, " echo 'AUTHENTIK_REDIS__HOST=#{HOST_IP}' >> #{path}/Authentik.env")
32
- self.class.sshExec!(ssh, " echo 'AUTHENTIK_POSTGRESQL__HOST=#{HOST_IP}' >> #{path}/Authentik.env")
33
- self.class.sshExec!(ssh, " echo 'AUTHENTIK_POSTGRESQL__PASSWORD=#{dbPassword}' >> #{path}/Authentik.env")
34
- self.class.sshExec!(ssh, "chown #{USER}:#{USER} #{path}/Authentik.env")
35
- self.class.sshExec!(ssh, "chmod 600 #{path}/Authentik.env")
36
-
37
- ssh.scp.upload!(__dir__ + '/Authentik-Server.container', path)
38
- ssh.scp.upload!(__dir__ + '/Authentik-Worker.container', path)
39
- self.class.sshExec!(ssh, "systemctl --user --machine=#{USER}@ daemon-reload")
40
- self.class.sshExec!(ssh, "systemctl --user --machine=#{USER}@ restart Authentik-Server")
41
- self.class.sshExec!(ssh, "systemctl --user --machine=#{USER}@ restart Authentik-Worker")
42
-
43
- Framework::LinuxApp.ensureServiceAutoStartOverSSH(NGINX_PACKAGE, ssh)
44
- self.writeNginxConfig(__dir__, 'Authentik', id, target, state, context, options)
45
- self.deployNginxConfig(id, target, activeState, context, options)
46
- Framework::LinuxApp.startServiceOverSSH(NGINX_PACKAGE, ssh)
47
-
48
- self.deployProxyOutpost(target, ssh)
18
+
19
+ if target['Location'].start_with?('http')
20
+ apiURL = target['Location']
21
+ configureAuthentik(apiURL, id, target, activeState, context, options)
22
+ else
23
+ deployServerAndReverseProxy(id, target, activeState, context, options)
24
+ end
25
+ end
26
+
27
+ def deployServerAndReverseProxy(id, target, activeState, context, options)
28
+
29
+ self.withConnection(target['Location'], target) do |connection|
30
+ Linux.withConnection(connection) do |linuxConnection|
31
+ target['Database'] ||= {}
32
+ target['Deploy'] = true unless target.key?('Deploy')
33
+
34
+ if target['Deploy']
35
+ if !target.key?('Proxy') || target['Proxy'] == false
36
+ self.deployServer(linuxConnection, target, activeState, context, options)
37
+ self.deployProxyOutpost(target, linuxConnection, options)
38
+ end
39
+
40
+ self.deployReverseProxy(id, linuxConnection, target, activeState, context, options)
49
41
  end
50
- else
51
- raise Framework::PluginProcessError.new("#{id}: Unknown protocol: #{uri.scheme}!")
52
42
  end
53
- else
54
- # TODO
55
43
  end
44
+
45
+ apiURL = "https://#{target['Domain']}/"
46
+ configureAuthentik(apiURL, id, target, activeState, context, options)
56
47
  end
57
48
 
58
- def deployProxyOutpost(target, ssh = nil)
59
- return unless target['Outposts'].to_a.include?('Proxy')
49
+ def deployServer(linuxConnection, target, activeState, context, options)
50
+ dbPassword = self.configurePostgreSQL(target['Database'], linuxConnection, options)
51
+
52
+ Podman.ensurePresent(linuxConnection, options)
53
+ Podman.createUser(USER, HOME_DIR, 'Authentik IdP and SSO', linuxConnection, options)
54
+ linuxConnection.withUserShell(USER) do |shell|
55
+ shell.createDirs(options, '~/media', '~/templates', '~/certs')
56
+ end
57
+
58
+ path = Podman.containersPath(HOME_DIR)
59
+ secretKey = context.secrets.load(target['SecretId'], 'SECRET_KEY')
60
+ if secretKey.nil?
61
+ secretKey = SecureRandom.urlsafe_base64(60)
62
+ context.secrets.store(target['SecretId'], 'SECRET_KEY', secretKey) unless options['dry']
63
+ end
64
+ linuxConnection.fileWrite("#{path}/Authentik.env", "AUTHENTIK_SECRET_KEY=#{secretKey}", { **options, hide: true })
65
+
66
+ valkeyHost = Podman.updateHost(target['Valkey'].to_h['Host'])
67
+ linuxConnection.fileAppend("#{path}/Authentik.env", "AUTHENTIK_REDIS__HOST=#{valkeyHost}", options)
68
+ if target['Valkey'].to_h['SecretId']
69
+ valkeyPassword = context.secrets.load(target['Valkey']['SecretId'], 'VALKEY_PASSWORD')
70
+ if !valkeyPassword.nil?
71
+ linuxConnection.fileAppend("#{path}/Authentik.env", "AUTHENTIK_REDIS__PASSWORD=#{valkeyPassword}", { **options, hide: true })
72
+ end
73
+ end
74
+
75
+ postgresHost = Podman.updateHost(target['Database'].to_h['HostName'])
76
+ linuxConnection.fileAppend("#{path}/Authentik.env", "AUTHENTIK_POSTGRESQL__HOST=#{postgresHost}", options)
77
+ linuxConnection.fileAppend("#{path}/Authentik.env", "AUTHENTIK_POSTGRESQL__PASSWORD=#{dbPassword}", { **options, hide: true })
78
+
79
+ if !target['SMTP'].to_h.empty?
80
+ host = target['SMTP']['Host']
81
+ host = Podman::HOST_IP if host.to_s.empty? || ['localhost', '127.0.0.1'].include?(host)
82
+
83
+ linuxConnection.fileAppend("#{path}/Authentik.env", "AUTHENTIK_EMAIL__HOST=#{host}", options)
84
+
85
+ if target['SMTP']['Port']
86
+ linuxConnection.fileAppend("#{path}/Authentik.env", "AUTHENTIK_EMAIL__PORT=#{target['SMTP']['Port']}", options)
87
+ end
88
+
89
+ if target['SMTP']['Username']
90
+ linuxConnection.fileAppend("#{path}/Authentik.env", "AUTHENTIK_EMAIL__USERNAME=#{target['SMTP']['Username']}", options)
91
+ end
60
92
 
61
- path = Framework::LinuxApp::SYSTEMD_CONTAINERS_PATH.gsub('~', HOME_DIR)
62
- self.class.exec("echo 'AUTHENTIK_HOST=https://#{target['Domain'].downcase}' > #{path}/ProxyOutpost.env", ssh)
63
- self.class.exec("echo 'AUTHENTIK_INSECURE=false' >> #{path}/ProxyOutpost.env", ssh)
64
- self.class.exec(" echo 'AUTHENTIK_TOKEN=#{ENV['AUTHENTIK_TOKEN']}' >> #{path}/ProxyOutpost.env", ssh)
65
- self.class.exec("chown #{USER}:#{USER} #{path}/ProxyOutpost.env", ssh)
66
- self.class.exec("chmod 600 #{path}/ProxyOutpost.env", ssh)
93
+ if target['SMTP']['SecretId']
94
+ smtpPassword = context.secrets.load(target['SMTP']['SecretId'], target['SMTP']['Username'].upcase + '_PASSWORD')
95
+ linuxConnection.fileAppend("#{path}/Authentik.env", "AUTHENTIK_EMAIL__PASSWORD=#{smtpPassword}", { **options, hide: true })
96
+ end
97
+
98
+ if target['SMTP']['Port'] == 465
99
+ linuxConnection.fileAppend("#{path}/Authentik.env", "AUTHENTIK_EMAIL__USE_TLS=true", options)
100
+ end
67
101
 
68
- if ssh.nil?
69
- self.class.exec("cp #{__dir__ + '/Authentik-ProxyOutpost.container'} #{path}/")
102
+ if target['SMTP']['From']
103
+ linuxConnection.fileAppend("#{path}/Authentik.env", "AUTHENTIK_EMAIL__FROM=#{target['SMTP']['From']}", options)
104
+ end
70
105
  else
71
- ssh.scp.upload!(__dir__ + '/Authentik-ProxyOutpost.container', path)
106
+ linuxConnection.fileAppend("#{path}/Authentik.env", "AUTHENTIK_EMAIL__HOST=#{Podman::HOST_IP}", options)
72
107
  end
73
108
 
74
- self.class.exec("systemctl --user --machine=#{USER}@ daemon-reload", ssh)
75
- self.class.exec("systemctl --user --machine=#{USER}@ restart Authentik-ProxyOutpost", ssh)
109
+ adminPassword = context.secrets.load(target['SecretId'], 'ADMIN_PASSWORD')
110
+ if adminPassword.nil?
111
+ raise 'Missing Authentik Admin.EMail' unless target['Admin'].to_h.key?('EMail')
112
+ adminPassword = SecureRandom.urlsafe_base64(30)
113
+ if !options['dry']
114
+ context.secrets.store(target['SecretId'], 'ADMIN_PASSWORD', adminPassword)
115
+ context.secrets.print("Authentik Admin password", adminPassword)
116
+ end
117
+ end
118
+ if target['Admin'].to_h.key?('EMail')
119
+ email = target['Admin']['EMail']
120
+ linuxConnection.fileAppend("#{path}/Authentik.env", "AUTHENTIK_BOOTSTRAP_EMAIL=#{email}", options)
121
+ linuxConnection.fileAppend("#{path}/Authentik.env", "AUTHENTIK_BOOTSTRAP_PASSWORD=#{adminPassword}", { **options, hide: true })
122
+ end
123
+
124
+ adminToken = context.secrets.load(target['SecretId'], 'ADMIN_TOKEN')
125
+ if adminToken.nil?
126
+ adminToken = SecureRandom.urlsafe_base64(60)
127
+ if !options['dry']
128
+ context.secrets.store(target['SecretId'], 'ADMIN_TOKEN', adminToken) unless options['dry']
129
+ context.secrets.print("Authentik Admin token", adminToken)
130
+ end
131
+ end
132
+ linuxConnection.fileAppend("#{path}/Authentik.env", "AUTHENTIK_BOOTSTRAP_TOKEN=#{adminToken}", { **options, hide: true })
133
+
134
+ linuxConnection.setUserGroup("#{path}/Authentik.env", USER, USER, options)
135
+ linuxConnection.setPrivate("#{path}/Authentik.env", options)
136
+
137
+ linuxConnection.upload(__dir__ + '/Authentik-Server.container', path, options)
138
+ linuxConnection.upload(__dir__ + '/Authentik-Worker.container', path, options)
139
+
140
+ if target['Proxy'] == false
141
+ linuxConnection.fileReplace("#{path}/Authentik-Server.container", 'PublishPort=127.0.0.1:19000:', 'PublishPort=0.0.0.0:19000:', options)
142
+ linuxConnection.firewallAddPort('19000/tcp', options)
143
+ end
144
+
145
+ linuxConnection.reloadUserServices(USER, options)
146
+ linuxConnection.restartUserService(USER, 'Authentik-Server', options)
147
+ linuxConnection.restartUserService(USER, 'Authentik-Worker', options)
148
+ end
149
+
150
+ def deployReverseProxy(id, linuxConnection, target, activeState, context, options)
151
+ if !target.key?('Proxy') || target['Proxy']
152
+ raise Framework::PluginProcessError.new('Domain field must be set!') unless target['Domain']
153
+ Nginx.withConnection(linuxConnection) do |nginxConnection|
154
+ target['Server'] = '127.0.0.1' unless target['Server']
155
+ target['ConfigName'] = target['Name']
156
+ nginxConnection.provision(__dir__, 'Authentik', target, activeState, context, options)
157
+ end
158
+ end
76
159
  end
77
160
 
78
- def prepareConfig(target, ssh)
79
- target['Database'] ||= {}
161
+ def configureAuthentik(apiURL, id, target, activeState, context, options)
162
+ if target['Groups'] || target['Providers'] || target['Applications']
163
+ prompt.say('Configuring specified settings for Authentik is not implemented! You\'ll have to configure those manually.', :color => :magenta)
164
+ end
165
+ end
80
166
 
81
- raise Framework::PluginProcessError.new('Domain field must be set!') unless target['Domain']
167
+ def waitTilReady(baseURL, target, linuxConnection, options)
168
+ if !options['dry']
169
+ timeout = 3600 # 1h
170
+ loop do
171
+ begin
172
+ linuxConnection.exec("curl --no-progress-meter --show-error --fail #{baseURL}/", false, options)
173
+ break
174
+ rescue
175
+ timeout -= 30
176
+ end
177
+ raise "Timeout while waiting #{baseURL}/ to be ready!" if timeout <= 0
178
+ sleep(30)
179
+ end
180
+ end
181
+ end
82
182
 
83
- Framework::LinuxApp.ensurePackages([NGINX_PACKAGE], ssh)
84
- self.class.prepareNginxConfig(target, ssh)
183
+ def viewToken(baseURL, target, tokenIdentifier, adminToken, linuxConnection, options)
184
+ url = "#{baseURL}/api/v3/core/tokens/#{tokenIdentifier}/view_key/"
185
+ result = linuxConnection.http(url, options, { 'Authorization' => 'Bearer ' + adminToken })
186
+ data = JSON.parse(result)
187
+ return nil unless data['key']
188
+ data['key']
85
189
  end
86
190
 
87
- def configurePostgreSQL(settings, ssh)
191
+ def loadProxyOutpostToken(baseURL, target, linuxConnection, options)
192
+ return '' if options['dry']
193
+ adminToken = context.secrets.load(target['SecretId'], 'ADMIN_TOKEN')
194
+ if adminToken.nil?
195
+ prompt.say("Authentik Admin token missing! You need to set secret: #{context.secrets.getID(target['SecretId'], 'ADMIN_TOKEN')}", :color => :magenta)
196
+ raise 'Authentik Admin token missing!'
197
+ end
198
+ url = "#{baseURL}/api/v3/outposts/instances/?name__iexact=authentik+Embedded+Outpost"
199
+ result = JSON.parse(linuxConnection.http(url, options, { 'Authorization' => 'Bearer ' + adminToken }))
200
+ if result['results'].to_a.empty?
201
+ prompt.say(result, :color => :red)
202
+ raise 'Failed to get Embedded Proxy Outpost info!'
203
+ end
204
+
205
+ tokenIdentifier = result['results'][0]['token_identifier']
206
+ tokenValue = viewToken(baseURL, target, tokenIdentifier, adminToken, linuxConnection, options)
207
+ raise 'Failed to get Embedded Proxy Outpost token!' if tokenValue.nil?
208
+ context.secrets.store(target['SecretId'], 'PROXYOUTPOST_TOKEN', tokenValue)
209
+ tokenValue
210
+ end
211
+
212
+ def deployProxyOutpost(target, linuxConnection, options)
213
+ return unless target['Outposts'].to_a.include?('Proxy')
214
+
215
+ proxyOutpostToken = context.secrets.load(target['SecretId'], 'PROXYOUTPOST_TOKEN')
216
+ if proxyOutpostToken.nil?
217
+ baseURL = "http://127.0.0.1:19000"
218
+ waitTilReady(baseURL, target, linuxConnection, options)
219
+ proxyOutpostToken = loadProxyOutpostToken(baseURL, target, linuxConnection, options)
220
+ end
221
+
222
+ Podman.ensurePresent(linuxConnection, options)
223
+ path = Podman.containersPath(HOME_DIR)
224
+ linuxConnection.fileWrite("#{path}/ProxyOutpost.env", "AUTHENTIK_HOST=https://#{target['Domain'].downcase}", options)
225
+ linuxConnection.fileAppend("#{path}/ProxyOutpost.env", 'AUTHENTIK_INSECURE=false', options)
226
+ linuxConnection.fileAppend("#{path}/ProxyOutpost.env", "AUTHENTIK_TOKEN=#{proxyOutpostToken}", { **options, hide: true })
227
+ valkeyHost = Podman.updateHost(target['Valkey'].to_h['Host'])
228
+ linuxConnection.fileAppend("#{path}/ProxyOutpost.env", "AUTHENTIK_REDIS__HOST=#{valkeyHost}", options)
229
+ if target['Valkey'].to_h['SecretId']
230
+ valkeyPassword = context.secrets.load(target['Valkey']['SecretId'], 'VALKEY_PASSWORD')
231
+ if !valkeyPassword.nil?
232
+ linuxConnection.fileAppend("#{path}/ProxyOutpost.env", "AUTHENTIK_REDIS__PASSWORD=#{valkeyPassword}", { **options, hide: true })
233
+ end
234
+ end
235
+
236
+ linuxConnection.setUserGroup("#{path}/ProxyOutpost.env", USER, USER, options)
237
+ linuxConnection.setPrivate("#{path}/ProxyOutpost.env", options)
238
+
239
+ linuxConnection.upload(__dir__ + '/Authentik-ProxyOutpost.container', path)
240
+
241
+ if target['Proxy'] == false
242
+ linuxConnection.fileReplace("#{path}/Authentik-ProxyOutpost.container", 'PublishPort=127.0.0.1:19010:', 'PublishPort=0.0.0.0:19010:', options)
243
+ linuxConnection.firewallAddPort('19010/tcp', options)
244
+ end
245
+
246
+ linuxConnection.reloadUserServices(USER, options)
247
+ linuxConnection.restartUserService(USER, 'Authentik-ProxyOutpost', options)
248
+ end
249
+
250
+ def configurePostgreSQL(dbSettings, linuxConnection, options)
88
251
  password = SecureRandom.alphanumeric(20)
89
- PostgreSQL.createRemoteUserAndDBOverSSH(settings, USER, password, ssh)
252
+ PostgreSQL.withConnection(dbSettings, linuxConnection) do |postgresConnection|
253
+ postgresConnection.createUserAndDB(USER, password, options)
254
+ end
90
255
  password
91
256
  end
92
257
 
@@ -22,9 +22,6 @@ server {
22
22
 
23
23
  server_name <%= config['Domain'] %>;
24
24
 
25
- access_log /var/log/nginx/bookstack.access.log;
26
- error_log /var/log/nginx/bookstack.error.log;
27
-
28
25
  include config-lmm/errors.conf;
29
26
  include config-lmm/security.conf;
30
27
 
@@ -4,12 +4,17 @@ Description=BookStack container
4
4
  After=local-fs.target
5
5
 
6
6
  [Container]
7
+ ContainerName=BookStack
7
8
  Image=ghcr.io/linuxserver/bookstack:latest
8
9
  EnvironmentFile=/var/lib/bookstack/.config/containers/systemd/BookStack.env
9
10
  Network=slirp4netns:allow_host_loopback=true
10
11
  PublishPort=127.0.0.1:18200:80
11
12
  Volume=/var/lib/bookstack/config:/config
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
@@ -30,10 +30,16 @@ module ConfigLMM
30
30
  self.class.exec(" echo 'APP_URL=https://#{target['Domain']}' >> #{path}/BookStack.env", ssh)
31
31
 
32
32
  if target['OIDC'] && target['OIDC']['Issuer']
33
+
34
+ secretId = target['OIDC']['SecretId']
35
+ secretId = target['SecretId'] unless secretId
36
+ clientId = context.secrets.load(secretId, 'OIDC_CLIENT_ID')
37
+ clientSecret = context.secrets.load(secretId, 'OIDC_CLIENT_SECRET')
38
+
33
39
  self.class.exec(" echo 'AUTH_METHOD=oidc' >> #{path}/BookStack.env", ssh)
34
40
  self.class.exec(" echo 'AUTH_AUTO_INITIATE=true' >> #{path}/BookStack.env", ssh)
35
- self.class.exec(" echo 'OIDC_CLIENT_ID=#{ENV['BOOKSTACK_OIDC_CLIENT_ID']}' >> #{path}/BookStack.env", ssh)
36
- self.class.exec(" echo 'OIDC_CLIENT_SECRET=#{ENV['BOOKSTACK_OIDC_CLIENT_SECRET']}' >> #{path}/BookStack.env", ssh)
41
+ self.class.exec(" echo 'OIDC_CLIENT_ID=#{clientId}' >> #{path}/BookStack.env", ssh)
42
+ self.class.exec(" echo 'OIDC_CLIENT_SECRET=#{clientSecret}' >> #{path}/BookStack.env", ssh)
37
43
  self.class.exec(" echo 'OIDC_ISSUER=#{target['OIDC']['Issuer']}' >> #{path}/BookStack.env", ssh)
38
44
  self.class.exec(" echo 'OIDC_ISSUER_DISCOVER=true' >> #{path}/BookStack.env", ssh)
39
45
  self.class.exec(" echo 'OIDC_USER_TO_GROUPS=true' >> #{path}/BookStack.env", ssh)
@@ -45,7 +51,12 @@ module ConfigLMM
45
51
  self.class.exec(" echo 'MAIL_HOST=#{host}' >> #{path}/BookStack.env", ssh)
46
52
  self.class.exec(" echo 'MAIL_PORT=#{target['SMTP']['Port']}' >> #{path}/BookStack.env", ssh)
47
53
  self.class.exec(" echo 'MAIL_USERNAME=#{target['SMTP']['Username']}' >> #{path}/BookStack.env", ssh)
48
- self.class.exec(" echo 'MAIL_PASSWORD=#{ENV['BOOKSTACK_SMTP_PASSWORD']}' >> #{path}/BookStack.env", ssh)
54
+
55
+ if target['SMTP']['SecretId'] && target['SMTP']['Username']
56
+ smtpPassword = context.secrets.load(target['SMTP']['SecretId'], target['SMTP']['Username'].upcase + '_PASSWORD')
57
+ self.class.exec(" echo 'MAIL_PASSWORD=#{smtpPassword}' >> #{path}/BookStack.env", ssh)
58
+ end
59
+
49
60
  self.class.exec(" echo 'MAIL_FROM=#{target['SMTP']['From']}' >> #{path}/BookStack.env", ssh)
50
61
  end
51
62
 
@@ -6,36 +6,26 @@ module ConfigLMM
6
6
  SERVICE_NAME = 'cassandra'
7
7
 
8
8
  def actionCassandraDeploy(id, target, activeState, context, options)
9
- plugins[:Linux].ensurePackage(PACKAGE_NAME, target['Location'])
10
- plugins[:Linux].ensureServiceAutoStart(SERVICE_NAME, target['Location'])
9
+ self.withConnection(target['Location'], target) do |connection|
10
+ Linux.withConnection(connection) do |linuxConnection|
11
+ linuxConnection.ensurePackage(PACKAGE_NAME, options)
12
+ linuxConnection.ensureServiceAutoStart(SERVICE_NAME, options)
11
13
 
12
- if target['Location'] && target['Location'] != '@me'
13
- uri = Addressable::URI.parse(target['Location'])
14
- raise Framework::PluginProcessError.new("#{id}: Unknown Protocol: #{uri.scheme}!") if uri.scheme != 'ssh'
15
-
16
- self.class.sshStart(uri) do |ssh|
17
- distroInfo = Framework::LinuxApp.currentDistroInfo(ssh)
18
- configFile = '/etc/cassandra/cassandra.yaml'
19
- if distroInfo['Name'] == 'openSUSE Leap'
14
+ if linuxConnection.distroInfo['Name'] == 'openSUSE Leap'
20
15
  configFile = '/etc/cassandra/conf/cassandra.yaml'
21
16
  end
22
17
 
23
- cmd = "sed -i 's|^uuid_sstable_identifiers_enabled:.*|uuid_sstable_identifiers_enabled: true|' #{configFile}"
24
- self.class.sshExec!(ssh, cmd)
18
+ linuxConnection.fileReplace(configFile, '^uuid_sstable_identifiers_enabled:.*', 'uuid_sstable_identifiers_enabled: true', options)
25
19
  if target['ClusterName']
26
- cmd = "sed -i 's|^cluster_name:.*|cluster_name: #{target['ClusterName']}|' #{configFile}"
27
- self.class.sshExec!(ssh, cmd)
20
+ linuxConnection.fileReplace(configFile, '^cluster_name:.*', "cluster_name: #{target['ClusterName']}", options)
28
21
  end
22
+
23
+ linuxConnection.restartService(SERVICE_NAME, options)
29
24
  end
30
- else
31
- # TODO
32
25
  end
33
-
34
- plugins[:Linux].startService(SERVICE_NAME, target['Location'])
35
26
  end
36
27
 
37
28
  end
38
29
 
39
30
  end
40
31
  end
41
-
@@ -0,0 +1,28 @@
1
+
2
+ [Unit]
3
+ Description=ClickHouse container
4
+ After=local-fs.target
5
+
6
+ [Container]
7
+ ContainerName=ClickHouse
8
+ Image=docker.io/clickhouse/clickhouse-server:latest
9
+ EnvironmentFile=/var/lib/clickhouse/.config/containers/systemd/ClickHouse.env
10
+ Network=slirp4netns:allow_host_loopback=true
11
+ PublishPort=0.0.0.0:8123:8123
12
+ PublishPort=0.0.0.0:19100:9000
13
+ UserNS=keep-id:uid=1000,gid=1000
14
+ Volume=/var/lib/clickhouse/server/config.d:/etc/clickhouse-server/config.d
15
+ Volume=/var/lib/clickhouse/server/users.d:/etc/clickhouse-server/users.d
16
+ Volume=/var/lib/clickhouse/data:/var/lib/clickhouse
17
+ Volume=/var/lib/clickhouse/logs:/var/log/clickhouse-server
18
+ LogDriver=journald
19
+ AddCapability=IPC_LOCK
20
+ AddCapability=SYS_NICE
21
+ AutoUpdate=registry
22
+
23
+ [Service]
24
+ TimeoutStartSec=6min
25
+ Restart=on-failure
26
+
27
+ [Install]
28
+ WantedBy=multi-user.target default.target