Merge branch '19015-rvm-gemset-passenger-fix'
authorWard Vandewege <ward@curii.com>
Fri, 6 May 2022 12:20:49 +0000 (08:20 -0400)
committerWard Vandewege <ward@curii.com>
Fri, 6 May 2022 12:20:49 +0000 (08:20 -0400)
closes #19015

Arvados-DCO-1.1-Signed-off-by: Ward Vandewege <ward@curii.com>

tools/salt-install/config_examples/multi_host/aws/pillars/nginx_passenger.sls
tools/salt-install/config_examples/multi_host/aws/states/passenger_rvm.sls [new file with mode: 0644]
tools/salt-install/config_examples/single_host/multiple_hostnames/pillars/nginx_passenger.sls
tools/salt-install/config_examples/single_host/multiple_hostnames/states/passenger_rvm.sls [new file with mode: 0644]
tools/salt-install/config_examples/single_host/single_hostname/pillars/nginx_passenger.sls
tools/salt-install/config_examples/single_host/single_hostname/states/passenger_rvm.sls [new file with mode: 0644]
tools/salt-install/provision.sh

index fbd42bd7a36fba39680d629f46ad91b2da04bc1e..2b6b96c3a47cf84f764c9648ece1a5c80621df62 100644 (file)
@@ -25,6 +25,8 @@ nginx:
   ### 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
diff --git a/tools/salt-install/config_examples/multi_host/aws/states/passenger_rvm.sls b/tools/salt-install/config_examples/multi_host/aws/states/passenger_rvm.sls
new file mode 100644 (file)
index 0000000..cb4bc1a
--- /dev/null
@@ -0,0 +1,43 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: Apache-2.0
+
+{%- if grains.os_family in ('RedHat',) %}
+  {%- set group = 'nginx' %}
+{%- else %}
+  {%- set group = 'www-data' %}
+{%- endif %}
+
+# Make sure that /var/www/.passenger exists with the proper ownership
+# so that passenger can build passenger_native_support.so
+extra_var_www_passenger:
+  file.directory:
+    - name: /var/www/.passenger
+    - user: {{ group }}
+    - group: {{ group }}
+    - mode: '0755'
+    - makedirs: True
+
+{%- if grains.osfinger in ('CentOS Linux-7', 'Ubuntu-18.04', 'Debian-10') %}
+# Work around passenger issue when RVM is in use, cf
+# https://dev.arvados.org/issues/19015
+extra_nginx_set_gem_home:
+  file.managed:
+    - name: /etc/systemd/system/nginx.service.d/override.conf
+    - mode: '0644'
+    - user: root
+    - group: root
+    - makedirs: True
+    - replace: False
+    - contents: |
+        [Service]
+        ExecStart=
+        ExecStart=/bin/bash -a -c "GEM_HOME=`[ -x /usr/local/rvm/bin/rvm-exec ] && /usr/local/rvm/bin/rvm-exec default env |grep GEM_HOME=|cut -f2 -d= || true` && /usr/sbin/nginx -g 'daemon on; master_process on;'"
+  cmd.run:
+    - name: systemctl daemon-reload
+    - require:
+      - file: extra_nginx_set_gem_home
+      - file: extra_var_www_passenger
+    - onchanges:
+      - file: extra_nginx_set_gem_home
+{%- endif -%}
index dbf21c265129d9721fa50e63b17bb5a3bfd612b6..e51ec21eb919278215d37bc37f46755017a7ea36 100644 (file)
@@ -25,6 +25,8 @@ nginx:
   ### 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
diff --git a/tools/salt-install/config_examples/single_host/multiple_hostnames/states/passenger_rvm.sls b/tools/salt-install/config_examples/single_host/multiple_hostnames/states/passenger_rvm.sls
new file mode 100644 (file)
index 0000000..cb4bc1a
--- /dev/null
@@ -0,0 +1,43 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: Apache-2.0
+
+{%- if grains.os_family in ('RedHat',) %}
+  {%- set group = 'nginx' %}
+{%- else %}
+  {%- set group = 'www-data' %}
+{%- endif %}
+
+# Make sure that /var/www/.passenger exists with the proper ownership
+# so that passenger can build passenger_native_support.so
+extra_var_www_passenger:
+  file.directory:
+    - name: /var/www/.passenger
+    - user: {{ group }}
+    - group: {{ group }}
+    - mode: '0755'
+    - makedirs: True
+
+{%- if grains.osfinger in ('CentOS Linux-7', 'Ubuntu-18.04', 'Debian-10') %}
+# Work around passenger issue when RVM is in use, cf
+# https://dev.arvados.org/issues/19015
+extra_nginx_set_gem_home:
+  file.managed:
+    - name: /etc/systemd/system/nginx.service.d/override.conf
+    - mode: '0644'
+    - user: root
+    - group: root
+    - makedirs: True
+    - replace: False
+    - contents: |
+        [Service]
+        ExecStart=
+        ExecStart=/bin/bash -a -c "GEM_HOME=`[ -x /usr/local/rvm/bin/rvm-exec ] && /usr/local/rvm/bin/rvm-exec default env |grep GEM_HOME=|cut -f2 -d= || true` && /usr/sbin/nginx -g 'daemon on; master_process on;'"
+  cmd.run:
+    - name: systemctl daemon-reload
+    - require:
+      - file: extra_nginx_set_gem_home
+      - file: extra_var_www_passenger
+    - onchanges:
+      - file: extra_nginx_set_gem_home
+{%- endif -%}
index c25720c60a5fb17bc7aa3d5199a6ba79b82066db..2b764eb2c25b69bc1c03097b7987077da425678d 100644 (file)
@@ -25,6 +25,8 @@ nginx:
   ### 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
diff --git a/tools/salt-install/config_examples/single_host/single_hostname/states/passenger_rvm.sls b/tools/salt-install/config_examples/single_host/single_hostname/states/passenger_rvm.sls
new file mode 100644 (file)
index 0000000..cb4bc1a
--- /dev/null
@@ -0,0 +1,43 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: Apache-2.0
+
+{%- if grains.os_family in ('RedHat',) %}
+  {%- set group = 'nginx' %}
+{%- else %}
+  {%- set group = 'www-data' %}
+{%- endif %}
+
+# Make sure that /var/www/.passenger exists with the proper ownership
+# so that passenger can build passenger_native_support.so
+extra_var_www_passenger:
+  file.directory:
+    - name: /var/www/.passenger
+    - user: {{ group }}
+    - group: {{ group }}
+    - mode: '0755'
+    - makedirs: True
+
+{%- if grains.osfinger in ('CentOS Linux-7', 'Ubuntu-18.04', 'Debian-10') %}
+# Work around passenger issue when RVM is in use, cf
+# https://dev.arvados.org/issues/19015
+extra_nginx_set_gem_home:
+  file.managed:
+    - name: /etc/systemd/system/nginx.service.d/override.conf
+    - mode: '0644'
+    - user: root
+    - group: root
+    - makedirs: True
+    - replace: False
+    - contents: |
+        [Service]
+        ExecStart=
+        ExecStart=/bin/bash -a -c "GEM_HOME=`[ -x /usr/local/rvm/bin/rvm-exec ] && /usr/local/rvm/bin/rvm-exec default env |grep GEM_HOME=|cut -f2 -d= || true` && /usr/sbin/nginx -g 'daemon on; master_process on;'"
+  cmd.run:
+    - name: systemctl daemon-reload
+    - require:
+      - file: extra_nginx_set_gem_home
+      - file: extra_var_www_passenger
+    - onchanges:
+      - file: extra_nginx_set_gem_home
+{%- endif -%}
index 669d04d92fa250dbe6a17978add5d5b88d3706e5..be1506c620e7aec8dbc5e58910c982aecd5b6f14 100755 (executable)
@@ -274,7 +274,7 @@ if [ ! -z "${HOSTNAME_EXT}" ] ; then
   # Make sure that the value configured as IP_INT is a real IP on the system.
   # If we don't error out early here when there is a mismatch, the formula will
   # fail with hard to interpret nginx errors later on.
-  ip addr list |grep -q "${IP_INT}/"
+  ip addr list |grep "${IP_INT}/" >/dev/null
   if [[ $? -ne 0 ]]; then
     echo "Unable to find the IP_INT address '${IP_INT}' on the system, please correct the value in local.params. Exiting..."
     exit 1
@@ -302,7 +302,10 @@ else
       yum install -y  curl git jq
       ;;
     "debian"|"ubuntu")
-      DEBIAN_FRONTEND=noninteractive apt update
+      # Wait 2 minutes for any apt locks to clear
+      # This option is supported from apt 1.9.1 and ignored in older apt versions.
+      # Cf. https://blog.sinjakli.co.uk/2021/10/25/waiting-for-apt-locks-without-the-hacky-bash-scripts/
+      DEBIAN_FRONTEND=noninteractive apt -o DPkg::Lock::Timeout=120 update
       DEBIAN_FRONTEND=noninteractive apt install -y curl git jq
       ;;
   esac
@@ -565,6 +568,7 @@ if [ -z "${ROLES}" ]; then
   echo "    - arvados" >> ${S_DIR}/top.sls
   echo "    - extra.shell_sudo_passwordless" >> ${S_DIR}/top.sls
   echo "    - extra.shell_cron_add_login_sync" >> ${S_DIR}/top.sls
+  echo "    - extra.passenger_rvm" >> ${S_DIR}/top.sls
 
   # Pillars
   echo "    - docker" >> ${P_DIR}/top.sls
@@ -657,6 +661,7 @@ else
         else
           echo "    - nginx.passenger" >> ${S_DIR}/top.sls
         fi
+        echo "    - extra.passenger_rvm" >> ${S_DIR}/top.sls
         ### If we don't install and run LE before arvados-api-server, it fails and breaks everything
         ### after it. So we add this here as we are, after all, sharing the host for api and controller
         if [ "${SSL_MODE}" = "lets-encrypt" ]; then