From 032107d9554f275792eab1f6ac4425365f6c5d74 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Sat, 28 Sep 2024 22:32:56 +0200 Subject: [PATCH] fix systemd env location --- tasks/main.yml | 13 ++++++++++++- templates/etc/systemd/system/lego-renew.service.j2 | 2 +- vars/debian.yml | 2 ++ vars/redhat.yml | 2 ++ 4 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 vars/debian.yml create mode 100644 vars/redhat.yml diff --git a/tasks/main.yml b/tasks/main.yml index 70c092b..387e8f3 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,4 +1,15 @@ --- +- name: Include OS specific vars + ansible.builtin.include_vars: "{{ lookup('first_found', params) }}" + vars: + params: + files: + - "{{ ansible_lsb.id | default('') | lower }}.yml" + - "{{ ansible_os_family | lower }}.yml" + paths: + - "vars" + errors: "ignore" + - name: Install lego ansible.legacy.unarchive: src: https://github.com/go-acme/lego/releases/download/v{{ lego_version }}/lego_v{{ lego_version }}_linux_amd64.tar.gz @@ -62,7 +73,7 @@ - name: Write environment file ansible.builtin.template: src: etc/sysconfig/lego.j2 - dest: /etc/sysconfig/lego + dest: "{{ __lego_systemd_env }}" mode: "0600" notify: __lego_restart diff --git a/templates/etc/systemd/system/lego-renew.service.j2 b/templates/etc/systemd/system/lego-renew.service.j2 index ba254ae..3fbeab6 100644 --- a/templates/etc/systemd/system/lego-renew.service.j2 +++ b/templates/etc/systemd/system/lego-renew.service.j2 @@ -7,7 +7,7 @@ After=network-online.target [Service] Type=oneshot -EnvironmentFile=/etc/sysconfig/lego +EnvironmentFile={{ __lego_systemd_env }} {% for cert in lego_certificates %} ExecStart={{ __lego_bin_file }} --email="{{ lego_acme_account_email }}" --domains {{ ' --domains '.join(cert.domains) }} $ARGS renew {{ '--renew-hook="' + __lego_base_dir + '/hooks/' + cert.name + '.sh"' if cert.hook is defined else '' }} --days 30 diff --git a/vars/debian.yml b/vars/debian.yml new file mode 100644 index 0000000..73549ab --- /dev/null +++ b/vars/debian.yml @@ -0,0 +1,2 @@ +--- +__lego_systemd_env: /etc/default/lego diff --git a/vars/redhat.yml b/vars/redhat.yml new file mode 100644 index 0000000..acb111b --- /dev/null +++ b/vars/redhat.yml @@ -0,0 +1,2 @@ +--- +__lego_systemd_env: /etc/sysconfig/lego