blob: a50ae36ec144f6d8fe9de8dc60fdd814185577c3 [file] [log] [blame]
{%- from "linux/map.jinja" import system with context %}
{%- if system.enabled %}
{%- for name, service in system.service.items() %}
{%- if service.name is defined %}
{%- set service_name = service.name %}
{%- else %}
{%- set service_name = name %}
{%- endif %}
{%- if service.status == 'running' %}
{%- if grains.get('init', None) == 'systemd' %}
{%- if service.override is defined %}
{%- for order,rule in service.override.items() %}
{%- if rule.get('enabled', True) %}
{{ service_name }}_{{ order }}_override:
file.managed:
- name: /etc/systemd/system/{{ rule.target }}/{{ order }}-{{ rule.name }}.conf
- contents_pillar: linux:system:service:{{ name }}:override:{{ order}}:content
- makedirs: True
- user: root
- group: root
- watch_in:
- module: {{ service_name }}_systemd_reload
- service: {{ service_name }}_service
{%- endif %}
{%- endfor %}
{{ service_name }}_systemd_reload:
module.wait:
- name: service.systemctl_reload
- watch_in:
- service: {{ service_name }}_service
{{ service_name }}_service:
service.running:
- name: {{ service_name }}
- enable: {{ service.get('enabled', True) }}
{%- if grains.get('noservices') %}
- onlyif: /bin/false
{%- endif %}
{%- endif %}
{%- endif %}
{%- elif service.status == 'dead' %}
{{ service_name }}_service:
service.dead:
- name: {{ service_name }}
- enable: {{ service.get('enabled', False) }}
{%- if grains.get('noservices') %}
- onlyif: /bin/false
{%- endif %}
{%- endif %}
{%- endfor %}
{%- endif %}