Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ops/ansible/inventories/legislation.demo.openfisca.org.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ all:

letsencrypt_email: contact@openfisca.org
letsencrypt_environment: production

autorestart_frequency: "*-*-* 00:10:00"
2 changes: 2 additions & 0 deletions ops/ansible/inventories/legislation.fr.openfisca.org.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ all:

letsencrypt_email: contact@openfisca.org
letsencrypt_environment: production

autorestart_frequency: "*-*-* 01:10:00"
3 changes: 3 additions & 0 deletions ops/ansible/roles/legislation_explorer/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ source_dir: legislation-explorer # relative to the home directory
systemd_service_file_name: legislation-explorer.service
unix_group_name: openfisca
unix_user_name: legislation-explorer

systemd_timer_file_name: "{{ systemd_service_file_name | replace('.service', '.timer') }}"
autorestart_frequency: daily
12 changes: 12 additions & 0 deletions ops/ansible/roles/legislation_explorer/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,25 @@
src: systemd/legislation-explorer.service.j2
dest: "/etc/systemd/system/{{ systemd_service_file_name }}"

- name: Copy the systemd timer file
ansible.builtin.template:
src: systemd/legislation-explorer.timer.j2
dest: "/etc/systemd/system/{{ systemd_timer_file_name }}"

- name: Enable and start the systemd service
ansible.builtin.systemd:
daemon_reload: yes
enabled: yes
state: restarted
name: "{{ systemd_service_file_name }}"

- name: Enable and start the systemd timer
ansible.builtin.systemd:
daemon_reload: yes
enabled: yes
state: started
name: "{{ systemd_timer_file_name }}"

- name: Check that Legislation Explorer is actually started
ansible.builtin.uri:
return_content: yes
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=Restart OpenFisca Legislation Explorer

[Timer]
OnCalendar={{ autorestart_frequency }}
Persistent=true
Unit={{ systemd_service_file_name }}

[Install]
WantedBy=timers.target