summaryrefslogtreecommitdiff
path: root/README
blob: 3036d690b7ebf806dc56919c5ccc6ac3df7841d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# The Bike Project Visitor Log Playbook #
This repository contains the content needed to run the bike project visitor log.

- Ansible is used to configure the host server
- The visitor logging software runs in a docker container
- The logs themselves are stored in text files in /var/tbp
- Reporting is available via tbpReport.sh

# Ansible #
Ansible is a tool for configuring a server.  The setup.yml and accompanying yml
files in the tasks/ directory tell ansible how to configure the server (create
users, copy files, run docker, etc)

## Getting started
### Configuration
First, server specific variables must be set in the localhosts file:

domainname: The domainname of the server (e.g. google.com)
letsencrypt_test: Typically false.  Set to true when testing to avoid
    LetsEncrypt ratelimiting.
tbp_server: URL to access the visitor log from.  Should be subdomain.domainname
    (e.g. tbp.google.com)
tbp_username: User that will own log files.  The user will be created if it does
    not exist.  Container will run as this user.
tbp_uid: UID to use for the user.

### Installing ansible
From this directory, run:
    
    $ pip install -r requirements.txt

### Running ansible
Simply run this command:

    $ ansible-playbook -i localhosts setup.yml

# The Vistor Log and Docker
The docker container is just a lighttpd image with cgi enabled and the bash
script that runs the logging webpage.  I wrote it mainly for my enjoyment years
ago, so I can't make many promises on readability.  It's probably good to keep
CGI stuff containerized.

## File structure
The following files are created on the host filesystem and mounted in the tbp
container:

- /var/tbp/firsttime.txt: Hashed list of first visits.  Used to determine if a
  visitor has used there "one free visit"
- /var/tbp/members.csv: The LittleGreenLight member list.  CSV with the
  following columns

"LGL Constituent ID","External Constituent ID","First Name","Last Name","LGL
membership ID","Membership level","Membership status","Membership end"

- /var/tbp/visits.csv: Record of visitors

## Member Update
Ansible creates a cronjob in `tbp_username`'s crontab to update the member list every 6 hours.

## Reporting
./docker/tbp/tbpReport.sh is a script that can generate a report.

One week report

    $ tbpReport.sh -w /var/tbp/visits.csv

One month report

    $ tbpReport.sh -m /var/tbp/visits.csv

One year report

    $ tbpReport.sh -y /var/tbp/visits.csv

The server can send this report via email:

    $ tbpReport.sh -w /var/tbp/visits.csv | mutt -s "Weekly TBP Visit Report" -- foo@gmail.com

Scheduled reporting is not configured by ansible as email configurations will
vary.