summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--inventory/host_vars/ch-greenbone.yml1
-rw-r--r--roles/greenbone/server/defaults/main.yml2
-rw-r--r--roles/greenbone/server/tasks/main.yml17
-rw-r--r--roles/greenbone/server/templates/systemd.service.j28
-rw-r--r--roles/greenbone/server/templates/systemd.timer.j29
5 files changed, 37 insertions, 0 deletions
diff --git a/inventory/host_vars/ch-greenbone.yml b/inventory/host_vars/ch-greenbone.yml
index 674b102e..d6ad35ce 100644
--- a/inventory/host_vars/ch-greenbone.yml
+++ b/inventory/host_vars/ch-greenbone.yml
@@ -85,3 +85,4 @@ greenbone_server_tls:
renew_margin: +70d
greenbone_server_admin_password: "{{ vault_greenbone_server_admin_password }}"
+greenbone_feed_update_schedule: "*-*-* 08:15:00"
diff --git a/roles/greenbone/server/defaults/main.yml b/roles/greenbone/server/defaults/main.yml
index 9844fdbb..d4c58442 100644
--- a/roles/greenbone/server/defaults/main.yml
+++ b/roles/greenbone/server/defaults/main.yml
@@ -8,3 +8,5 @@ greenbone_server_version: 22.4
# ...
# greenbone_server_admin_password: secret
+
+# greenbone_feed_update_schedule: 08:08
diff --git a/roles/greenbone/server/tasks/main.yml b/roles/greenbone/server/tasks/main.yml
index 6fd11271..090f2746 100644
--- a/roles/greenbone/server/tasks/main.yml
+++ b/roles/greenbone/server/tasks/main.yml
@@ -71,3 +71,20 @@
exit 0
dest: "/usr/local/bin/update-greenbone.{{ greenbone_server_hostname }}"
mode: 0755
+
+- name: install systemd units for feed updates
+ when: greenbone_feed_update_schedule is defined
+ loop:
+ - service
+ - timer
+ template:
+ src: "systemd.{{ item }}.j2"
+ dest: "/etc/systemd/system/update-greenbone_{{ greenbone_server_hostname }}.{{ item }}"
+
+- name: make sure systemd is started and enabled
+ when: greenbone_feed_update_schedule is defined
+ systemd:
+ daemon_reload: yes
+ name: "update-greenbone_{{ greenbone_server_hostname }}.timer"
+ enabled: yes
+ state: started
diff --git a/roles/greenbone/server/templates/systemd.service.j2 b/roles/greenbone/server/templates/systemd.service.j2
new file mode 100644
index 00000000..42a92760
--- /dev/null
+++ b/roles/greenbone/server/templates/systemd.service.j2
@@ -0,0 +1,8 @@
+[Unit]
+Description=greenbone feed update for {{ greenbone_server_hostname }}
+After=docker.service
+Requires=docker.service
+
+[Service]
+Type=oneshot
+ExecStart="/usr/local/bin/update-greenbone.{{ greenbone_server_hostname }}"
diff --git a/roles/greenbone/server/templates/systemd.timer.j2 b/roles/greenbone/server/templates/systemd.timer.j2
new file mode 100644
index 00000000..d162c3a1
--- /dev/null
+++ b/roles/greenbone/server/templates/systemd.timer.j2
@@ -0,0 +1,9 @@
+[Unit]
+Description=greenbone feed update for {{ greenbone_server_hostname }}
+
+[Timer]
+OnCalendar={{ greenbone_feed_update_schedule }}
+AccuracySec=10s
+
+[Install]
+WantedBy=timers.target