19015: installer fix: work around a Passenger issue with the detection of RVM
[arvados.git] / tools / salt-install / config_examples / single_host / multiple_hostnames / states / passenger_rvm.sls
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: Apache-2.0
4
5 {%- if grains.os_family in ('RedHat',) %}
6   {%- set group = 'nginx' %}
7 {%- else %}
8   {%- set group = 'www-data' %}
9 {%- endif %}
10
11 # Make sure that /var/www/.passenger exists with the proper ownership
12 # so that passenger can build passenger_native_support.so
13 extra_var_www_passenger:
14   file.directory:
15     - name: /var/www/.passenger
16     - user: {{ group }}
17     - group: {{ group }}
18     - mode: '0755'
19     - makedirs: True
20
21 {%- if grains.osfinger in ('CentOS Linux-7', 'Ubuntu-18.04', 'Debian-10') %}
22 # Work around passenger issue when RVM is in use, cf
23 # https://dev.arvados.org/issues/19015
24 extra_nginx_set_gem_home:
25   file.managed:
26     - name: /etc/systemd/system/nginx.service.d/override.conf
27     - mode: '0644'
28     - user: root
29     - group: root
30     - makedirs: True
31     - replace: False
32     - contents: |
33         [Service]
34         ExecStart=
35         ExecStart=/bin/bash -a -c "GEM_HOME=`/usr/local/rvm/bin/rvm-exec default env |grep GEM_HOME=|cut -f2 -d=` && /usr/sbin/nginx -g 'daemon on; master_process on;'"
36   cmd.run:
37     - name: systemctl daemon-reload
38     - require:
39       - file: extra_nginx_set_gem_home
40       - file: extra_var_www_passenger
41     - onchanges:
42       - file: extra_nginx_set_gem_home
43 {%- endif -%}