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
@@ -0,0 +1,16 @@
1
+ [Unit]
2
+ Description=vaultwarden container
3
+ After=local-fs.target
4
+
5
+ [Container]
6
+ AutoUpdate=registry
7
+ Image=ghcr.io/dani-garcia/vaultwarden:latest
8
+ Exec=/start.sh
9
+ EnvironmentFile=/var/lib/vaultwarden/.config/containers/systemd/Vaultwarden.env
10
+ Network=slirp4netns:allow_host_loopback=true
11
+ PublishPort=0.0.0.0:18000:8000
12
+ UserNS=keep-id:uid=1000,gid=1000
13
+ Volume=/var/lib/vaultwarden/data/:/data/
14
+
15
+ [Install]
16
+ WantedBy=multi-user.target default.target
@@ -5,8 +5,13 @@ module ConfigLMM
5
5
  module LMM
6
6
  class Vaultwarden < Framework::NginxApp
7
7
 
8
+ NAME = 'Vaultwarden'
9
+ USER = 'vaultwarden'
10
+ HOME_DIR = '/var/lib/vaultwarden'
11
+ SERVICE_PORT = '18000'
12
+
8
13
  def actionVaultwardenBuild(id, target, state, context, options)
9
- writeNginxConfig(__dir__, 'Vaultwarden', id, target, state, context, options)
14
+ writeNginxConfig(__dir__, NAME, id, target, state, context, options)
10
15
  end
11
16
 
12
17
  def actionVaultwardenDiff(id, target, activeState, context, options)
@@ -14,8 +19,46 @@ module ConfigLMM
14
19
  end
15
20
 
16
21
  def actionVaultwardenDeploy(id, target, activeState, context, options)
17
- if !target['Location'] || target['Location'] == '@me'
18
- deployNginxConfig(id, target, activeState, context, options)
22
+ if target['Location'] && target['Location'] != '@me'
23
+ uri = Addressable::URI.parse(target['Location'])
24
+ self.class.sshStart(uri) do |ssh|
25
+ if !target.key?('Proxy') || target['Proxy'] != 'only'
26
+ distroInfo = Framework::LinuxApp.currentDistroInfo(ssh)
27
+ Framework::LinuxApp.configurePodmanServiceOverSSH(USER, HOME_DIR, 'Vaultwarden', distroInfo, ssh)
28
+ self.class.sshExec!(ssh, "su --login #{USER} --shell /bin/sh --command 'mkdir -p ~/data'")
29
+ path = Framework::LinuxApp::SYSTEMD_CONTAINERS_PATH.gsub('~', HOME_DIR)
30
+ self.class.sshExec!(ssh, "echo 'ROCKET_PORT=8000' > #{path}/Vaultwarden.env")
31
+ if target['Domain']
32
+ self.class.sshExec!(ssh, "echo 'DOMAIN=https://#{target['Domain']}' >> #{path}/Vaultwarden.env")
33
+ end
34
+ target['Signups'] = false unless target['Signups']
35
+ self.class.sshExec!(ssh, "echo 'SIGNUPS_ALLOWED=#{target['Signups'].to_s}' >> #{path}/Vaultwarden.env")
36
+ if target.key?('Invitations')
37
+ self.class.sshExec!(ssh, "echo 'INVITATIONS_ALLOWED=#{target['Invitations'].to_s}' >> #{path}/Vaultwarden.env")
38
+ end
39
+ if ENV.key?('VAULTWARDEN_ADMIN_TOKEN')
40
+ token = ENV['VAULTWARDEN_ADMIN_TOKEN']
41
+ token = SecureRandom.alphanumeric(40) if token.empty?
42
+ self.class.sshExec!(ssh, "echo 'ADMIN_TOKEN=#{token}' >> #{path}/Vaultwarden.env")
43
+ end
44
+ self.class.sshExec!(ssh, "chown #{USER}:#{USER} #{path}/Vaultwarden.env")
45
+ self.class.sshExec!(ssh, "chmod 600 #{path}/Vaultwarden.env")
46
+
47
+ ssh.scp.upload!(__dir__ + '/Vaultwarden.container', path)
48
+ self.class.sshExec!(ssh, "systemctl --user --machine=#{USER}@ daemon-reload")
49
+ self.class.sshExec!(ssh, "systemctl --user --machine=#{USER}@ start Vaultwarden")
50
+ if target['Proxy'] != 'only'
51
+ Framework::LinuxApp.firewallAddPortOverSSH(SERVICE_PORT + '/tcp', ssh)
52
+ end
53
+ end
54
+ if !target.key?('Proxy') || !!target['Proxy']
55
+ self.class.prepareNginxConfig(target, ssh)
56
+ writeNginxConfig(__dir__, NAME, id, target, state, context, options)
57
+ deployNginxConfig(id, target, activeState, context, options)
58
+ end
59
+ end
60
+ else
61
+ # TODO
19
62
  activeState['Location'] = '@me'
20
63
  end
21
64
  end
@@ -0,0 +1,42 @@
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/wikijs.access.log;
26
+ error_log /var/log/nginx/wikijs.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:13200;
36
+ <% end %>
37
+
38
+ include config-lmm/proxy.conf;
39
+ }
40
+
41
+ }
42
+
@@ -0,0 +1,15 @@
1
+
2
+ [Unit]
3
+ Description=Wiki.js container
4
+ After=local-fs.target
5
+
6
+ [Container]
7
+ Image=docker.io/requarks/wiki:latest
8
+ EnvironmentFile=/var/lib/wikijs/.config/containers/systemd/Wiki.js.env
9
+ Network=slirp4netns:allow_host_loopback=true
10
+ PublishPort=127.0.0.1:13200:3000
11
+ UserNS=keep-id:uid=1000,gid=1000
12
+ AutoUpdate=registry
13
+
14
+ [Install]
15
+ WantedBy=multi-user.target default.target
@@ -0,0 +1,61 @@
1
+
2
+ module ConfigLMM
3
+ module LMM
4
+ class WikiJS < Framework::NginxApp
5
+
6
+ USER = 'wikijs'
7
+ HOME_DIR = '/var/lib/wikijs'
8
+ HOST_IP = '10.0.2.2'
9
+
10
+ def actionWikiJSDeploy(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.configurePostgreSQL(target['Database'], ssh)
21
+ distroInfo = Framework::LinuxApp.currentDistroInfo(ssh)
22
+ Framework::LinuxApp.configurePodmanServiceOverSSH(USER, HOME_DIR, 'Wiki.js', distroInfo, ssh)
23
+
24
+ path = Framework::LinuxApp::SYSTEMD_CONTAINERS_PATH.gsub('~', HOME_DIR)
25
+ self.class.exec("echo 'DB_TYPE=postgres' > #{path}/Wiki.js.env", ssh)
26
+ self.class.exec("echo 'DB_HOST=#{HOST_IP}' >> #{path}/Wiki.js.env", ssh)
27
+ self.class.exec("echo 'DB_PORT=5432' >> #{path}/Wiki.js.env", ssh)
28
+ self.class.exec("echo 'DB_USER=#{USER}' >> #{path}/Wiki.js.env", ssh)
29
+ self.class.exec("echo 'DB_NAME=#{USER}' >> #{path}/Wiki.js.env", ssh)
30
+ self.class.exec(" echo 'DB_PASS=#{dbPassword}' >> #{path}/Wiki.js.env", ssh)
31
+
32
+ self.class.exec("chown #{USER}:#{USER} #{path}/Wiki.js.env", ssh)
33
+ self.class.exec("chmod 600 #{path}/Wiki.js.env", ssh)
34
+
35
+ ssh.scp.upload!(__dir__ + '/Wiki.js.container', path)
36
+ self.class.exec("systemctl --user --machine=#{USER}@ daemon-reload", ssh)
37
+ self.class.exec("systemctl --user --machine=#{USER}@ restart Wiki.js", ssh)
38
+
39
+ Framework::LinuxApp.ensurePackages([NGINX_PACKAGE], ssh)
40
+ Framework::LinuxApp.ensureServiceAutoStartOverSSH(NGINX_PACKAGE, ssh)
41
+ self.class.prepareNginxConfig(target, ssh)
42
+ self.writeNginxConfig(__dir__, 'Wiki.js', id, target, state, context, options)
43
+ self.deployNginxConfig(id, target, activeState, context, options)
44
+ Framework::LinuxApp.startServiceOverSSH(NGINX_PACKAGE, ssh)
45
+
46
+ end
47
+ else
48
+ # TODO
49
+ end
50
+ end
51
+
52
+ def configurePostgreSQL(settings, ssh)
53
+ password = SecureRandom.alphanumeric(20)
54
+ PostgreSQL.createRemoteUserAndDBOverSSH(settings, USER, password, ssh)
55
+ password
56
+ end
57
+
58
+ end
59
+ end
60
+ end
61
+
@@ -1,27 +1,45 @@
1
1
 
2
2
  server {
3
3
 
4
- <% if !config['TLS'] %>
5
- listen <%= config['Port'] %>;
6
- listen [::]:<%= config['Port'] %>;
7
- <% else %>
8
- listen <%= config['Port'] %> ssl;
9
- listen [::]:<%= config['Port'] %> ssl;
4
+ <% if config['NginxVersion'] >= 1.25 %>
5
+ <% if !config['TLS'] %>
6
+ listen <%= config['Port'] %>;
7
+ listen [::]:<%= config['Port'] %>;
8
+ <% else %>
9
+ listen <%= config['Port'] %> ssl;
10
+ listen [::]:<%= config['Port'] %> ssl;
11
+
12
+ include config-lmm/ssl.conf;
13
+ <% end %>
10
14
  http2 on;
11
- include config-lmm/ssl.conf;
15
+ http3 on;
16
+ quic_retry on;
17
+ add_header Alt-Svc 'h3=":443"; ma=86400';
18
+ <% else %>
19
+ <% if !config['TLS'] %>
20
+ listen <%= config['Port'] %>;
21
+ listen [::]:<%= config['Port'] %>;
22
+ <% else %>
23
+ listen <%= config['Port'] %> ssl http2;
24
+ listen [::]:<%= config['Port'] %> ssl http2;
25
+
26
+ include config-lmm/ssl.conf;
27
+ <% end %>
12
28
  <% end %>
13
29
 
14
30
  server_name <%= config['Domain'] %>;
15
31
 
16
- root <%= config['Root'] %>;
17
- passenger_app_root /srv/gollum;
18
-
19
- try_files $uri @Passenger;
32
+ <% if config['Root'] %>
33
+ root <%= config['Root'] %>;
34
+ <% end %>
20
35
 
21
36
  access_log /var/log/nginx/gollum.access.log;
22
37
  error_log /var/log/nginx/gollum.error.log;
23
38
 
24
- include config-lmm/private.conf;
39
+ <% if config['AuthentikDomain'].nil? %>
40
+ include config-lmm/private.conf;
41
+ <% end %>
42
+
25
43
  include config-lmm/errors.conf;
26
44
 
27
45
  <% if config['CertName'] %>
@@ -30,12 +48,59 @@ server {
30
48
  ssl_trusted_certificate "/etc/letsencrypt/live/<%= config['CertName'] %>/chain.pem";
31
49
  <% end %>
32
50
 
33
- location @Passenger {
34
- passenger_enabled on;
35
- passenger_min_instances 1;
36
- rails_env production;
51
+ <% if config['Passenger'] %>
52
+ passenger_app_root /srv/gollum;
53
+
54
+ try_files $uri @Passenger;
55
+
56
+ location @Passenger {
57
+ passenger_enabled on;
58
+ passenger_min_instances 1;
59
+ rails_env production;
60
+
61
+ #passenger_set_cgi_param HTTP_X_FORWARDED_PROTO https;
62
+ #limit_req zone=one burst=5;
63
+ }
64
+ <% else %>
65
+ location / {
66
+ proxy_pass <%= config['Server'] %>;
67
+
68
+ <% if config['AuthentikDomain'] %>
69
+ error_page 401 = @authenticate;
70
+ include config-lmm/errors.conf;
71
+
72
+ auth_request /outpost.goauthentik.io/auth/nginx;
73
+
74
+ # translate headers from the outposts back to the actual upstream
75
+ auth_request_set $authentik_username $upstream_http_x_authentik_username;
76
+ auth_request_set $authentik_groups $upstream_http_x_authentik_groups;
77
+ auth_request_set $authentik_email $upstream_http_x_authentik_email;
78
+ auth_request_set $authentik_name $upstream_http_x_authentik_name;
79
+ auth_request_set $authentik_uid $upstream_http_x_authentik_uid;
80
+
81
+ proxy_set_header REMOTE_USER $authentik_username;
82
+ proxy_set_header REMOTE_GROUPS $authentik_groups;
83
+ proxy_set_header REMOTE_EMAIL $authentik_email;
84
+ proxy_set_header REMOTE_NAME $authentik_name;
85
+ proxy_set_header REMOTE_UID $authentik_uid;
86
+ <% end %>
87
+
88
+ include config-lmm/proxy.conf;
89
+ }
90
+ <% end %>
91
+
92
+ <% if config['AuthentikDomain'] %>
93
+ location /outpost.goauthentik.io {
94
+ proxy_pass https://<%= config['AuthentikDomain'] %>/outpost.goauthentik.io;
95
+ proxy_ssl_protocols TLSv1.2 TLSv1.3;
96
+ proxy_set_header X-Original-URL $scheme://$http_host$request_uri;
97
+ proxy_pass_request_body off;
98
+ proxy_set_header Content-Length "";
99
+ }
37
100
 
38
- #passenger_set_cgi_param HTTP_X_FORWARDED_PROTO https;
39
- #limit_req zone=one burst=5;
40
- }
101
+ location @authenticate {
102
+ internal;
103
+ return 302 /outpost.goauthentik.io/start?rd=$request_uri;
104
+ }
105
+ <% end %>
41
106
  }
@@ -0,0 +1,15 @@
1
+ [Unit]
2
+ Description=gollum container
3
+ After=local-fs.target
4
+
5
+ [Container]
6
+ Image=docker.io/gollumwiki/gollum:master
7
+ Exec=--config=/config/config.rb
8
+ PublishPort=0.0.0.0:14567:4567
9
+ UserNS=keep-id:uid=1000,gid=1000
10
+ Volume=/srv/gollum/repo:/wiki
11
+ Volume=/srv/gollum/config:/config
12
+ AutoUpdate=registry
13
+
14
+ [Install]
15
+ WantedBy=multi-user.target default.target
@@ -4,15 +4,14 @@ module ConfigLMM
4
4
  class Gollum < Framework::NginxApp
5
5
 
6
6
  NAME = 'gollum'
7
+ USER = 'gollum'
7
8
  GOLLUM_PATH = '/srv/gollum'
9
+ GOLLUM_PORT = '14567'
8
10
 
9
11
  def actionGollumBuild(id, target, activeState, context, options)
10
- if !target['Root'] && (!target['Location'] || target['Location'] == '@me')
11
- target['Root'] = File.dirname(`gem which gollum`.strip) + '/gollum/public'
12
- end
13
12
  writeNginxConfig(__dir__, NAME, id, target, activeState, context, options)
14
13
  targetDir = options['output'] + GOLLUM_PATH
15
- mkdir(targetDir, options['dry'])
14
+ mkdir(targetDir + '/config', options['dry'])
16
15
  copy(__dir__ + '/config.ru', targetDir, options['dry'])
17
16
  `git init #{targetDir}/repo`
18
17
  end
@@ -22,16 +21,54 @@ module ConfigLMM
22
21
  end
23
22
 
24
23
  def actionGollumDeploy(id, target, activeState, context, options)
25
- if !target['Location'] || target['Location'] == '@me'
24
+ if target['Location'] && target['Location'] != '@me'
25
+ uri = Addressable::URI.parse(target['Location'])
26
+ self.class.sshStart(uri) do |ssh|
27
+ if !target.key?('Proxy') || !!target['Proxy']
28
+ self.class.prepareNginxConfig(target, ssh)
29
+ if !target['Root']
30
+ gollumPath = ssh.exec!('gem which gollum').strip
31
+ target['Root'] = File.dirname(gollumPath) + '/gollum/public'
32
+ end
33
+ writeNginxConfig(__dir__, NAME, id, target, state, context, options)
34
+ deployNginxConfig(id, target, activeState, context, options)
35
+ end
36
+ if !target.key?('Proxy') || target['Proxy'] != 'only'
37
+ distroInfo = Framework::LinuxApp.currentDistroInfo(ssh)
38
+ Framework::LinuxApp.configurePodmanServiceOverSSH(USER, GOLLUM_PATH, 'gollum', distroInfo, ssh)
39
+ if target['Config']
40
+ `cp #{target['Config']} #{options['output'] + GOLLUM_PATH}/config/config.rb`
41
+ else
42
+ `touch #{options['output'] + GOLLUM_PATH}/config/config.rb`
43
+ end
44
+ self.class.uploadFolder(options['output'] + GOLLUM_PATH, '/srv', ssh)
45
+ path = Framework::LinuxApp::SYSTEMD_CONTAINERS_PATH.gsub('~', GOLLUM_PATH)
46
+ ssh.scp.upload!(__dir__ + '/gollum.container', path)
47
+ self.class.sshExec!(ssh, "chown -R #{USER}:#{USER} #{GOLLUM_PATH}")
48
+ self.class.sshExec!(ssh, "systemctl --user --machine=#{USER}@ daemon-reload")
49
+ self.class.sshExec!(ssh, "systemctl --user --machine=#{USER}@ restart gollum")
50
+ if target['Proxy'] != 'only'
51
+ Framework::LinuxApp.firewallAddPortOverSSH(GOLLUM_PORT + '/tcp', ssh)
52
+ end
53
+ end
54
+ end
55
+ else
26
56
  targetDir = GOLLUM_PATH
27
57
  mkdir(targetDir, options['dry'])
28
- deployNginxConfig(id, target, activeState, context, options)
29
- copy(options['output'] + GOLLUM_PATH + '/config.ru', GOLLUM_PATH, options['dry'])
30
- copyNotPresent(options['output'] + GOLLUM_PATH + '/repo', GOLLUM_PATH, options['dry'])
31
- chown('http', 'http', GOLLUM_PATH, options['dry'])
58
+ if !target.key?('Proxy') || !!target['Proxy']
59
+ self.class.prepareNginxConfig(target)
60
+ if !target['Root']
61
+ target['Root'] = File.dirname(`gem which gollum`.strip) + '/gollum/public'
62
+ end
63
+ writeNginxConfig(__dir__, NAME, id, target, state, context, options)
64
+ deployNginxConfig(id, target, activeState, context, options)
65
+ end
66
+ if !target.key?('Proxy') || target['Proxy'] != 'only'
67
+ copy(options['output'] + GOLLUM_PATH + '/config.ru', GOLLUM_PATH, options['dry'])
68
+ copyNotPresent(options['output'] + GOLLUM_PATH + '/repo', GOLLUM_PATH, options['dry'])
69
+ chown('http', 'http', GOLLUM_PATH, options['dry'])
70
+ end
32
71
  activeState['Location'] = '@me'
33
- else
34
- # TODO
35
72
  end
36
73
  end
37
74
 
@@ -0,0 +1,62 @@
1
+ #_preseed_V1
2
+
3
+ d-i debian-installer/locale string en_US
4
+ d-i keyboard-configuration/xkb-keymap select us
5
+
6
+ <% if config['Network'].is_a?(Hash) %>
7
+ d-i netcfg/disable_autoconfig boolean true
8
+ d-i netcfg/dhcp_failed note
9
+ d-i netcfg/dhcp_options select Configure network manually
10
+
11
+ d-i netcfg/get_ipaddress string <%= config['Network']['IP'].split('/').first %>
12
+ d-i netcfg/get_netmask string <%= [((1 << 32) - 1) << (32 - config['Network']['IP'].split('/').last.to_i)].pack('N').bytes.join('.') %>
13
+ d-i netcfg/get_gateway string <%= config['Network']['Gateway'] %>
14
+ d-i netcfg/get_nameservers string <%= config['Network']['DNS'] %>
15
+ d-i netcfg/confirm_static boolean true
16
+ <% end %>
17
+
18
+ d-i netcfg/get_hostname string <%= Addressable::IDNA.to_ascii(config['Domain']) %>
19
+
20
+ d-i passwd/make-user boolean false
21
+
22
+ <% if config['Users'].to_h['root'].to_h['PasswordHash'] %>
23
+ d-i passwd/root-password-crypted password <%= config['Users']['root']['PasswordHash'] %>
24
+ <% elsif config['Users'].to_h['root'].to_h['Password'] %>
25
+ d-i passwd/root-password password <%= config['Users']['root']['Password'] %>
26
+ <% end %>
27
+
28
+ d-i time/zone string UTC
29
+
30
+ d-i partman-auto/method string regular
31
+ d-i partman-auto/choose_recipe select atomic
32
+ d-i partman/choose_partition select finish
33
+ d-i partman/confirm_nooverwrite boolean true
34
+
35
+ d-i base-installer/install-recommends boolean false
36
+ d-i apt-setup/cdrom/set-first boolean false
37
+ d-i apt-setup/non-free-firmware boolean true
38
+ d-i apt-setup/non-free boolean true
39
+ d-i apt-setup/contrib boolean true
40
+ d-i apt-setup/use_mirror boolean true
41
+ d-i mirror/country string US
42
+ d-i mirror/http/mirror select deb.debian.org
43
+ d-i mirror/http/proxy string
44
+
45
+ d-i pkgsel/run_tasksel boolean false
46
+
47
+ <% if !config['Apps'].to_a.empty? %>
48
+ d-i pkgsel/include string <%= config['Apps'].map(&:downcase).join(' ') %>
49
+ <% end %>
50
+
51
+ d-i pkgsel/upgrade select full-upgrade
52
+
53
+ popularity-contest popularity-contest/participate boolean false
54
+
55
+ d-i grub-installer/only_debian boolean true
56
+ d-i grub-installer/bootdev string default
57
+
58
+ d-i finish-install/reboot_in_progress note
59
+
60
+ <% if !config['Users'].to_h['root'].to_h['AuthorizedKeys'].empty? %>
61
+ d-i preseed/late_command string in-target sh -c "echo '<%= config['Users']['root']['AuthorizedKeys'].first %>' > /root/.ssh/authorized_keys"
62
+ <% end %>
@@ -2,5 +2,47 @@
2
2
  opensuse-leap:
3
3
  Name: openSUSE Leap
4
4
  InstallPackage: zypper install --no-confirm
5
+ RemovePackage: zypper remove --no-confirm
5
6
  AutoStartService: systemctl enable
6
7
  StartService: systemctl start
8
+ RestartService: systemctl restart
9
+ ReloadService: systemctl reload
10
+ StopService: systemctl stop
11
+ DisableService: systemctl disable
12
+ ReloadServiceManager: systemctl daemon-reload
13
+ CreateServiceUser: useradd --system --shell /usr/sbin/nologin --user-group
14
+ ModifyUser: usermod
15
+ DeleteUser: userdel --remove --force
16
+ DeleteGroup: groupdel
17
+
18
+ arch:
19
+ Name: Arch Linux
20
+ InstallPackage: pacman -S --noconfirm --needed
21
+ RemovePackage: pacman --remove --noconfirm
22
+ AutoStartService: systemctl enable
23
+ StartService: systemctl start
24
+ RestartService: systemctl restart
25
+ ReloadService: systemctl reload
26
+ StopService: systemctl stop
27
+ DisableService: systemctl disable
28
+ ReloadServiceManager: systemctl daemon-reload
29
+ CreateServiceUser: useradd --system --shell /usr/sbin/nologin --user-group
30
+ ModifyUser: usermod
31
+ DeleteUser: userdel --remove --force
32
+ DeleteGroup: groupdel
33
+
34
+ debian:
35
+ Name: Debian
36
+ InstallPackage: DEBIAN_FRONTEND=noninteractive apt-get install --assume-yes
37
+ RemovePackage: apt-get remove --assume-yes
38
+ AutoStartService: systemctl enable
39
+ StartService: systemctl start
40
+ RestartService: systemctl restart
41
+ ReloadService: systemctl reload
42
+ StopService: systemctl stop
43
+ DisableService: systemctl disable
44
+ ReloadServiceManager: systemctl daemon-reload
45
+ CreateServiceUser: useradd --system --shell /usr/sbin/nologin --user-group
46
+ ModifyUser: usermod
47
+ DeleteUser: userdel --remove --force
48
+ DeleteGroup: groupdel
@@ -0,0 +1,11 @@
1
+ openSUSE Leap:
2
+ ISO: https://download.opensuse.org/distribution/leap/15.6/iso/openSUSE-Leap-15.6-NET-x86_64-Media.iso
3
+
4
+ Arch Linux:
5
+ ISO: https://mirror.rackspace.com/archlinux/iso/2024.10.01/archlinux-x86_64.iso
6
+
7
+ Debian:
8
+ ISO: https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-12.7.0-amd64-netinst.iso
9
+
10
+ Proxmox VE:
11
+ ISO: https://enterprise.proxmox.com/iso/proxmox-ve_8.2-2.iso