feat(lego): allow configuring permissions of lego's certificate store folder

This commit is contained in:
Johanna Dorothea Reichmann 2021-11-09 09:23:31 +01:00
parent 84c8e7ca0d
commit b980e37177
No known key found for this signature in database
GPG key ID: 03624C433676E465
3 changed files with 19 additions and 2 deletions

View file

@ -1,5 +1,9 @@
---
lego_base_path: /opt/lego
lego_certificate_store: "{{ lego_base_path }}/certificates"
lego_certificate_store_user: "{{ lego_user_res.uid | default(lego_user) }}"
lego_certificate_store_group: "{{ lego_user_res.group | default(lego_user) }}"
lego_certificate_store_mode: "0750"
lego_systemd_path: /etc/systemd/system
lego_version: 4.5.2
lego_system_type: "linux"

View file

@ -14,8 +14,17 @@
file:
path: "{{ lego_base_path }}"
state: directory
owner: "{{ lego_user_res.uid }}"
group: "{{ lego_user_res.group }}"
owner: "{{ lego_certificate_store_user }}"
group: "{{ lego_certificate_store_group }}"
mode: "0755"
- name: Ensure certificate directory exists and has the configured permissions
file:
path: "{{ lego_certificate_store }}"
state: directory
owner: "{{ lego_certificate_store_user }}"
group: "{{ lego_certificate_store_group }}"
mode: "{{ lego_certificate_store_mode }}"
- name: Check if binary exsists and is the correct version
command:

View file

@ -12,7 +12,11 @@ Type=oneshot
Group={{ lego_user_res.group }}
User={{ lego_user_res.name }}
WorkingDirectory={{ lego_base_path }}
ExecStartPre=+-chown {{ lego_certificate_store_user }}:{{ lego_certificate_store_group }} {{ lego_certificate_store }}
ExecStartPre=+-chmod {{ lego_certificate_store_mode }} {{ lego_certificate_store }}
ExecStart={{ lego_command_systemd }}
ExecStartPost=+-/bin/sh -c 'chown {{ lego_certificate_store_user }}:{{ lego_certificate_store_group }} {{ lego_certificate_store }}/*'
ExecStartPost=+-/bin/sh -c 'chmod 0640 {{ lego_certificate_store }}/*'
[Install]
WantedBy=multi-user.target