ansible-development-environ.../roles/service/templates/systemd.j2

45 lines
1.1 KiB
Django/Jinja

{{ ansible_managed | comment }}
[Unit]
Description={{ item.description }}
{% if item.after is defined %}
After={{ item.after }}
{% endif %}
[Service]
{% if item.type is defined and item.type != "simple" %}
Type={{ item.type }}
{% endif %}
{% if item.working_directory is defined %}
WorkingDirectory={{ item.working_directory }}
{% endif %}
{% if item.user_name is defined %}
User={{ item.user_name }}
{% endif %}
{% if item.group_name is defined %}
Group={{ item.group_name }}
{% endif %}
ExecStart={{ item.start_command }}
{% if item.stop_command is defined %}
ExecStop={{ item.stop_command }}
{% endif %}
{% if item.environment_variables is defined %}
{% for key in item.environment_variables %}
Environment={{ key }}={{ item.environment_variables[key] }}
{% endfor %}
{% endif %}
{% if item.environmentfile is defined %}
EnvironmentFile={{ item.environmentfile }}
{% endif %}
{% if item.restart_mode is defined %}
Restart={{ item.restart_mode }}
{% endif %}
{% if item.restart_seconds is defined %}
RestartSec={{ item.restart_seconds }}
{% endif %}
{% if item.pidfile is defined %}
PIDFile={{ item.pidfile }}
{% endif %}
[Install]
WantedBy=multi-user.target