system-config/playbooks/periodic/goaccess.yaml
Clark Boylan 9e394d24d0 Return goaccess html as zuul artifact
This will give us a nice link to the goaccess reports on the zuul
dashboard build pages.

Move ansible-lint config into config file

As of 4.2.0 we can configure ansible-lint with a config file. It's
also apparently now smart enough to only find ansible yaml. Let's
see how that goes.

Add a fake zuul_return module

This should let us fake out ansible-lint without having to install
all of zuul.

Change-Id: Ib233eb577a8ca2aabfe3a49b2cd823dd4a00bd82
2020-03-11 14:28:28 -05:00

78 lines
2.8 KiB
YAML

- hosts: localhost
tasks:
- name: Add static.opendev.org to inventory
add_host:
name: static.opendev.org
ansible_connection: ssh
ansible_host: static.opendev.org
ansible_port: 22
ansible_user: zuul
- name: Add static.opendev.org host key
known_hosts:
name: static.opendev.org
key: static.opendev.org,23.253.245.150,2001:4800:7818:101:be76:4eff:fe04:7c28 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBMu3PnnkNhPS2d5Z2uPju3Qqcbbc0lwHA1j9MgHlLnbK3bx1O2Kfez6RJUGl2i6nshdzkKwPBvN2vehQKiw1oSk=
- hosts: static.opendev.org
tasks:
- name: Configure goaccess
copy:
dest: /home/zuul/goaccess.conf
owner: zuul
group: zuul
mode: '0444'
content: |
log-format COMBINED
ignore-panel VISITORS
ignore-panel REQUESTS
ignore-panel REQUESTS_STATIC
ignore-panel NOT_FOUND
ignore-panel HOSTS
ignore-panel OS
ignore-panel BROWSERS
ignore-panel VISIT_TIMES
ignore-panel VIRTUAL_HOSTS
ignore-panel REFERRERS
ignore-panel REFERRING_SITES
ignore-panel KEYPHRASES
ignore-panel STATUS_CODES
ignore-panel REMOTE_USER
ignore-panel GEO_LOCATION
enable-panel VISITORS
enable-panel REQUESTS
enable-panel REQUESTS_STATIC
enable-panel NOT_FOUND
enable-panel STATUS_CODES
- name: Run goaccess
become: yes
shell: |
# We will publish to the zuul homedir for now as that allows us to
# double check the data produced is clean before making it
# public.
OUT_FILE="/home/zuul/{{ goaccess_site }}_goaccess_report.html"
SOURCE_FILE="/var/log/apache2/{{ goaccess_site }}_access.log"
# This pipes in all the compressed logs as well as the current
# uncompressed logs. Giving us a window as wide as our log retention.
( cat ${SOURCE_FILE}{,.1} ; zcat ${SOURCE_FILE}.*.gz ) | goaccess -o $OUT_FILE -p /home/zuul/goaccess.conf -
args:
executable: /bin/bash
# Not using normal zuul job roles as static.opendev.org is not a
# test node with all the normal bits in place.
- name: Collect log output
synchronize:
dest: "{{ zuul.executor.log_root }}/{{ goaccess_site }}_goaccess_report.html"
mode: pull
src: "/home/zuul/{{ goaccess_site }}_goaccess_report.html"
verify_host: true
- name: Return goaccess artifact to Zuul
zuul_return:
data:
zuul:
artifacts:
- name: "Goaccess report"
url: "{{ goaccess_site }}_goaccess_report.html"
metadata:
type: html_report