diff --git a/defaults/main.yml b/defaults/main.yml index 4966374..5418d0b 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -45,3 +45,11 @@ omero_prometheus_tools_requirements: default('zeroc-ice')}}" - omero-py>=5.18.0 - "omero-prometheus-tools=={{ omero_prometheus_tools_version }}" + +environment_file_path: + RedHat: "-/etc/sysconfig/prometheus-omero-exporter" + Debian: "-/etc/prometheus-omero-exporter" + +systemd_prometheus_omero_exporter_env_file_path: >- + {{ environment_file_path[ansible_os_family] | + default('/etc')}} diff --git a/tasks/main.yml b/tasks/main.yml index 5e8c70c..4eda6b3 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -72,17 +72,6 @@ mode: 0644 notify: - restart prometheus-omero-exporter - when: ansible_os_family == "RedHat" - -- name: omero prometheus exporter | install service - become: true - template: - dest: /etc/systemd/system/prometheus-omero-exporter.service - src: systemd-prometheus-omero-exporter-service-debian.j2 - mode: 0644 - notify: - - restart prometheus-omero-exporter - when: ansible_os_family == "Debian" - name: omero prometheus exporter | enable service become: true diff --git a/templates/systemd-prometheus-omero-exporter-service-debian.j2 b/templates/systemd-prometheus-omero-exporter-service-debian.j2 deleted file mode 100644 index edefc9f..0000000 --- a/templates/systemd-prometheus-omero-exporter-service-debian.j2 +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=prometheus-omero-exporter - -[Service] -User={{ omero_prometheus_exporter_system_user }} -EnvironmentFile=-/etc/prometheus-omero-exporter -ExecStart=/opt/prometheus-omero-tools/venv3/bin/omero-prometheus-tools.py $OPTIONS -RestartSec=10 -Restart=on-failure -SyslogIdentifier=prometheus-omero-exporter - -[Install] -WantedBy=multi-user.target diff --git a/templates/systemd-prometheus-omero-exporter-service.j2 b/templates/systemd-prometheus-omero-exporter-service.j2 index 4ea596a..b412264 100644 --- a/templates/systemd-prometheus-omero-exporter-service.j2 +++ b/templates/systemd-prometheus-omero-exporter-service.j2 @@ -3,7 +3,7 @@ Description=prometheus-omero-exporter [Service] User={{ omero_prometheus_exporter_system_user }} -EnvironmentFile=-/etc/sysconfig/prometheus-omero-exporter +EnvironmentFile={{ systemd_prometheus_omero_exporter_env_file_path }} ExecStart=/opt/prometheus-omero-tools/venv3/bin/omero-prometheus-tools.py $OPTIONS RestartSec=10 Restart=on-failure