19015: installer fix: work around a Passenger issue with the detection of RVM
[arvados.git] / tools / salt-install / config_examples / multi_host / aws / pillars / nginx_passenger.sls
index a2df3ff0965bc506d8ce215bcf0f809bd1008b8d..2b6b96c3a47cf84f764c9648ece1a5c80621df62 100644 (file)
@@ -3,12 +3,40 @@
 #
 # SPDX-License-Identifier: AGPL-3.0
 
+{%- set passenger_pkg = 'nginx-mod-http-passenger'
+                          if grains.osfinger in ('CentOS Linux-7') else
+                        'libnginx-mod-http-passenger' %}
+{%- set passenger_mod = '/usr/lib64/nginx/modules/ngx_http_passenger_module.so'
+                          if grains.osfinger in ('CentOS Linux-7',) else
+                        '/usr/lib/nginx/modules/ngx_http_passenger_module.so' %}
+{%- set passenger_ruby = '/usr/local/rvm/rubies/ruby-2.7.2/bin/ruby'
+                           if grains.osfinger in ('CentOS Linux-7', 'Ubuntu-18.04', 'Debian-10') else
+                         '/usr/bin/ruby' %}
+
 ### NGINX
 nginx:
-  install_from_phusionpassenger: true
+  __NGINX_INSTALL_SOURCE__: true
   lookup:
-    passenger_package: libnginx-mod-http-passenger
-    passenger_config_file: /etc/nginx/conf.d/mod-http-passenger.conf
+    passenger_package: {{ passenger_pkg }}
+  ### PASSENGER
+  passenger:
+    passenger_ruby: {{ passenger_ruby }}
+
+  ### SERVER
+  server:
+    config:
+      # Needed for RVM, harmless otherwise. Cf. https://dev.arvados.org/issues/19015
+      env: GEM_HOME
+      # As we now differentiate where passenger is required or not, we need to
+      # load this module conditionally, so we add this conditional just to use
+      # the same pillar file
+      {% if "install_from_phusionpassenger" == "__NGINX_INSTALL_SOURCE__" %}
+      # This is required to get the passenger module loaded
+      # In Debian it can be done with this
+      # include: 'modules-enabled/*.conf'
+      load_module: {{ passenger_mod }}
+      {% endif %}
+      worker_processes: 4
 
   ### SNIPPETS
   snippets:
@@ -39,12 +67,6 @@ nginx:
       # replace with the IP address of your resolver
       # - resolver: 127.0.0.1
 
-  ### SERVER
-  server:
-    config:
-      include: 'modules-enabled/*.conf'
-      worker_processes: 4
-
   ### SITES
   servers:
     managed: