# HG changeset patch # User Luke Hoersten # Date 1597000824 18000 # Node ID 746d5fdbbc187a241f7b28f360f57e10813743d0 # Parent 46785fdb4fc550b0c7b1b059a5bf987876535171 Added periodit goaccess update role diff -r 46785fdb4fc5 -r 746d5fdbbc18 goaccess/defaults/main.yaml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/goaccess/defaults/main.yaml Sun Aug 09 14:20:24 2020 -0500 @@ -0,0 +1,5 @@ +--- + +goaccess_timer_freq: "hourly" +goaccess_http_log: "/var/log/nginx/access.log" +goaccess_output_dest: "/var/www/report.html" diff -r 46785fdb4fc5 -r 746d5fdbbc18 goaccess/handlers/main.yaml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/goaccess/handlers/main.yaml Sun Aug 09 14:20:24 2020 -0500 @@ -0,0 +1,5 @@ +--- + +- name: daemon reload + systemd: name="goaccess.timer" enabled="yes" daemon_reload="yes" + become: yes diff -r 46785fdb4fc5 -r 746d5fdbbc18 goaccess/tasks/main.yaml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/goaccess/tasks/main.yaml Sun Aug 09 14:20:24 2020 -0500 @@ -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 -r 46785fdb4fc5 -r 746d5fdbbc18 goaccess/templates/goaccess.service.j2 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/goaccess/templates/goaccess.service.j2 Sun Aug 09 14:20:24 2020 -0500 @@ -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 -r 46785fdb4fc5 -r 746d5fdbbc18 goaccess/templates/goaccess.timer.j2 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/goaccess/templates/goaccess.timer.j2 Sun Aug 09 14:20:24 2020 -0500 @@ -0,0 +1,9 @@ +[Unit] +Description=GoAccess refresh timer + +[Timer] +OnCalendar={{goaccess_timer_freq}} +Unit=goaccess.service + +[Install] +WantedBy=timers.target