Commit aa7b3709 authored by Philippe Pepiot's avatar Philippe Pepiot Committed by Denis Laxalde
Browse files

map.jinja: set os dependent variables in 'os_family_map'

So we can override them in saemref.lookup
parent 2cc869e6
{% import_yaml 'saemref/defaults.yaml' as default_settings %}
{% set os_family_map = salt['grains.filter_by']({
'Debian': {},
'RedHat': {},
'Debian': {
'supervisor_conffile': '/etc/supervisor/conf.d/saemref.conf',
'supervisor_service_name': 'supervisor',
},
'RedHat': {
'supervisor_conffile': '/etc/supervisord.d/saemref.ini',
'supervisor_service_name': 'supervisord',
},
},
grain="os_family",
merge=salt['pillar.get']('saemref:lookup'))
......@@ -17,14 +23,4 @@
)
%}
{% if grains['os_family'] == 'RedHat' %}
{% set supervisor_confdir = '/etc/supervisord.d/' %}
{% set supervisor_conffile = [supervisor_confdir, 'saemref.ini']|join('/') %}
{% set supervisor_service_name = 'supervisord' %}
{% else %}{# Debian #}
{% set supervisor_confdir = '/etc/supervisor/conf.d' %}
{% set supervisor_conffile = [supervisor_confdir, 'saemref.conf']|join('/') %}
{% set supervisor_service_name = 'supervisor' %}
{% endif %}
{% set is_docker_build = (salt['cmd.retcode']('/bin/sh -c "(readlink -f /sbin/init | grep -q systemd) && ! (readlink -f /proc/1/exe | grep systemd)"') == 0) %}
{% from "saemref/map.jinja" import saemref, supervisor_confdir, supervisor_conffile, supervisor_service_name, is_docker_build with context %}
{% from "saemref/map.jinja" import saemref, is_docker_build with context %}
include:
- saemref.install
......@@ -7,21 +7,16 @@ supervisor:
pkg:
- installed
supervisor_confdir:
file.directory:
- name: {{ supervisor_confdir }}
- require:
- pkg: supervisor
{{ supervisor_conffile }}:
{{ saemref.supervisor_conffile }}:
file.managed:
- source: salt://saemref/files/saemref-supervisor.conf
- template: jinja
{% if grains['os_family'] != 'Debian' %}
- user: {{ saemref.instance.user }}
{% endif %}
- makedirs: true
- require:
- file: supervisor_confdir
- pkg: supervisor
supervisor-service-running:
{% if is_docker_build %}
......@@ -30,9 +25,9 @@ Salt fail to enable a systemd service if systemd is not running (during the
docker build phase) This is a workaround.
#}
cmd.run:
- name: systemctl enable {{ supervisor_service_name }}
- name: systemctl enable {{ saemref.supervisor_service_name }}
{% else %}
service.running:
- name: {{ supervisor_service_name }}
- name: {{ saemref.supervisor_service_name }}
- enable: true
{% endif %}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment