Skip to content

Commit

Permalink
Added certificate watcher service.
Browse files Browse the repository at this point in the history
  • Loading branch information
patbec committed Sep 25, 2023
1 parent bfeb85e commit 3fab251
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
21 changes: 21 additions & 0 deletions playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,22 @@
group: root
mode: "0644"

- name: Template nginx watcher configuration
ansible.builtin.template:
src: nginx.watcher.conf.j2
dest: /etc/systemd/system/nginx.watcher.conf
owner: root
group: root
mode: "0644"

- name: Template nginx watcher path
ansible.builtin.template:
src: nginx.watcher.path.j2
dest: /etc/systemd/system/nginx.watcher.path
owner: root
group: root
mode: "0644"

- name: Stop nginx if configuration has changed
ansible.builtin.meta: flush_handlers

Expand All @@ -106,6 +122,11 @@
state: started
enabled: true

- name: Ensure watcher is enabled
ansible.builtin.service:
name: nginx
enabled: true

handlers:
- name: Stop nginx
ansible.builtin.service:
Expand Down
5 changes: 5 additions & 0 deletions templates/nginx.watcher.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# {{ ansible_managed }}

[Service]
Type=oneshot
ExecStart=/usr/bin/systemctl reload nginx.service
9 changes: 9 additions & 0 deletions templates/nginx.watcher.path.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# {{ ansible_managed }}

[Path]
# Activates the unit whenever it changes. It is not activated on every write to the
# watched file but it is activated if the file which was open for writing gets closed.
PathChanged=/etc/pve/local/pveproxy-ssl.pem

[Install]
WantedBy=multi-user.target

0 comments on commit 3fab251

Please sign in to comment.