ConfigLMM 0.2.0 → 0.4.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 (121) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +67 -0
  3. data/Examples/Implemented.mm.yaml +75 -1
  4. data/Plugins/Apps/Authentik/Authentik-ProxyOutpost.container +14 -0
  5. data/Plugins/Apps/Authentik/Authentik-Server.container +19 -0
  6. data/Plugins/Apps/Authentik/Authentik-Worker.container +18 -0
  7. data/Plugins/Apps/Authentik/Authentik.conf.erb +42 -0
  8. data/Plugins/Apps/Authentik/Authentik.lmm.rb +95 -0
  9. data/Plugins/Apps/BookStack/BookStack.conf.erb +41 -0
  10. data/Plugins/Apps/BookStack/BookStack.container +15 -0
  11. data/Plugins/Apps/BookStack/BookStack.lmm.rb +80 -0
  12. data/Plugins/Apps/Cassandra/Cassandra.lmm.rb +41 -0
  13. data/Plugins/Apps/Discourse/Discourse-Sidekiq.container +17 -0
  14. data/Plugins/Apps/Discourse/Discourse.conf.erb +41 -0
  15. data/Plugins/Apps/Discourse/Discourse.container +17 -0
  16. data/Plugins/Apps/Discourse/Discourse.lmm.rb +95 -0
  17. data/Plugins/Apps/Dovecot/Dovecot.lmm.rb +171 -0
  18. data/Plugins/Apps/ERPNext/ERPNext-Frontend.container +19 -0
  19. data/Plugins/Apps/ERPNext/ERPNext-Queue.container +17 -0
  20. data/Plugins/Apps/ERPNext/ERPNext-Scheduler.container +17 -0
  21. data/Plugins/Apps/ERPNext/ERPNext-Websocket.container +19 -0
  22. data/Plugins/Apps/ERPNext/ERPNext.container +18 -0
  23. data/Plugins/Apps/ERPNext/ERPNext.lmm.rb +193 -0
  24. data/Plugins/Apps/ERPNext/ERPNext.network +12 -0
  25. data/Plugins/Apps/ERPNext/sites/apps.json +10 -0
  26. data/Plugins/Apps/ERPNext/sites/apps.txt +3 -0
  27. data/Plugins/Apps/ERPNext/sites/common_site_config.json +11 -0
  28. data/Plugins/Apps/GitLab/GitLab.container +18 -0
  29. data/Plugins/Apps/GitLab/GitLab.lmm.rb +100 -0
  30. data/Plugins/Apps/LetsEncrypt/LetsEncrypt.lmm.rb +57 -0
  31. data/Plugins/Apps/LetsEncrypt/hooks/dovecot.sh +2 -0
  32. data/Plugins/Apps/LetsEncrypt/hooks/nginx.sh +2 -0
  33. data/Plugins/Apps/LetsEncrypt/hooks/postfix.sh +2 -0
  34. data/Plugins/Apps/LetsEncrypt/renew-certificates.service +7 -0
  35. data/Plugins/Apps/LetsEncrypt/renew-certificates.timer +12 -0
  36. data/Plugins/Apps/LetsEncrypt/rfc2136.ini +11 -0
  37. data/Plugins/Apps/MariaDB/MariaDB.lmm.rb +115 -0
  38. data/Plugins/Apps/Matrix/Element.container +14 -0
  39. data/Plugins/Apps/Matrix/Matrix.conf.erb +49 -5
  40. data/Plugins/Apps/Matrix/Matrix.lmm.rb +86 -1
  41. data/Plugins/Apps/Matrix/Synapse.container +17 -0
  42. data/Plugins/Apps/Matrix/config.json +50 -0
  43. data/Plugins/Apps/Matrix/homeserver.yaml +70 -0
  44. data/Plugins/Apps/Matrix/log.config +30 -0
  45. data/Plugins/Apps/Nextcloud/Nextcloud.conf.erb +48 -10
  46. data/Plugins/Apps/Nextcloud/Nextcloud.lmm.rb +83 -1
  47. data/Plugins/Apps/Nextcloud/config.php +18 -0
  48. data/Plugins/Apps/Nginx/conf.d/configlmm.conf +71 -0
  49. data/Plugins/Apps/Nginx/config-lmm/errors.conf +11 -5
  50. data/Plugins/Apps/Nginx/config-lmm/proxy.conf +5 -1
  51. data/Plugins/Apps/Nginx/main.conf.erb +31 -0
  52. data/Plugins/Apps/Nginx/nginx.conf +3 -68
  53. data/Plugins/Apps/Nginx/nginx.lmm.rb +83 -22
  54. data/Plugins/Apps/Nginx/proxy.conf.erb +13 -3
  55. data/Plugins/Apps/Odoo/Odoo.conf.erb +30 -13
  56. data/Plugins/Apps/Odoo/Odoo.container +18 -0
  57. data/Plugins/Apps/Odoo/Odoo.lmm.rb +62 -2
  58. data/Plugins/Apps/Odoo/odoo.conf +37 -0
  59. data/Plugins/Apps/OpenVidu/Ingress.container +18 -0
  60. data/Plugins/Apps/OpenVidu/OpenVidu.conf.erb +34 -0
  61. data/Plugins/Apps/OpenVidu/OpenVidu.container +16 -0
  62. data/Plugins/Apps/OpenVidu/OpenVidu.lmm.rb +90 -0
  63. data/Plugins/Apps/OpenVidu/OpenViduCall.conf.erb +35 -0
  64. data/Plugins/Apps/OpenVidu/OpenViduCall.container +15 -0
  65. data/Plugins/Apps/OpenVidu/ingress.yaml +10 -0
  66. data/Plugins/Apps/OpenVidu/livekit.yaml +13 -0
  67. data/Plugins/Apps/PHP-FPM/PHP-FPM.lmm.rb +95 -0
  68. data/Plugins/Apps/Peppermint/Peppermint.conf.erb +60 -0
  69. data/Plugins/Apps/Peppermint/Peppermint.container +15 -0
  70. data/Plugins/Apps/Peppermint/Peppermint.lmm.rb +58 -0
  71. data/Plugins/Apps/Postfix/Postfix.lmm.rb +165 -31
  72. data/Plugins/Apps/Postfix/smtpd.conf +3 -0
  73. data/Plugins/Apps/PostgreSQL/PostgreSQL.lmm.rb +242 -24
  74. data/Plugins/Apps/Roundcube/Roundcube.conf.erb +75 -0
  75. data/Plugins/Apps/Roundcube/Roundcube.lmm.rb +145 -0
  76. data/Plugins/Apps/SSH/SSH.lmm.rb +51 -0
  77. data/Plugins/Apps/Tunnel/tunnel.lmm.rb +63 -0
  78. data/Plugins/Apps/Tunnel/tunnelTCP.service +9 -0
  79. data/Plugins/Apps/Tunnel/tunnelTCP.socket +9 -0
  80. data/Plugins/Apps/Tunnel/tunnelUDP.service +9 -0
  81. data/Plugins/Apps/Tunnel/tunnelUDP.socket +9 -0
  82. data/Plugins/Apps/UVdesk/UVdesk.conf.erb +52 -0
  83. data/Plugins/Apps/UVdesk/UVdesk.lmm.rb +85 -0
  84. data/Plugins/Apps/Valkey/Valkey.lmm.rb +34 -1
  85. data/Plugins/Apps/Vaultwarden/Vaultwarden.conf.erb +35 -18
  86. data/Plugins/Apps/Vaultwarden/Vaultwarden.container +16 -0
  87. data/Plugins/Apps/Vaultwarden/Vaultwarden.lmm.rb +46 -3
  88. data/Plugins/Apps/Wiki.js/Wiki.js.conf.erb +42 -0
  89. data/Plugins/Apps/Wiki.js/Wiki.js.container +15 -0
  90. data/Plugins/Apps/Wiki.js/Wiki.js.lmm.rb +61 -0
  91. data/Plugins/Apps/gollum/gollum.conf.erb +84 -19
  92. data/Plugins/Apps/gollum/gollum.container +15 -0
  93. data/Plugins/Apps/gollum/gollum.lmm.rb +48 -11
  94. data/Plugins/OS/Linux/Debian/preseed.cfg.erb +62 -0
  95. data/Plugins/OS/Linux/Distributions.yaml +42 -0
  96. data/Plugins/OS/Linux/Flavours.yaml +11 -0
  97. data/Plugins/OS/Linux/Linux.lmm.rb +362 -41
  98. data/Plugins/OS/Linux/Packages.yaml +88 -5
  99. data/Plugins/OS/Linux/Proxmox/answer.toml.erb +30 -0
  100. data/Plugins/OS/Linux/WireGuard/WireGuard.lmm.rb +137 -0
  101. data/Plugins/OS/Linux/WireGuard/wg0.conf.erb +15 -0
  102. data/Plugins/OS/Linux/systemd/systemd.lmm.rb +28 -0
  103. data/Plugins/OS/Linux/systemd/user-0.slice +9 -0
  104. data/Plugins/OS/Linux/systemd/user@.service.d/delegate.conf +3 -0
  105. data/Plugins/Platforms/GoDaddy/GoDaddy.lmm.rb +7 -3
  106. data/Plugins/Platforms/libvirt/libvirt.lmm.rb +3 -2
  107. data/Plugins/Services/DNS/PowerDNS.lmm.rb +158 -8
  108. data/README.md +6 -0
  109. data/bootstrap.sh +92 -0
  110. data/lib/ConfigLMM/Framework/plugins/dns.rb +1 -2
  111. data/lib/ConfigLMM/Framework/plugins/linuxApp.rb +249 -45
  112. data/lib/ConfigLMM/Framework/plugins/nginxApp.rb +56 -7
  113. data/lib/ConfigLMM/Framework/plugins/plugin.rb +112 -16
  114. data/lib/ConfigLMM/cli.rb +3 -1
  115. data/lib/ConfigLMM/commands/cleanup.rb +1 -0
  116. data/lib/ConfigLMM/commands/configsCommand.rb +3 -1
  117. data/lib/ConfigLMM/io/configList.rb +3 -1
  118. data/lib/ConfigLMM/state.rb +10 -2
  119. data/lib/ConfigLMM/version.rb +1 -1
  120. metadata +82 -3
  121. data/Plugins/Apps/Nginx/main.conf +0 -30
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a8ee6e7ca0b1e3cf4dd9e1007aa696d763ab522c2c1cfc4a401e55ccdeefc4e3
4
- data.tar.gz: 71c10651774b7c6ce347cf3fe9bc2df08ca388244ad8cf0cdbaa77c1f8beb1a7
3
+ metadata.gz: e75cd300255c00348e10301216861bbc10e1fd1473e35a19c0b879f6c90f433c
4
+ data.tar.gz: b75628e73fa064c403e4dc51cb69997c1e5d8215536df9f961ce8861bf405757
5
5
  SHA512:
6
- metadata.gz: 17cc1304b94186312fd2c25779234ba4c0354c8dfcc971eeff5d000ebdb1d29138f7decfa5f175f154cbc1174d6e3b5ef3f7077caa8013d53a493c8c2a7ccf7d
7
- data.tar.gz: 50b169c6147cbd7b02da3e0fc3b264b09271bb83813330196a546da4d976c5071b2d53e534e47512fca85927ea5201e1f085b10601febcfaacf0d41ffec7c362
6
+ metadata.gz: f357dba4ec543ed5b7d1ac66e678df83bb5bcf0c22793b80f70a30e6c22648837ca259d429ccff099fb77fb640c87ecafcf679b052d34ff45f1764ca650eedd5
7
+ data.tar.gz: 954e1f8b9720c7ffaa4f6173fe28ead5e1dd706d488b950172651273016422df300a2fd81a70652aaeb506f84bfa755902c6c198849821d72decf551779337e2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,70 @@
1
+ ## [0.4.0] - 2024-10-04
2
+
3
+ Implement:
4
+ - Authentik: Outpost deployment
5
+ - gollum: Authentik authentication
6
+ - MariaDB - https://mariadb.org/
7
+ - BookStack - https://www.bookstackapp.com/
8
+ - Discourse - https://www.discourse.org/
9
+ - OpenVidu - https://openvidu.io/
10
+ - Matrix server - https://matrix.org/
11
+ - Wiki.js - https://js.wiki/
12
+ - ERPNext - https://erpnext.com/
13
+ - Let's Encrypt - https://letsencrypt.org/
14
+ - Roundcube - https://roundcube.net/
15
+ - Tunnel support
16
+ - Support Proxmox VE distro - https://www.proxmox.com/en/proxmox-virtual-environment/overview
17
+ - Support Debian distro - https://www.debian.org/
18
+
19
+ Other improvements:
20
+ - bootstrap.sh script
21
+ - Peppermint
22
+ - Vaultwarden
23
+ - Nginx
24
+ - Valkey
25
+ - PostgreSQL
26
+ - Dovecot
27
+ - GitLab
28
+ - Linux
29
+ - PowerDNS
30
+ - GoDaddy
31
+ - NginxProxy
32
+ - Nextcloud
33
+ - Cassandra
34
+ - Postfix: Implement cleanup/uninstall functionality
35
+ - WireGuard: Implement cleanup/uninstall functionality
36
+ - Various other improvements
37
+
38
+ ## [0.3.0] - 2024-08-13
39
+
40
+ Implement:
41
+ - systemd UserCgroups
42
+ - Authentik - https://goauthentik.io/
43
+ - WireGuard - https://www.wireguard.com/
44
+ - Dovecot - https://www.dovecot.org/
45
+ - Nextcloud - https://nextcloud.com/
46
+ - Vaultwarden - https://github.com/dani-garcia/vaultwarden
47
+ - Linux: fstab tmpfs
48
+ - Linux: Network config
49
+ - Linux: deployLocal() and Execute commands
50
+ - SSH settings
51
+ - Odoo - https://www.odoo.com/
52
+ - GitLab - https://about.gitlab.com/
53
+ - Partial UVdesk - https://www.uvdesk.com/en/ticket-management-system/
54
+ - Peppermint - https://peppermint.sh/
55
+ - Cassandra - https://cassandra.apache.org/_/index.html
56
+
57
+ Other improvements:
58
+ - Add bootstrap.sh script
59
+ - PowerDNS
60
+ - GoDaddy
61
+ - Nginx
62
+ - PostgreSQL: Support Logical Replication
63
+ - Postfix
64
+ - gollum
65
+ - Linux: Users SSHKey
66
+ - PostgreSQL
67
+ - Valkey
1
68
 
2
69
  ## [0.2.0] - 2024-07-19
3
70
 
@@ -49,6 +49,7 @@ Linux:
49
49
  CPU: 2
50
50
  RAM: 4 GiB
51
51
  Storage: 30 GiB
52
+ Tmpfs: 1G
52
53
  Domain: example.org
53
54
  Hosts:
54
55
  127.0.0.1:
@@ -60,6 +61,7 @@ Linux:
60
61
  Users:
61
62
  root:
62
63
  Shell: fish
64
+ SSHKey: yes
63
65
  AuthorizedKeys:
64
66
  - ~/.ssh/id_ed25519.pub
65
67
  SSH:
@@ -68,7 +70,26 @@ Linux:
68
70
  User: root
69
71
  HostName: example.org
70
72
  Sysctl:
71
- vm.overcommit_memory: 1
73
+ vm.overcommit_memory: 1 # Need for ValKey
74
+ net.ipv4.ip_forward: 1 # Need for Wanguard
75
+ Network:
76
+ IP: 192.168.1.2/24
77
+ Gateway: 192.168.1.1
78
+ DNS: 192.168.1.1
79
+ Execute:
80
+ sh: echo Hello World from ConfigLMM > /tmp/hello
81
+
82
+ SSH:
83
+ Type: SSH
84
+ Location: ssh://example.org/
85
+ Port: 1234
86
+ Settings:
87
+ PasswordAuthentication: no
88
+
89
+ Systemd:
90
+ Type: systemd
91
+ Location: ssh://example.org/
92
+ UserCgroups: yes # Need for Podman
72
93
 
73
94
  # https://www.arubanetworks.com/
74
95
  ArubaInstant:
@@ -81,15 +102,39 @@ ArchiSteamFarm:
81
102
  Type: ArchiSteamFarm
82
103
  Domain: ASF.example.org
83
104
 
105
+ # https://goauthentik.io/
106
+ Authentik:
107
+ Type: Authentik
108
+ Location: ssh://example.org/
109
+ Domain: auth.example.org
110
+
84
111
  # https://bitmagnet.io/
85
112
  Bitmagnet:
86
113
  Type: Bitmagnet
87
114
  Domain: bitmagnet.example.org
88
115
 
116
+ # https://cassandra.apache.org/_/index.html
117
+ Cassandra:
118
+ Type: Cassandra
119
+ Location: ssh://example.org/
120
+ ClusterName: Cluster
121
+
122
+ # https://www.dovecot.org/
89
123
  Dovecot:
90
124
  Type: Dovecot
91
125
  Location: ssh://example.org/
92
126
 
127
+ # https://about.gitlab.com/
128
+ GitLab:
129
+ Type: GitLab
130
+ Location: ssh://example.org/
131
+ Domain: git.example.org
132
+ SMTP:
133
+ HostName: email.example.org
134
+ Port: 465
135
+ User: git@example.org
136
+ TLS: yes
137
+
93
138
  # https://github.com/gollum/gollum
94
139
  Gollum:
95
140
  Type: Gollum
@@ -141,18 +186,31 @@ Netdata:
141
186
  Nextcloud:
142
187
  Type: Nextcloud
143
188
  Domain: nextcloud.example.org
189
+ Database:
190
+ Type: pgsql
191
+ HostName: localhost
144
192
 
145
193
  # https://www.odoo.com/
146
194
  Odoo:
147
195
  Type: Odoo
148
196
  Domain: odoo.example.org
197
+ Database:
198
+ HostName: db.example.org
199
+
200
+ # https://peppermint.sh/
201
+ Peppermint:
202
+ Type: Peppermint
203
+ Location: ssh://example.org/
204
+ Domain: Peppermint.example.org
149
205
 
150
206
  # https://www.postfix.org/
151
207
  Postfix:
152
208
  Type: Postfix
153
209
  Location: ssh://example.org/
154
210
  AlternativePort: 2525
211
+ SMTP: unix
155
212
  ForwardAll: example.com
213
+ ForwardDovecot: yes
156
214
  Settings:
157
215
  inet_interfaces: $myhostname, localhost
158
216
 
@@ -160,6 +218,13 @@ PostgreSQL:
160
218
  Type: PostgreSQL
161
219
  Location: ssh://example.org/
162
220
  ListenAll: yes
221
+ Users:
222
+ replication:
223
+ Replication: yes
224
+ Password: ${ENV:POSTGRES_REPLICATION_PASSWORD}
225
+ Subscriptions:
226
+ db:
227
+ Connection: user=replication dbname=db password=${ENV:POSTGRES_REPLICATION_PASSWORD}
163
228
 
164
229
  # https://pterodactyl.io/
165
230
  Pterodactyl:
@@ -199,3 +264,12 @@ Valkey:
199
264
  Vaultwarden:
200
265
  Type: Vaultwarden
201
266
  Domain: vaultwarden.example.org
267
+
268
+ # https://www.wireguard.com/
269
+ WireGuard:
270
+ Type: WireGuard
271
+ Location: ssh://example.org/
272
+ Address: 172.20.0.1/20
273
+ Peers:
274
+ example:
275
+ Endpoint: example.example.org
@@ -0,0 +1,14 @@
1
+
2
+ [Unit]
3
+ Description=Authentik Proxy Outpost container
4
+ After=local-fs.target
5
+
6
+ [Container]
7
+ Image=ghcr.io/goauthentik/proxy:latest
8
+ EnvironmentFile=/var/lib/authentik/.config/containers/systemd/ProxyOutpost.env
9
+ PublishPort=127.0.0.1:19010:9000
10
+ UserNS=keep-id:uid=1000,gid=1000
11
+ AutoUpdate=registry
12
+
13
+ [Install]
14
+ WantedBy=multi-user.target default.target
@@ -0,0 +1,19 @@
1
+
2
+ [Unit]
3
+ Description=Authentik Server container
4
+ After=local-fs.target
5
+
6
+ [Container]
7
+ Image=ghcr.io/goauthentik/server:latest
8
+ Exec=server
9
+ EnvironmentFile=/var/lib/authentik/.config/containers/systemd/Authentik.env
10
+ Network=slirp4netns:allow_host_loopback=true
11
+ PublishPort=127.0.0.1:19000:9000
12
+ PublishPort=127.0.0.1:19300:9300
13
+ UserNS=keep-id:uid=1000,gid=1000
14
+ Volume=/var/lib/authentik/media:/media
15
+ Volume=/var/lib/authentik/templates:/templates
16
+ AutoUpdate=registry
17
+
18
+ [Install]
19
+ WantedBy=multi-user.target default.target
@@ -0,0 +1,18 @@
1
+
2
+ [Unit]
3
+ Description=Authentik Worker container
4
+ After=local-fs.target
5
+
6
+ [Container]
7
+ Image=ghcr.io/goauthentik/server:latest
8
+ Exec=worker
9
+ EnvironmentFile=/var/lib/authentik/.config/containers/systemd/Authentik.env
10
+ Network=slirp4netns:allow_host_loopback=true
11
+ UserNS=keep-id:uid=1000,gid=1000
12
+ Volume=/var/lib/authentik/media:/media
13
+ Volume=/var/lib/authentik/templates:/templates
14
+ Volume=/var/lib/authentik/certs:/certs
15
+ AutoUpdate=registry
16
+
17
+ [Install]
18
+ WantedBy=multi-user.target default.target
@@ -0,0 +1,42 @@
1
+
2
+ # Upstream where your authentik server is hosted.
3
+ upstream authentik {
4
+ server localhost:19000;
5
+
6
+ # Improve performance by keeping some connections alive.
7
+ keepalive 10;
8
+ }
9
+
10
+ server {
11
+ <% if config['NginxVersion'] >= 1.25 %>
12
+ listen 443 ssl;
13
+ listen [::]:443 ssl;
14
+ http2 on;
15
+ http3 on;
16
+ quic_retry on;
17
+ add_header Alt-Svc 'h3=":443"; ma=86400';
18
+ <% else %>
19
+ listen 443 ssl http2;
20
+ listen [::]:443 ssl http2;
21
+ <% end %>
22
+
23
+ include config-lmm/ssl.conf;
24
+
25
+ server_name <%= config['Domain'] %>;
26
+
27
+ access_log /var/log/nginx/authentik.access.log;
28
+ error_log /var/log/nginx/authentik.error.log;
29
+
30
+ # Proxy site
31
+ location / {
32
+ proxy_pass http://authentik;
33
+ include config-lmm/proxy.conf;
34
+ }
35
+
36
+ <% if config['Outposts'].to_a.include?('Proxy') %>
37
+ location /outpost.goauthentik.io {
38
+ proxy_pass http://localhost:19010/outpost.goauthentik.io;
39
+ include config-lmm/proxy.conf;
40
+ }
41
+ <% end %>
42
+ }
@@ -0,0 +1,95 @@
1
+
2
+ module ConfigLMM
3
+ module LMM
4
+ class Authentik < Framework::NginxApp
5
+
6
+ USER = 'authentik'
7
+ HOME_DIR = '/var/lib/authentik'
8
+ HOST_IP = '10.0.2.2'
9
+
10
+ def actionAuthentikBuild(id, target, state, context, options)
11
+ self.writeNginxConfig(__dir__, 'Authentik', id, target, state, context, options)
12
+ end
13
+
14
+ 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)
49
+ end
50
+ else
51
+ raise Framework::PluginProcessError.new("#{id}: Unknown protocol: #{uri.scheme}!")
52
+ end
53
+ else
54
+ # TODO
55
+ end
56
+ end
57
+
58
+ def deployProxyOutpost(target, ssh = nil)
59
+ return unless target['Outposts'].to_a.include?('Proxy')
60
+
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)
67
+
68
+ if ssh.nil?
69
+ self.class.exec("cp #{__dir__ + '/Authentik-ProxyOutpost.container'} #{path}/")
70
+ else
71
+ ssh.scp.upload!(__dir__ + '/Authentik-ProxyOutpost.container', path)
72
+ end
73
+
74
+ self.class.exec("systemctl --user --machine=#{USER}@ daemon-reload", ssh)
75
+ self.class.exec("systemctl --user --machine=#{USER}@ restart Authentik-ProxyOutpost", ssh)
76
+ end
77
+
78
+ def prepareConfig(target, ssh)
79
+ target['Database'] ||= {}
80
+
81
+ raise Framework::PluginProcessError.new('Domain field must be set!') unless target['Domain']
82
+
83
+ Framework::LinuxApp.ensurePackages([NGINX_PACKAGE], ssh)
84
+ self.class.prepareNginxConfig(target, ssh)
85
+ end
86
+
87
+ def configurePostgreSQL(settings, ssh)
88
+ password = SecureRandom.alphanumeric(20)
89
+ PostgreSQL.createRemoteUserAndDBOverSSH(settings, USER, password, ssh)
90
+ password
91
+ end
92
+
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,41 @@
1
+
2
+ server {
3
+
4
+ <% if !config['TLS'] %>
5
+ listen <%= config['Port'] %>;
6
+ listen [::]:<%= config['Port'] %>;
7
+ <% else %>
8
+ <% if config['NginxVersion'] >= 1.25 %>
9
+ listen <%= config['Port'] %> ssl;
10
+ listen [::]:<%= config['Port'] %> ssl;
11
+ http2 on;
12
+ http3 on;
13
+ quic_retry on;
14
+ add_header Alt-Svc 'h3=":<%= config['Port'] %>"; ma=86400';
15
+ <% else %>
16
+ listen <%= config['Port'] %> ssl http2;
17
+ listen [::]:<%= config['Port'] %> ssl http2;
18
+ <% end %>
19
+
20
+ include config-lmm/ssl.conf;
21
+ <% end %>
22
+
23
+ server_name <%= config['Domain'] %>;
24
+
25
+ access_log /var/log/nginx/bookstack.access.log;
26
+ error_log /var/log/nginx/bookstack.error.log;
27
+
28
+ include config-lmm/errors.conf;
29
+ include config-lmm/security.conf;
30
+
31
+ location / {
32
+ <% if config['Server'] %>
33
+ proxy_pass <%= config['Server'] %>;
34
+ <% else %>
35
+ proxy_pass http://127.0.0.1:18200;
36
+ <% end %>
37
+
38
+ include config-lmm/proxy.conf;
39
+ }
40
+
41
+ }
@@ -0,0 +1,15 @@
1
+
2
+ [Unit]
3
+ Description=BookStack container
4
+ After=local-fs.target
5
+
6
+ [Container]
7
+ Image=ghcr.io/linuxserver/bookstack:latest
8
+ EnvironmentFile=/var/lib/bookstack/.config/containers/systemd/BookStack.env
9
+ Network=slirp4netns:allow_host_loopback=true
10
+ PublishPort=127.0.0.1:18200:80
11
+ Volume=/var/lib/bookstack/config:/config
12
+ AutoUpdate=registry
13
+
14
+ [Install]
15
+ WantedBy=multi-user.target default.target
@@ -0,0 +1,80 @@
1
+
2
+ module ConfigLMM
3
+ module LMM
4
+ class BookStack < Framework::NginxApp
5
+
6
+ USER = 'bookstack'
7
+ HOME_DIR = '/var/lib/bookstack'
8
+ HOST_IP = '10.0.2.2'
9
+
10
+ def actionBookStackDeploy(id, target, activeState, context, options)
11
+ raise Framework::PluginProcessError.new('Domain field must be set!') unless target['Domain']
12
+
13
+ target['Database'] ||= {}
14
+ if target['Location'] && target['Location'] != '@me'
15
+ uri = Addressable::URI.parse(target['Location'])
16
+ raise Framework::PluginProcessError.new("#{id}: Unknown Protocol: #{uri.scheme}!") if uri.scheme != 'ssh'
17
+
18
+ self.class.sshStart(uri) do |ssh|
19
+
20
+ dbPassword = self.configureMariaDB(target['Database'], activeState, ssh)
21
+ distroInfo = Framework::LinuxApp.currentDistroInfo(ssh)
22
+ Framework::LinuxApp.configurePodmanServiceOverSSH(USER, HOME_DIR, 'BookStack', distroInfo, ssh)
23
+ self.class.sshExec!(ssh, "su --login #{USER} --shell /bin/sh --command 'mkdir -p ~/config'")
24
+
25
+ path = Framework::LinuxApp::SYSTEMD_CONTAINERS_PATH.gsub('~', HOME_DIR)
26
+ self.class.exec(" echo 'DB_HOST=#{HOST_IP}' > #{path}/BookStack.env", ssh)
27
+ self.class.exec(" echo 'DB_DATABASE=#{USER}' >> #{path}/BookStack.env", ssh)
28
+ self.class.exec(" echo 'DB_USERNAME=#{USER}' >> #{path}/BookStack.env", ssh)
29
+ self.class.exec(" echo 'DB_PASSWORD=#{dbPassword}' >> #{path}/BookStack.env", ssh)
30
+ self.class.exec(" echo 'APP_URL=https://#{target['Domain']}' >> #{path}/BookStack.env", ssh)
31
+
32
+ if target['OIDC'] && target['OIDC']['Issuer']
33
+ self.class.exec(" echo 'AUTH_METHOD=oidc' >> #{path}/BookStack.env", ssh)
34
+ 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)
37
+ self.class.exec(" echo 'OIDC_ISSUER=#{target['OIDC']['Issuer']}' >> #{path}/BookStack.env", ssh)
38
+ self.class.exec(" echo 'OIDC_ISSUER_DISCOVER=true' >> #{path}/BookStack.env", ssh)
39
+ self.class.exec(" echo 'OIDC_USER_TO_GROUPS=true' >> #{path}/BookStack.env", ssh)
40
+ end
41
+
42
+ if target['SMTP']
43
+ host = target['SMTP']['Host']
44
+ host = HOST_IP if ['localhost', '127.0.0.1'].include?(host)
45
+ self.class.exec(" echo 'MAIL_HOST=#{host}' >> #{path}/BookStack.env", ssh)
46
+ self.class.exec(" echo 'MAIL_PORT=#{target['SMTP']['Port']}' >> #{path}/BookStack.env", ssh)
47
+ 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)
49
+ self.class.exec(" echo 'MAIL_FROM=#{target['SMTP']['From']}' >> #{path}/BookStack.env", ssh)
50
+ end
51
+
52
+ self.class.exec("chown #{USER}:#{USER} #{path}/BookStack.env", ssh)
53
+ self.class.exec("chmod 600 #{path}/BookStack.env", ssh)
54
+
55
+ ssh.scp.upload!(__dir__ + '/BookStack.container', path)
56
+ self.class.exec("systemctl --user --machine=#{USER}@ daemon-reload", ssh)
57
+ self.class.exec("systemctl --user --machine=#{USER}@ restart BookStack", ssh)
58
+
59
+ Framework::LinuxApp.ensurePackages([NGINX_PACKAGE], ssh)
60
+ Framework::LinuxApp.ensureServiceAutoStartOverSSH(NGINX_PACKAGE, ssh)
61
+ self.class.prepareNginxConfig(target, ssh)
62
+ self.writeNginxConfig(__dir__, 'BookStack', id, target, state, context, options)
63
+ self.deployNginxConfig(id, target, activeState, context, options)
64
+ Framework::LinuxApp.startServiceOverSSH(NGINX_PACKAGE, ssh)
65
+ end
66
+ else
67
+ # TODO
68
+ end
69
+ end
70
+
71
+ def configureMariaDB(settings, activeState, ssh)
72
+ password = SecureRandom.alphanumeric(20)
73
+ MariaDB.createRemoteUserAndDB(settings, USER, password, ssh)
74
+ password
75
+ end
76
+
77
+ end
78
+ end
79
+ end
80
+
@@ -0,0 +1,41 @@
1
+
2
+ module ConfigLMM
3
+ module LMM
4
+ class Cassandra < Framework::Plugin
5
+ PACKAGE_NAME = 'Cassandra'
6
+ SERVICE_NAME = 'cassandra'
7
+
8
+ def actionCassandraDeploy(id, target, activeState, context, options)
9
+ plugins[:Linux].ensurePackage(PACKAGE_NAME, target['Location'])
10
+ plugins[:Linux].ensureServiceAutoStart(SERVICE_NAME, target['Location'])
11
+
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'
20
+ configFile = '/etc/cassandra/conf/cassandra.yaml'
21
+ end
22
+
23
+ cmd = "sed -i 's|^uuid_sstable_identifiers_enabled:.*|uuid_sstable_identifiers_enabled: true|' #{configFile}"
24
+ self.class.sshExec!(ssh, cmd)
25
+ if target['ClusterName']
26
+ cmd = "sed -i 's|^cluster_name:.*|cluster_name: #{target['ClusterName']}|' #{configFile}"
27
+ self.class.sshExec!(ssh, cmd)
28
+ end
29
+ end
30
+ else
31
+ # TODO
32
+ end
33
+
34
+ plugins[:Linux].startService(SERVICE_NAME, target['Location'])
35
+ end
36
+
37
+ end
38
+
39
+ end
40
+ end
41
+
@@ -0,0 +1,17 @@
1
+
2
+
3
+ [Unit]
4
+ Description=Discourse Sidekiq container
5
+ After=local-fs.target
6
+
7
+ [Container]
8
+ Image=docker.io/bitnami/discourse:latest
9
+ Exec=/opt/bitnami/scripts/discourse-sidekiq/run.sh
10
+ EnvironmentFile=/var/lib/discourse/.config/containers/systemd/Discourse.env
11
+ Network=slirp4netns:allow_host_loopback=true
12
+ UserNS=keep-id:uid=999,gid=999
13
+ Volume=/var/lib/discourse/sidekiq:/bitnami/discourse
14
+ AutoUpdate=registry
15
+
16
+ [Install]
17
+ WantedBy=multi-user.target default.target
@@ -0,0 +1,41 @@
1
+
2
+ server {
3
+
4
+ <% if !config['TLS'] %>
5
+ listen <%= config['Port'] %>;
6
+ listen [::]:<%= config['Port'] %>;
7
+ <% else %>
8
+ <% if config['NginxVersion'] >= 1.25 %>
9
+ listen <%= config['Port'] %> ssl;
10
+ listen [::]:<%= config['Port'] %> ssl;
11
+ http2 on;
12
+ http3 on;
13
+ quic_retry on;
14
+ add_header Alt-Svc 'h3=":<%= config['Port'] %>"; ma=86400';
15
+ <% else %>
16
+ listen <%= config['Port'] %> ssl http2;
17
+ listen [::]:<%= config['Port'] %> ssl http2;
18
+ <% end %>
19
+
20
+ include config-lmm/ssl.conf;
21
+ <% end %>
22
+
23
+ server_name <%= config['Domain'] %>;
24
+
25
+ access_log /var/log/nginx/discourse.access.log;
26
+ error_log /var/log/nginx/discourse.error.log;
27
+
28
+ include config-lmm/errors.conf;
29
+ include config-lmm/security.conf;
30
+
31
+ location / {
32
+ <% if config['Server'] %>
33
+ proxy_pass <%= config['Server'] %>;
34
+ <% else %>
35
+ proxy_pass http://127.0.0.1:13100;
36
+ <% end %>
37
+
38
+ include config-lmm/proxy.conf;
39
+ }
40
+
41
+ }
@@ -0,0 +1,17 @@
1
+
2
+ [Unit]
3
+ Description=Discourse container
4
+ After=local-fs.target
5
+
6
+ [Container]
7
+ ContainerName=Discourse
8
+ Image=docker.io/bitnami/discourse:latest
9
+ EnvironmentFile=/var/lib/discourse/.config/containers/systemd/Discourse.env
10
+ Network=slirp4netns:allow_host_loopback=true
11
+ PublishPort=127.0.0.1:13100:3000
12
+ UserNS=keep-id:uid=999,gid=999
13
+ Volume=/var/lib/discourse/data:/bitnami/discourse
14
+ AutoUpdate=registry
15
+
16
+ [Install]
17
+ WantedBy=multi-user.target default.target