From f689e65a72ae9693c0a17987c8e32d724bb9fb6c Mon Sep 17 00:00:00 2001 From: Luke Hoersten Date: Sun, 9 Aug 2020 14:20:24 -0500 Subject: Added periodit goaccess update role --- goaccess/defaults/main.yaml | 5 +++++ goaccess/handlers/main.yaml | 5 +++++ goaccess/tasks/main.yaml | 17 +++++++++++++++++ goaccess/templates/goaccess.service.j2 | 11 +++++++++++ goaccess/templates/goaccess.timer.j2 | 9 +++++++++ 5 files changed, 47 insertions(+) create mode 100644 goaccess/defaults/main.yaml create mode 100644 goaccess/handlers/main.yaml create mode 100644 goaccess/tasks/main.yaml create mode 100644 goaccess/templates/goaccess.service.j2 create mode 100644 goaccess/templates/goaccess.timer.j2 (limited to 'goaccess') diff --git a/goaccess/defaults/main.yaml b/goaccess/defaults/main.yaml new file mode 100644 index 0000000..b11b6d7 --- /dev/null +++ b/goaccess/defaults/main.yaml @@ -0,0 +1,5 @@ +--- + +goaccess_timer_freq: "hourly" +goaccess_http_log: "/var/log/nginx/access.log" +goaccess_output_dest: "/var/www/report.html" diff --git a/goaccess/handlers/main.yaml b/goaccess/handlers/main.yaml new file mode 100644 index 0000000..4d540b5 --- /dev/null +++ b/goaccess/handlers/main.yaml @@ -0,0 +1,5 @@ +--- + +- name: daemon reload + systemd: name="goaccess.timer" enabled="yes" daemon_reload="yes" + become: yes diff --git a/goaccess/tasks/main.yaml b/goaccess/tasks/main.yaml new file mode 100644 index 0000000..6d65396 --- /dev/null +++ b/goaccess/tasks/main.yaml @@ -0,0 +1,17 @@ +--- + +- name: apt install goaccess + become: yes + apt: name="goaccess" + +- name: install systemd timer and service + become: yes + template: src="goaccess.{{item}}.j2" dest="/lib/systemd/system/goaccess.{{item}}" + loop: + - "timer" + - "service" + notify: daemon reload + +- name: ensure timer is started + become: yes + systemd: name="goaccess.timer" enabled="yes" state="started" diff --git a/goaccess/templates/goaccess.service.j2 b/goaccess/templates/goaccess.service.j2 new file mode 100644 index 0000000..aa1e929 --- /dev/null +++ b/goaccess/templates/goaccess.service.j2 @@ -0,0 +1,11 @@ +[Unit] +Description=GoAccess + +[Service] +Type=oneshot +ExecStart=/usr/bin/goaccess {{goaccess_http_log}} -o {{goaccess_output_dest}} --log-format=COMBINED --no-progress --no-parsing-spinner +RemainAfterExit=true +Environment=HOME=/var/run + +[Install] +WantedBy=multi-user.target diff --git a/goaccess/templates/goaccess.timer.j2 b/goaccess/templates/goaccess.timer.j2 new file mode 100644 index 0000000..7f68e81 --- /dev/null +++ b/goaccess/templates/goaccess.timer.j2 @@ -0,0 +1,9 @@ +[Unit] +Description=GoAccess refresh timer + +[Timer] +OnCalendar={{goaccess_timer_freq}} +Unit=goaccess.service + +[Install] +WantedBy=timers.target -- cgit v1.2.3